about c++/cli dll in vs2k10 beta1
-
Thursday, June 18, 2009 4:06 PMI'v writtern a c++/cli dll, and use c# console ap to call it..
It work fine in vs2k8,
but in vs2k10, the c# app got an exception "BadImageFormatException" ...
If use c# ap by vs2k10, and c++/cli dll by vs2k8, work fine too!
Is there something to be cared?
Thanks ...
All Replies
-
Thursday, June 18, 2009 6:30 PMWhat is your target runtime?.Net 4.0 has a separate runtime.
MSMVP VC++ -
Thursday, June 18, 2009 10:40 PMI'm using .net 2.0 in vs2k8,
when converting to vs2k10 project files, set option not upgrade to .net 4.0,
but I found in c++/cli's project property pages, the Targeted Framework is ".NET Framework 4.0", and grayed (cannot be changed).
In VS2K10 beta1, c++/cli can not set different version's targeted framwrok?
I'v got warning message when building..
"
1>C:\Windows\Microsoft.NET\Framework\v4.0.20506\Microsoft.Common.targets(1337,9): warning MSB3258: The primary reference "OrisQ_CLI, Version=1.0.2896.17747, Culture=neutral, processorArchitecture=x86" has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than exists in the current target framework. The version found in the current target framework redist list is "2.0.0.0". By including the primary reference you may get compile and/or runtime errors.
1>C:\Windows\Microsoft.NET\Framework\v4.0.20506\Microsoft.Common.targets(1337,9): warning MSB3258: The primary reference "OrisQ_CLI, Version=1.0.2896.17747, Culture=neutral, processorArchitecture=x86" has an indirect dependency on the .NET Framework assembly "Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "10.0.0.0" than exists in the current target framework. The version found in the current target framework redist list is "8.0.0.0". By including the primary reference you may get compile and/or runtime errors.
1>C:\Windows\Microsoft.NET\Framework\v4.0.20506\Microsoft.Common.targets(1337,9): warning MSB3258: The primary reference "OrisQ_CLI, Version=1.0.2896.17747, Culture=neutral, processorArchitecture=x86" has an indirect dependency on the .NET Framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than exists in the current target framework. The version found in the current target framework redist list is "2.0.0.0". By including the primary reference you may get compile and/or runtime errors.
"
I'v removed these 3 refernce (mscorlib,Microsoft.VisualC,System), and readd 4.0.0.0 version, but still got these warning....
(vs2k10 run on Windows 7 RC x64 platform...)
Thanks. -
Friday, November 20, 2009 6:51 PM
it looks like you issue is caused by mixed framework version in your applications. After upgrade, your C# application remains at the old framework version while you c++ application has been upgraded to 4.0.
After conversion to Dev10, the TargetFrameworkVersion for managed C++ application is 4.0 by default. We made this decision due to a limitation of CL compiler, as Dev10 Cl compiler cannot targeting framework 2.0, 3.0, 3.5, while Orcas Cl compiler can only targeting framework 2.0, 3.0, 3.5. C# application will keep its original framework version after conversion, although in the case where 2.0, 3.0, 3.5 framework is absent on the machine, you will be prompt to upgrade to 4.0 version.Due to resource constrain, retargeting for C++ application in the IDE is a feature we do not support. You can workaround the issue by doing one of the following:
1. Edit the vcxproj file and in the first property group define add the following:
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
2. Open VS2010 commandline, set TargetFrameworkVersion=v3.5, and then start devenv from the commandline. This will target all your projects to target v3.5 framework.
Li Shao, MSFT
Li Shao -
Monday, August 16, 2010 12:27 AM
it looks like you issue is caused by mixed framework version in your applications. After upgrade, your C# application remains at the old framework version while you c++ application has been upgraded to 4.0.
After conversion to Dev10, the TargetFrameworkVersion for managed C++ application is 4.0 by default. We made this decision due to a limitation of CL compiler, as Dev10 Cl compiler cannot targeting framework 2.0, 3.0, 3.5, while Orcas Cl compiler can only targeting framework 2.0, 3.0, 3.5. C# application will keep its original framework version after conversion, although in the case where 2.0, 3.0, 3.5 framework is absent on the machine, you will be prompt to upgrade to 4.0 version.Due to resource constrain, retargeting for C++ application in the IDE is a feature we do not support. You can workaround the issue by doing one of the following:
1. Edit the vcxproj file and in the first property group define add the following:
<TARGETFRAMEWORKVERSION>v3.5</TARGETFRAMEWORKVERSION>
2. Open VS2010 commandline, set TargetFrameworkVersion=v3.5, and then start devenv from the commandline. This will target all your projects to target v3.5 framework.
Li Shao, MSFT
Li Shao
I've learned a lot, I'm still studying it.

