0

I have find many ways to make c# can use c++ dll.I used clr c++ to wrap the native c++ dll . But I need to use in c# with .net 3.5,it has the trouble

because it does the .NET Framework assembly "mscorlib, Version = 4.0.0.0, Culture = Neutral, PublicKeyToken = b77a5c561934e089 "has an indirect dependency, and the version of the assembly is" 4.0.0.0 ", higher than the version" 2.0.0.0 "in the current target framework

. The c++ dll is bulit in .net2.0 and clr dll also in .net2.0. How to resolve the problem? Thank you!

Mix
  • 103
  • 1
  • 9
  • One of the assemblies you are referencing is in .NET 4.0 OR one of your projects is in .NET 4.0... Find which one is. If you open your dll/exe with ILSpy you should be able to see each one which .NET is targetting. – xanatos Mar 30 '17 at 06:20
  • @xanatos By the ILSpy, th clr c++ dll has `mscorlib` , is Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 . Others are Version=2.0.0.0. – Mix Mar 30 '17 at 06:44
  • There is a bug... It could be you are affected: https://connect.microsoft.com/VisualStudio/feedback/details/780602/compiling-c-clr-dll-in-vs-2012-targeting-net-2-0-introduces-indirect-dependency-on-net-4-0#tabs What Visual Studio are you using? – xanatos Mar 30 '17 at 06:48
  • Probably a duplicate of this question: http://stackoverflow.com/a/2921868/613130 (where Hans repeats that you need older versions of Visual Studio installed to do it) – xanatos Mar 30 '17 at 06:53
  • @vs2015with update 3. I also bulit in .net3.5. The problem are still existing. – Mix Mar 30 '17 at 07:01
  • I'll say that they left the bug "as is" after VS 2012 :-( – xanatos Mar 30 '17 at 07:02
  • 1
    Thank you very much! I know what need to do. Because I work with unity in .net 3.5. I will install vs2010 – Mix Mar 30 '17 at 07:11
  • Then I'll close this as a duplicate – xanatos Mar 30 '17 at 07:11
  • 1
    I had a try. I find I need vs2008. And .NET Framework Versions and Dependencies: https://msdn.microsoft.com/en-us/library/bb822049.aspx – Mix Mar 30 '17 at 10:01
  • Yes :-) When you said "I will install vs2010" I had a suspect it was the wrong version... (because Hans Passant wrote explicitly: *For example, if you specify v3.5, which represents the .NET Framework v3.5, Visual Studio 2008 SP1 must be installed.*) – xanatos Mar 30 '17 at 10:02

0 Answers0