Skip to content

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

Closed
@RedwoodForest

Description

@RedwoodForest

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions