Bug 4829 - Support 3rd party Assembly Integration within Visual Studio
Summary: Support 3rd party Assembly Integration within Visual Studio
Status: RESOLVED NORESPONSE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: Low enhancement
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2012-05-02 16:24 UTC by Jonathan Pryor
Modified: 2016-08-03 15:22 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Jonathan Pryor 2012-05-02 16:24:03 UTC
Many commercial entities will want to have their assemblies show up in the Visual Studio Add Assembly Reference dialog in Mono for Android projects. For "normal" .NET, this is supported via registry keys; see:

    http://support.microsoft.com/kb/306149

Unfortunately, the registry keys listed in the above article and the "obvious" alternatives are not used in Mono for Android + VS projects, e.g.:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MonoAndroid\AssemblyFolders

This despite verbose MSBuild output mentioning that the AssemblySearchPaths contains:

> AssemblySearchPaths =
>             {CandidateAssemblyFiles};
>             ;
>             {HintPathFromItem};
>             {TargetFrameworkDirectory};
>             {Registry:Software\Microsoft\MonoAndroid,v2.2,AssemblyFoldersEx};
>             {AssemblyFolders};
>             {GAC};
>             {RawFileName};
>             bin\Debug\

We should figure out how to more sanely integrate with Visual Studio so that 3rd party library providers don't need to stick their assemblies into the Mono for Android reference assemblies directory.
Comment 1 Jonathan Pobst 2012-05-03 00:08:55 UTC
Not sure there's much we can do.  If we can't find a way for VS to already support this, there is zero chance we will implementing it.
Comment 2 dean.ellis 2012-11-12 09:14:39 UTC
Third Parties can add the following structure to the registry and have their assemblies appear in the Extensions section in VS 2012

In HKLM or HKCU Software\Microsoft\MonoAndroid\v2.2\AssemblyFoldersEx

They need to add a folder for their Project and set the (Default) key to be the path of the location where the assemblies are installed. for example for ServiceStack there would be a key

HKLM\Software\Microsoft\MonoAndroid\v2.2\AssemblyFoldersEx\ServiceStack

and its (Default) REG_SZ value would point to the install directory for the ServiceStack assemblies.

Note this will show up all the assemblies in that folder, so if the framework has multiple versions it will probably be better to split the Android assemblies into their own directory. 

This is how both VS 2010 and VS 2012 work. 

Using this technique means that third parties do not need to install their assemblies in the Mono for Android installation directory. The fact that is works in HKCU means that this can be done without the need for administrator privileges by an installer (although it will only affect the current user).
Comment 3 dean.ellis 2012-11-12 10:51:16 UTC
If you are a third party and you have written a library which would be useful for other developers you will want to provide an easy way for developers to add that library to their applications.
If they are using Visual Studio the normal method to do this is via the Add References dialog, what would be really nice would be if your assemblies could be listed in that dialog without requiring the user to browse for them.

When building the assemblies list Visual Studio scans certain registry keys based on the .Net runtime version of the active project. In the case for Mono for Android it scans the following keys

HKLM\Software\Microsoft\MonoAndroid\v2.2\AssemblyFoldersEx\

and

HKCU\Software\Microsoft\MonoAndroid\v2.2\AssemblyFoldersEx\

Steps to manually add the registry key are.

1) Open regedit.exe
2) Navigate to HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
     Software\Microsoft\MonoAndroid\v2.2\AssemblyFoldersEx\
   You can safely create this key chain if it does not exist.

3) Right click on the AssemblyFoldersEx and click New->Key and type the name of your product or library in the dialog and click ok.
4) Open the new Key and Right click on the (Default) items and click Modify
5) Put the full path to the folder containing your assemblies in the dialog and click ok.

that should be everything you need to do. There is no need to restart Visual Studio clicking Add References should now pick up the new assemblies.

These key values can also be added via installers or scripts.
Comment 4 Jonathan Pryor 2012-11-12 16:49:18 UTC
What is "v2.2" in the above registry key? Is that the $(TargetFrameworkVersion) for the project?

If so, the problem is that this is an unbounded list: there is currently v1.4, v2.1, v2.2, v2.3.3, v3.1, v4.0, v4.0.3, v4.1, and this will only grow (e.g. API 17 will presumably be v4.2). Needing to provide registry keys for every one of those versions will be annoying, and means that things will "break" if/when a new API level comes out.

Is there any form of "version inclusion" supported by the registry keys, so that e.g. HKLM\Software\Microsoft\MonoAndroid\v1.0\AssemblFoldersEx\... is also searched, something akin to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v4.0\RedistList.xml?
Comment 5 dean.ellis 2012-11-13 10:48:55 UTC
The v2.2 is the Minimum Android version that the third party library supports. So if the library supports only 4.0 features the registry key will be 

Software\Microsoft\MonoAndroid\v4.0\AssemblyFoldersEx\

This will mean the assemblies will be unavailable for projects with a "Minimum Android to Target" version below 4.0. If the framework supports all features on all platforms then v1.0 can be used to ensure that the assemblies appear in all projects.
Comment 6 dean.ellis 2012-11-13 11:41:47 UTC
The registry is searched as well so if your application targets v4.0 the Add References dialog will be populated with assemblies matching any key v4.0 or less, so v3.0, v2.2, v2.1 etc will be included. However v4.1 , v4.0.3 would not be included.
Comment 7 PJ 2013-11-19 17:04:34 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 8 PJ 2013-12-05 18:34:40 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.