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

Referencing .NETStandard,Version1.3 NuGet library depending on System.ComponentModel.TypeConverter from .NET 4.7 #877

Closed
RedwoodForest opened this issue Aug 21, 2017 · 5 comments

Comments

@RedwoodForest
Copy link

When I reference the NuGet package SharpSnmpLib version 9.2.2 from a .NET 4.7 app it fails during execution with:

2017.08.21 10:05:35.217   ERROR System.IO.FileLoadException: Could not load file or assembly 'System.ComponentModel.TypeConverter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

It seems like this may have something to do with to the .NETStandard,Version1.3 dependency on the System.ComponentModel.TypeConverter NuGet package.

This seems like it could be related to #730 but I'm not sure.

One workaround I found based on a suggestion from @weshaggard in #730 is to manually add NuGet references to System.ComponentModel.TypeConverter and System.Runtime.Serialization.Primitives. This seems problematic though because these types are already included in the full .NET 4.7 framework so it doesn't seem correct to add a separate reference to a different version of them. Also it seems like if these references are necessary they should be automatically added by NuGet.

What's the expected behavior here?

Steps to reproduce:

  1. Create a .NET Framework Console App referencing version 4.7.

  2. Add a NuGet reference to Lextm.SharpSnmpLib version 9.2.2.

  3. Add this code in Main():

     static void Main() {
         Console.Out.WriteLine(typeof(ObjectIdentifier).GetCustomAttributes(typeof(Attribute)));
         Console.ReadLine();
     }
    
  4. Run the Console Application.

We originally ran into this issue using the Machine.Specifications test runner to run tests in a project that references SharpSnmp lib. It looks like the test runner uses GetCustomAttributes to find test attributes.

@weshaggard
Copy link
Member

I suspect you might be hitting dotnet/sdk#901. Can you try the workarounds listed in that issue?

@RedwoodForest
Copy link
Author

@weshaggard

Thanks for your help.

I just tried the workarounds (<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
and
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> and re-adding the nuget reference) and I'm still getting the same issue.

I've uploaded my test project to make it easy to see what's going on.

@RedwoodForest
Copy link
Author

Is anybody able to take a look at this? It's preventing us from upgrading to netstandard-based libraries.

CC @weshaggard

@weshaggard
Copy link
Member

@lawrencejohnston I took a look at your sample project and figured out what is happening. You aren't consuming a ProjectReference like I first thought you are consuming a PackageReference to Lextm.SharpSnmpLib which doesn't correctly identify its full dependency set.

You can work around this but opt-ing in to netstandard in your project by setting <DependsOnNETStandard>true</DependsOnNETStandard> which should get you all the missing dependencies you have.

Please give that a try and let me know if it works for you.

@RedwoodForest
Copy link
Author

@weshaggard thanks for looking into this. We will open an issue with SharpSnmpLib to fix their dependency declarations. Also thanks for the workaround, I've confirmed it fixes the issue in our test project.

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

2 participants