Error initializing xamarin extensions in VS2012

I have a solution which contains an android project, and iOS project, and some other non-xamarin projects. When I try to open the solution, I receive the following errors: "There was an error attempting to initialize the Mono for Android extension" and "Xamarin.iOS encountered the following error(s): Xamarin.iOS initialization failed."

Below is the detailed error message for the android plug-in; the error message for the iOS plugin is nearly identical, so I haven't included it here.

System.ComponentModel.Composition.CompositionException: The composition produced multiple composition errors, with 3 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.

1) No exports were found that match the constraint: 
    ContractName    Mono.VisualStudio.Extension.Commands.ICommandManager
    RequiredTypeIdentity    Mono.VisualStudio.Extension.Commands.ICommandManager

Resulting in: Cannot set import 'Mono.Android.VisualStudio.MonoAndroidPackage.Commands (ContractName="Mono.VisualStudio.Extension.Commands.ICommandManager")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
Element: Mono.Android.VisualStudio.MonoAndroidPackage.Commands (ContractName="Mono.VisualStudio.Extension.Commands.ICommandManager") -->  Mono.Android.VisualStudio.MonoAndroidPackage

2) No exports were found that match the constraint: 
    ContractName    Mono.VisualStudio.Extension.Events.IShellEvents
    RequiredTypeIdentity    Mono.VisualStudio.Extension.Events.IShellEvents

Resulting in: Cannot set import 'Mono.VisualStudio.Extension.TastyPackage.ShellEvents (ContractName="Mono.VisualStudio.Extension.Events.IShellEvents")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
Element: Mono.VisualStudio.Extension.TastyPackage.ShellEvents (ContractName="Mono.VisualStudio.Extension.Events.IShellEvents") -->  Mono.Android.VisualStudio.MonoAndroidPackage

3) No exports were found that match the constraint: 
    ContractName    Mono.VisualStudio.Extension.Diagnostics.IUserMessageService
    RequiredTypeIdentity    Mono.VisualStudio.Extension.Diagnostics.IUserMessageService

Resulting in: Cannot set import 'Mono.VisualStudio.Extension.TastyPackage.UserMessages (ContractName="Mono.VisualStudio.Extension.Diagnostics.IUserMessageService")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
Element: Mono.VisualStudio.Extension.TastyPackage.UserMessages (ContractName="Mono.VisualStudio.Extension.Diagnostics.IUserMessageService") -->  Mono.Android.VisualStudio.MonoAndroidPackage
   at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
   at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
   at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
   at Mono.VisualStudio.Extension.TastyPackage.Initialize()
   at Mono.Android.VisualStudio.MonoAndroidPackage.Initialize()

Posts

  • ChrisHonselaarChrisHonselaar NLBeta ✭✭✭
    edited May 2013

    what version of Xamarin are you on? Are other Xamarin iOS/Android projects opening correctly? And what actually happens after the error message - does VS crash or are the Xamarin projects simply unloaded? What happens if you open the projects individually?

  • I have the same problem with VS 2010 and Xamarin 4.6.8007. trial version. It happens if I click one button from any button from the Xamarin.Android toolbar in VS without project also.

  • ChrisHonselaarChrisHonselaar NLBeta ✭✭✭

    Please submit a bug report and/or contact the support email address on your account page in case it's urgent.

  • KentPickardKentPickard USMember

    I have the same exact problem. This started happening after I upgraded to the latest version.
    I can open my android project fine in Xamarin studio but I need to check in code via Visual Studio 2013 into TFS.

    Full Version Details from Xamarin Studio:
    Xamarin Studio
    Version 4.2.1 (build 1)
    Installation UUID: 669e5ade-4ad2-424e-a0fa-3857c027b01a
    Runtime:
    Microsoft .NET 4.0.30319.18408
    GTK+ 2.24.20 theme: MS-Windows
    GTK# (2.12.0.0)

    Xamarin.Android
    Version: 4.10.1 (Business Edition)
    Android SDK: C:\Users\Kent\AppData\Local\Android\android-sdk
    Supported Android versions:
    2.1 (API level 7)
    2.2 (API level 8)
    2.3 (API level 10)
    3.1 (API level 12)
    4.0 (API level 14)
    4.0.3 (API level 15)
    4.1 (API level 16)
    4.3 (API level 18)
    Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
    java version "1.6.0_39"
    Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
    Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

    Full Output when trying to open in Visual Studio:

    System.ComponentModel.Composition.CompositionException: The composition produced multiple composition errors, with 3 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.

    1) No exports were found that match the constraint:
    ContractName Mono.VisualStudio.Extension.Commands.ICommandManager
    RequiredTypeIdentity Mono.VisualStudio.Extension.Commands.ICommandManager

    Resulting in: Cannot set import 'Mono.Android.VisualStudio.MonoAndroidPackage.Commands (ContractName="Mono.VisualStudio.Extension.Commands.ICommandManager")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
    Element: Mono.Android.VisualStudio.MonoAndroidPackage.Commands (ContractName="Mono.VisualStudio.Extension.Commands.ICommandManager") --> Mono.Android.VisualStudio.MonoAndroidPackage

    2) No exports were found that match the constraint:
    ContractName Mono.VisualStudio.Extension.Events.IShellEvents
    RequiredTypeIdentity Mono.VisualStudio.Extension.Events.IShellEvents

    Resulting in: Cannot set import 'Mono.VisualStudio.Extension.TastyPackage.ShellEvents (ContractName="Mono.VisualStudio.Extension.Events.IShellEvents")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
    Element: Mono.VisualStudio.Extension.TastyPackage.ShellEvents (ContractName="Mono.VisualStudio.Extension.Events.IShellEvents") --> Mono.Android.VisualStudio.MonoAndroidPackage

    3) No exports were found that match the constraint:
    ContractName Mono.VisualStudio.Extension.Diagnostics.IUserMessageService
    RequiredTypeIdentity Mono.VisualStudio.Extension.Diagnostics.IUserMessageService

    Resulting in: Cannot set import 'Mono.VisualStudio.Extension.TastyPackage.UserMessages (ContractName="Mono.VisualStudio.Extension.Diagnostics.IUserMessageService")' on part 'Mono.Android.VisualStudio.MonoAndroidPackage'.
    Element: Mono.VisualStudio.Extension.TastyPackage.UserMessages (ContractName="Mono.VisualStudio.Extension.Diagnostics.IUserMessageService") --> Mono.Android.VisualStudio.MonoAndroidPackage

    at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition)
    at System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImportsOnce(ComposablePart part)
    at System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce(ComposablePart part)
    at System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(ICompositionService compositionService, Object attributedPart)
    at Mono.VisualStudio.Extension.TastyPackage.Initialize()
    at Mono.Android.VisualStudio.MonoAndroidPackage.Initialize()

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai

    For anyone hitting the "No exports were found that match the constraint: ContractName" error, please try quitting Visual Studio and deleting the ComponentModelCache folder:

    %AppData%\..\Local\Microsoft\VisualStudio\11.0\ComponentModelCache
    %AppData%\..\Local\Microsoft\VisualStudio\12.0\ComponentModelCache

  • wvd_vegtwvd_vegt NLMember ✭✭

    Hi

    Cleared the cache but still have the same problem (tried to de-reinstall only one extension but VS2012 still gives an error like described).

    Using a fully patched Windows 8.1 x64, Visual Studio 2012 and latest Xamarin Adroid.

    regards
    Wim van der Vegt

  • wvd_vegtwvd_vegt NLMember ✭✭

    Hi

    I think I managed to solve the problem by also removing the Xamarin directory from
    %localappdata%\Microsoft\VisualStudio\11.0\Extensions and restart Visual Studio 2012.

    It seemed to contain some old stuff.

    Also during a complete re-install Xamarin Studio wanted me to re-install it's old 32bit Java 1.6 jdk once more.

    regards
    Wim van der Vegt

  • I have the same problem with my Visual Studio 2013 install. Interestingly VS2012 on the same machine does work. Deleting the ComponentModelCache doesn't seem to help.

    Any more ideas?

    Mark Daniel.

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited December 2013

    For anyone still seeing an error dialog that says:

    The 'ShellPackage' package did not load correctly.

    ... or an ActivityLog.xml that says:

    SetSite failed for package [ShellPackage]... The composition produced multiple composition errors, with 3 root causes... "No exports were found that match the constraint"

    First check if the Visual Studio Xamarin Extensions folder contains a Shell folder, and whether the contents of the Shell folder are complete (see attached screenshot for comparison). If the folder is incomplete, delete it. Then create a new, complete Shell folder by reinstalling (or repairing) either of the Xamarin VS extensions. Both extensions contain a copy of the Shell, so either will work.

    If the Shell folder looks alright, next open regedit, and look for a registry value named "Mono.VisualStudio.Shell,1.0" under the following registry key:

    Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\ExtensionManager\PendingDeletions

    If this registry value is present, delete it. Then run the following command from a command prompt with administrative privileges:

    "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /setup /nosetupvstemplates

    This registry problem will happen if you have removed the Xamarin Shell extension via the "Tools -> Extensions and Updates" menu in Visual Studio. Uninstalling this way creates the ill-behaving "Mono.VisualStudio.Shell,1.0" registry value.

  • DanWatersDanWaters USMember

    Brendan,
    The registry fix restored everything for me, thanks so much for that.

    I uninstalled Xamarin extensions via the VS IDE, so that's what caused it. won't be doing that again!

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited January 2014

    Glad that worked for you!

    Just to add a little update to this thread: a fix for the "Extensions and Updates" problem has been written, but not yet released. Once the fix is released, the Xamarin extensions will no longer (incorrectly) allow uninstalling via the "Extensions and Updates" menu.

  • DanielSchroederDanielSchroeder CAMember ✭✭

    I was having the same problem and just downloaded and installed the newest "Xamarin for Windows" and it seems to have fixed it up for me.

  • Strange_VStrange_V UAMember

    Hi guys.

    Looks like I have exactly the same problem. I tried all fixes which posted above, but still have the same error.

    I got the exception even I try to open Tools -> Options -> Xamarin
    There was an error attempting to initialize the Mono for Android extension.

    System.MethodAccessException: Attempt by method 'Mono.Android.VisualStudio.MonoAndroidPackage.get_Settings()' to access method 'Microsoft.VisualStudio.Shell.Package.GetDialogPage(System.Type)' failed.
    at Mono.Android.VisualStudio.MonoAndroidPackage.get_Settings()
    at Mono.Android.VisualStudio.MonoAndroidPackage.SetupLogging()
    at Mono.Android.VisualStudio.MonoAndroidPackage.Initialize()

    I use Visual Studio 2012 and latest xamarin.

    Could you help me to solve this trouble?

  • mikekmikek DEMember

    Hi, I got the same error in the activity log ... "SetSite failed for package [ShellPackage] ..."
    It is a fresh Visual Studio 2013 Ultimate Update 4 installation and after running the Xamarin installer I got the error message while starting the ide. I tried a "repair" on the Visual Studio. It took hours but didn't fix the problem.

    If I look in this info on github: https://gist.github.com/brendanzagaeski/7953966 there should be an "SHELL" folder? There isn't any shell folder in the Extensions/Xamarin .. structure. I found only this:
    C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Xamarin\Xamarin\3.11.446.0

    It's not very funny - next monday I'll have a xamarin training and need a functional installation :( ...

  • mikekmikek DEMember

    It seems that the reason for the "SetSite failed for package [ShellPackage]" was an installation with an admin user account ...

    Our company policies deny admin rights for normal user accounts. Therefore I installed the Xamarin setup with the "run as admin" option. If I started Visual Studio also with the "run as admin" option with the same user account which was used for the installation it worked (after one start with the /setup commandline parameter). If I give admin rights to my normal user account and start Visual Studio, the error is still there! I resolved the problem by deinstalling Xamarin and reinstalling it again with my normal user account with admin rights.

    While reinstalling the android sdk installer asks for a path - and the old path was in the AppData/Local folder of the admin user account!?!?!

    Why do you install parts of the Xamarin package in an user specific path??? Then it's clear, why Visual Studio could not load assemblies, if I use a different user account for normal work.

  • Sreekanth_BantuSreekanth_Bantu USMember ✭✭

    **mikek **your explanation helped me a lot, i logged in as another domain user other than the user getting exception and installed it worked like a charm. Thank you so much.

  • Siavash_NabavizadehSiavash_Nabavizadeh CAMember ✭✭
    edited July 2016

    BrendanZagaeski
    Your comment was helpful but as I found the same problem here, the installer msi file provided by Xamarin helped me to solve the problem automatically.

Sign In or Register to comment.