开发者

Can you use a .NET 4.0 dll in a 3.5 project?

Can you use a .NET 4.0开发者_如何学JAVA dll in a 3.5 project?


Nope. You can use a .Net 3.5 assembly in a 4.0 project, but not the other way around.


No you can't. An assembly compiled against .NET 4.0 can be loaded only by the CLR 4.0. On the other hand the CLR 4.0 can load assemblies compiled against .NET 3.5.


https://code.msdn.microsoft.com/Using-a-NET-4-Based-DLL-bb141db3/

Use our .NET 4 DLL via COM

using System; 
using Net4ToNet2Adapter; 

namespace Net2Assembly 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            Console.WriteLine("CLR version from EXE: {0}", Environment.Version); 
            Type myClassAdapterType = Type.GetTypeFromProgID("Net4ToNet2Adapter.MyClassAdapter"); 
            object myClassAdapterInstance = Activator.CreateInstance(myClassAdapterType); 
            IMyClassAdapter myClassAdapter = (IMyClassAdapter)myClassAdapterInstance; 
            myClassAdapter.DoNet4Action(); 
        } 
    } 

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜