locked
DSL: How to troubleshoot "AdapterManagerNotRegisteredException DSL5030: An AdapterManager supporting LogicalAdapterId ... could not be found"? RRS feed

  • Question

  • Dear, I have an extension containing 4 different DSL's which I created a first version of back in VS2012. I've upgraded the extension each time a new VS version came out and now it's in VS2017. At first it was working but now I've done some more work on it and I get an "AdapterManagerNotRegisteredException" when making use of the ModelBus to create an adapter of another DSL in the extension:

    Running transformation: Microsoft.VisualStudio.Modeling.Integration.AdapterManagerNotRegisteredException: DSL5030: An AdapterManager supporting LogicalAdapterId ... could not be found.   at Microsoft.VisualStudio.Modeling.Integration.ModelBus.CreateAdapter(ModelBusReference reference, IServiceProvider serviceProvider)   at Microsoft.VisualStudio.Modeling.Integration.ModelBus.CreateAdapter(ModelBusReference reference)   at Microsoft.VisualStudio.TextTemplating1974C3A82A455614538A9633AB47D111513E01046BD903929F99C1D2FCAA92F369134967B6067F993F2BE2DB0ADDE871D5B11D0D515B3BEDD6968F52950A4DB1.GeneratedTextTransformation.TransformText()


    This error is thrown in the template performing the transformation with the following code:

    var model = ModelBus.CreateAdapter(Model.OtherModelRef);

    When debugging there are 0 AdapterManagers registered in the ModelBus, though I would expect at least one to be registered as it was implemented (long time ago) as follows https://docs.microsoft.com/en-us/visualstudio/modeling/using-visual-studio-modelbus-in-a-text-template?view=vs-2017

    I'm trying to figure out why now the AdapterManager is no longer being registered - the rest of my DSL designers are working and the AppDomain loaded assemblies show that the assembly containing the AdapterManager I need are there. Any idea how I can troubleshoot this best?

    Kind regards,

    Roel

    Thursday, December 13, 2018 2:10 PM

All replies

  • Apparently when debugging I notice that the MEF CompositionContainer does not contain any of the types that actually contain AdapterManager exports. This seems highly unusual? When I simulate the same composition in a unit test I get my adapter manager properly instantiated when calling the "FindAdapterManager" method?!

    The following code simulates the failing behavior, not containing the actual types that have the required exports, only containing the "Microsoft.VisualStudio.TextTemplating.VSHost.15.0.DLL" assembly:

                using (var catalog = new AssemblyCatalog(@"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TextTemplating.VSHost.15.0.DLL"))
                {
                    var compositionConfigurationManager = new CompositionConfigurationManager(new CompositionContainer(catalog), "T4VSHost");
    
                    var adapterManager = compositionConfigurationManager
                        .FindAdapterManager("...DslAdapter");
    
                    Assert.IsNotNull(adapterManager); // Fails, adapterManager == null !
                }

    The following code simulates the success behavior, which is not happening right now (the above failing situation is):

    using (var catalog = new AssemblyCatalog(Assembly.Load("...ModelBusAdaptersForTextTemplating"))) { var compositionConfigurationManager = new CompositionConfigurationManager(new CompositionContainer(catalog), "T4VSHost"); var adapterManager = compositionConfigurationManager .FindAdapterManager("...DslAdapter");

    Assert.IsNotNull(adapterManager); // Success, adapterManager != null ! }


    Any idea why the CompositionContainer is initialized with the wrong assembly in the assembly-catalog?

    Kind regards,

    Roel

    Saturday, December 15, 2018 9:44 PM
  • Hi Roel,

    I am great that you have resolved this issue and thanks for sharing your solution here, you could accept it as an answer. This can be beneficial to other community members reading this thread and we could close this thread. Thanks.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 7, 2019 3:16 AM
  • Hi Leo,

    Just for clarification, I have not yet been able to resolve the issue. I have been able to determine that this behavior is present in version 15.9.x of VS2017 and NOT in version 15.7.x (I haven't tried 15.8.x yet). Currently I'm continuing my development in version 15.7.x which unblocks me. I have yet to debug/compare the behavior between both versions to see where the difference is in what is loaded in the CompositionContainer. By no means is my second post a solution for the issue.

    Regards,

    Roel

    Monday, January 7, 2019 7:24 AM