Thursday, September 20, 2012

Refer to .net assemblies from vc9/.net 3.5 apps

Our partner gave us some components built with .net 4.0, and our hosting application is mixed application based on 3.5, when trying to refer to them, the compiler complains with errors. Finally figure out how to make it work.

After inserting the reference, unload the project, manually adding the

   1: <ProjectReference Include="XXXX.csproj">
   2:       <Project>{2897acf2-f168-4c4b-8a4e-b1dedd8733fc}</Project>
   3:       <SpecificVersion>true</SpecificVersion>
   4: </ProjectReference>

<SpecificVersion> node also applies to the assembly reference.


Then force the app to load .net 4.0 during the runtime:


 



   1: <startup useLegacyV2RuntimeActivationPolicy="true">
   2:     <supportedRuntime version="v4.0"/>
   3: </startup>

If using visual studio 2010 to build vc9/3.5 c++ apps, change the target to vc9,


then manually change the target framework to 3.5:



   1: <PropertyGroup Label="Globals">
   2:     <ProjectGuid>{0D090EBF-7467-4DA5-8AE4-E6A52335F0AA}</ProjectGuid>
   3:     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
   4:     <Keyword>ManagedCProj</Keyword>
   5:     <RootNamespace>xxxx</RootNamespace>
   6: </PropertyGroup>

No comments:

Post a Comment