Closed icnocop closed 1 month ago
I was able to resolve the issue by calling
services.RegisterCommands(ServiceLifetime.Singleton, Assembly.GetExecutingAssembly());
Instead of this:
services.RegisterCommands(ServiceLifetime.Singleton);
I think the cause is described in this blog post: https://ticklishtechs.net/2010/03/04/be-careful-when-using-getcallingassembly-and-always-use-the-release-build-for-testing/index.html
If the method that calls the GetCallingAssembly method is expanded inline by the compiler (that is, if the compiler inserts the function body into the emitted Microsoft intermediate language (MSIL), rather than emitting a function call), then the assembly returned by the GetCallingAssembly method is the assembly containing the inline code. This might be different from the assembly that contains the original method. To ensure that a method that calls the GetCallingAssembly method is not inlined by the compiler, you can apply the MethodImplAttribute attribute with MethodImplOptions.NoInlining.
Hi.
Thank you for Community.VisualStudio.Toolkit.DependencyInjection.
I created a VSIX extension for Visual Studio 2022 with a command which uses DI and it works in a Visual Studio Experimental Instance when debugging the extension.
However, when I install it from the marketplace and try to use it, the following warning dialog appears:
The following entry appears in ActivityLog.xml:
I registered my commands using
services.RegisterCommands(ServiceLifetime.Singleton);
.Steps to reproduce:
Migrate packages.config to PackagesReferences...
When I open MigratePackagesConfigToPackageReferences.sln and debug the extension, the error does not occur.
Any advice?
Thank you.