Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembly loading exception when using DependencyInjection library #19

Open
rezanid opened this issue Sep 10, 2024 · 1 comment
Open

Comments

@rezanid
Copy link
Contributor

rezanid commented Sep 10, 2024

After I converting my package to use dependency injection, I get assembly load exceptions. I checked the public key of the libraries and all of them are correct. The files are physically in the same folder as the main assembly. I even tried signing my assemblies and all the open source assemblies and still have the same problem. Here is a log from ActivityLog.xml that shows that Community.VisualStudio.Toolkit.DependencyInjection.Core assembly is not able to load the main Community.VisualStudio.Toolkit assembly.

  <entry>
    <record>2026</record>
    <time>2024/09/10 16:22:40.491</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>CreateInstance failed for package [XrmGenPackage]Source: &apos;mscorlib&apos; Description: Could not load file or assembly &apos;Community.VisualStudio.Toolkit, Version=17.0.482.0, Culture=neutral, PublicKeyToken=79441d341a79572c&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;System.IO.FileNotFoundException: Could not load file or assembly &apos;Community.VisualStudio.Toolkit, Version=17.0.482.0, Culture=neutral, PublicKeyToken=79441d341a79572c&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;File name: &apos;Community.VisualStudio.Toolkit, Version=17.0.482.0, Culture=neutral, PublicKeyToken=79441d341a79572c&apos;&#x000D;&#x000A;   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)&#x000D;&#x000A;   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)&#x000D;&#x000A;   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)&#x000D;&#x000A;   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)&#x000D;&#x000A;&#x000D;&#x000A;=== Pre-bind state information ===&#x000D;&#x000A;LOG: DisplayName = Community.VisualStudio.Toolkit, Version=17.0.482.0, Culture=neutral, PublicKeyToken=79441d341a79572c&#x000A; (Fully-specified)&#x000D;&#x000A;LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/&#x000D;&#x000A;LOG: Initial PrivatePath = NULL&#x000D;&#x000A;Calling assembly : Community.VisualStudio.Toolkit.DependencyInjection.Core, Version=17.0.20.0, Culture=neutral, PublicKeyToken=79441d341a79572c.&#x000D;&#x000A;===&#x000D;&#x000A;LOG: This bind starts in LoadFrom load context.&#x000D;&#x000A;WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().&#x000D;&#x000A;LOG: Using application configuration file: C:\Users\G99202\AppData\Local\Microsoft\VisualStudio\17.0_353ed674Exp\devenv.exe.config&#x000D;&#x000A;LOG: Using host configuration file: &#x000D;&#x000A;LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.&#x000D;&#x000A;LOG: Post-policy reference: Community.VisualStudio.Toolkit, Version=17.0.482.0, Culture=neutral, PublicKeyToken=79441d341a79572c&#x000D;&#x000A;LOG: The same bind was seen before, and was failed with hr = 0x80070002.&#x000D;&#x000A;</description>
    <guid>{9D0B1940-11E7-41CC-A95A-AD5A6ED3C73B}</guid>
    <hr>0x80004005 - E_FAIL</hr>
    <errorinfo></errorinfo>
  </entry>
@rezanid
Copy link
Contributor Author

rezanid commented Sep 10, 2024

Looking more carefully I noticed that Community.VisualStudio.Toolkit.DependencyInjection.Core is looking for an older version of the required assembly. To fix this I will need to download and recompile the dependent assembly. Is there any better way to fix this issue, given that I'm in the context of a Vsix?

@rezanid rezanid closed this as completed Sep 10, 2024
@rezanid rezanid reopened this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant