2

Possible Duplicate:
Change C++/CLI project to another framework than 4.0 with vs2010

I wrote a hello world app in C++/CLI and i compiled (with safe clr) and ran it under windows. No problem. I ran it under linux and i got this error

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v1.1.4322

How do I compile C++/CLI so it will work for either .NET run time 2/3.5 or .NET 4? -edit- I found this answer why says mono 2.6 falls back (or reports?) version 1 when it comes across .NET 4 runtimes. Ok, so now i know this is a .NET 4 runtime but how do i compile it as .NET 2 or 3.5? I rather deal with .NET 4 than 1 so good :). But my server isnt setup for that ATM (monos VM image is tho which i am testing now with success)

Community
  • 1
  • 1
  • Does your runtime on Linux support any other framework than 1.1 which seems to be the default? – Joachim Isaksson Jan 14 '12 at 08:40
  • @JoachimIsaksson: I am using mono 2.6.7 which supports .NET 2-3.5. I don't believe v4 (which i think 2.8 supports) nor lower (which is why i get the error) –  Jan 14 '12 at 08:42
  • If it's possible to compile your program for 3.5, it should run on both Windows and Mono (barring any bugs or unimplemented features) What would be the reason to use 4.0? (I know there are advantages, just asking your side of it for this case) – Joachim Isaksson Jan 14 '12 at 08:51
  • @Joachim: 4 is the default. I have no idea how to change it (thus this question). I actually dont mine 4 but i still like the option of 2 using CLI C++ if possible –  Jan 14 '12 at 09:03
  • Are you using Visual Studio or mono to compile? – Joachim Isaksson Jan 14 '12 at 09:11
  • @JoachimIsaksson: VS, ATM i have no idea how to compile C++ CLR. This is the first time i done it in C++ as well. ATM i am toying around with it. –  Jan 14 '12 at 09:15

1 Answers1

1

The VC++ 2010 compiler only generates .NET 4.0 assemblies.

The VC++ 2008 compiler only generates .NET 2.0-3.5 assemblies.

If you have VC++ 2008 installed, you can instruct Visual Studio 2010 to use the VC++ 2008 compiler which will create a .NET 2.0-3.5 assembly. Simply change the "Platform Toolset" setting under project properties to "v90".

enter image description here

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • I know it is old post- I have a similar issue. Will the C++/CLI assembly compiled with toolset/compiler of vs 2008 compatible with my pure .Net assemblies that are compiled in VS-2010 - IE my main .Net assembly built using VS2010 would use this C++/CLI assembly built using VS2008, all assemblies targeting .Net 2.0 and same architecture ?? – Ahmed Aug 20 '16 at 20:51
  • @Ahmed .NET 2/3 assemblies, including C++/CLI ones, should generally load and successfully run inside a process using the .NET 4 CLR. – Ben Voigt Aug 20 '16 at 21:51
  • My main assembly is also targeted for .Net 2.0 not 4.0. The only thing is it will be compiled with VS2010 but C++/CLI will be compiled with VS2008 – Ahmed Aug 20 '16 at 21:56
  • That should not cause any problems. – Ben Voigt Aug 20 '16 at 22:00