4

I have 2 separate projects, lets call them Alpha and Bravo.

Project Alpha targets only the net462 framework in its project.json file, while project Bravo targets only netstandard1.5. Those 2 frameworks are compatible according to Microsoft.

Project Alpha references project Bravo's assembly. In particular, Alpha needs to implement an interface defined in Bravo. Let's call this interface IProblematic. This interface deals mostly with headers stuff, and defines methods like this

bool DoStuff(List<KeyValuePair<string, IEnumerable<string>>> requestHeaders, List<string> rolesList)

Project Alpha declares a class that implements that interface.

public bool DoStuff(List<KeyValuePair<string, IEnumerable<string>>> requestHeaders, List<string> rolesList)  {... }

So far so good. But during runtime I get plagued by errors such as Unable to load one or more of the requested types. I believe the source of the errors comes from the Collection types.

Using Visual Studio's "go to definition" feature, I can see that project Alpha (the 462 project) is using System.Collections.Generic defined in ..\Framework\v4.0.30319\mscorlib.dll, while if I do the same in project Bravo's collections, it shows me that it is using System.Collections.Generic, defined in ..\netstandard1.3\System.Collections.dll.

Thus, my question is, how can I get project Alpha to use the correct Collections assembly when implementing the netstandard1.5 interface, as opposed to using mscorlib's collections? Shouldn't this even be a non-issue, given that the 2 frameworks are compatible?

Thank you all in advance!

Athari
  • 33,702
  • 16
  • 105
  • 146
  • 4
    Can you show us some minimal sample code? Also providing the full error messages would be helpful. – NineBerry Nov 21 '16 at 23:55
  • If you haven't already, try to reproduce the problem in a new solution with only 2 assemblies that target net462 and netstandard1.5 and absolutely minimal code, without the collection types in the interface. This can help prove or falsify if it is really the collections that cause problem. – Botond Balázs Nov 22 '16 at 00:05
  • I have tested this and cannot reproduce this issue. Please provide a [mcve](http://stackoverflow.com/help/mcve) I get the same information from the IDE about using different List classes from different assemblies, but it works nonetheless. – NineBerry Nov 22 '16 at 00:32
  • 1
    I have just created a minimal project and I too can't reproduce. It seems that I am doing something else that is causing the problem. I will have to look into it for some more time. At least I know that my original suspicion was not correct. Thanks for the help so far... – dan_rozenberg Nov 22 '16 at 00:51
  • 1
    As mentioned above, a full-er error message might make it easier to point out the problem. – Eric Mellino Nov 22 '16 at 00:51
  • The name `Alpha and Bravo` makes me crazy, can't you just use `A & B`? – Lei Yang Nov 22 '16 at 01:27

1 Answers1

0

After some investigation I have found out that the problem is happening because my net462 app is (indirectly) depending on System.Collections.Immutable: "1.3.0 and my netstandard1.5 library has a dependency on "NETStandard.Library": "1.6.0". I will create a more focused thread with more code and stack traces on it. I apologize for the delay in getting back.

  • Here is the more focused (with code and stack trace) SO thread: http://stackoverflow.com/questions/40856177/could-not-load-file-or-assembly-error-when-net462-app-references-a-netstandard – dan_rozenberg Nov 29 '16 at 01:10
  • I got a very similar problem here: http://stackoverflow.com/questions/41535341/using-net-standard-1-5-lib-in-net-4-6-2-misses-system-runtime-4-1-0-0 any hint ? – Boas Enkler Jan 09 '17 at 13:24