开发者

Force FSI, the .NET 4 version, to load assamblies that are compiled for .NET 2.0

开发者 https://www.devze.com 2023-02-27 03:26 出处:网络
I\'m working primarily with .NET 4.0 using fsi, F# interactive, but I have a couple of dll tha开发者_运维知识库t I need to access that are only compiled for the .NET 2.0 version of the framework (I ch

I'm working primarily with .NET 4.0 using fsi, F# interactive, but I have a couple of dll tha开发者_运维知识库t I need to access that are only compiled for the .NET 2.0 version of the framework (I checked the manifest they reference mscorlib version 2).

I'm getting a type load exception when I try to use these types. I'm assuming this is because of some .NET 2.0/.NET 4.0 incompatibility when do dynamic type loading etc. The exact error message is:

System.TypeLoadException: Could not load type 'IMyInterface' from assembly 'MyDll, Version=2.3.17.15, Culture=neutral, PublicKeyToken=null'.

The type I’m trying to work with is an interface, I don’t know if this is significant. Using a compiled equivalent of the code works fine.

Is the assumption that this is due to .NET 2.0/.NET 4.0 incompatibility correct? If so is there any way to work round it?


The problem you are facing is because of versioning between .NET 4.0 mscorlib n assemblies with .NET 2.0 FW assemblies. Since the whole set of .NET 4.0 is versioned differently, I don't think you can use .NET 2.0 in that. To test, you can have two class libraries with different versioned (sign them!), and try loading them, It simply won't work because of their dependencies.

You should probably get the .NET 2.0 FW assembly built with .NET 4.0 again, May be suffix the assembly like "4.0"

0

精彩评论

暂无评论...
验证码 换一张
取 消