none
vs2010 compilation to target the compiling against a older .net framework RRS feed

  • Question

  • Hi,

    I have a set of code that has been compiled as a mixed mode dll, and we use the /clr flag . This is compiled against .net framework 3.5 earlier as our requirement is mainly ver 2 and some parts of ver 3.5. Now we moved to vs2010 and it defaults to ver 4. i dont have a project for the same and we have our own build methods but we do build it using cl option. 

    Now when the module is built with .net 4 framework , it doesnt run on an env that doesnt hv a .net 4 framework installed though it has ver 3.5, which can be a obvious way of working as it was compiled in a later version. If so is there a way to compile this mode against .net 3.5 with vs 2010 compiler. i did see that if we have a vcxproj or if we use msbuild we can target the required frame work either by setting the env variable or in the project properties to change the target version or to change the vcxproj xml file. 

    Is there a option or a flag in addition to or as a replacement of /clr that i can use to specify that particular module to be compiled against ver 3.5. so that i can run that on a machine that has only .net 3.5 and not .net 4 ver.

    If this is not the right forum for this question please can some one point out the correct forum for this to be posted? 

    Thanks in advance

    kamalesh.


    kamalesh

    • Moved by Helen Zhao Thursday, February 9, 2012 2:15 AM (From:Visual C++ General)
    Tuesday, February 7, 2012 11:03 AM

Answers

  • VC2010 doesn't allow managed multi targetting. That means that if you compile with the VC2010 compiler then it will target .NET 4 always.

    The best you can hope for is set the supportedRuntime attribute in the application configuration and then test.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Proposed as answer by Helen Zhao Wednesday, February 8, 2012 9:42 AM
    • Marked as answer by Paul Zhou Thursday, February 16, 2012 8:15 AM
    Tuesday, February 7, 2012 2:24 PM
  • Hi Kamalesh,

    Crescens2k has provide a solution that if the application is build with .NET 4.0 and the application references some assemblies that build with .NET 3.5/2.0.

    You can read the document("application_compatibility_and_deployment" section):

    http://msdn.microsoft.com/en-us/library/ms171868.aspx#application_compatibility_and_deployment

    Moreover, why you can not build your project with .NET 3.5 in VS2010? Just choose the target Framework version of .NET 3.5: Open properties of the project->Application tag->Target Framework, choose .NET Framework 3.5. Then build the project. I think it is simple.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Paul Zhou Thursday, February 16, 2012 8:15 AM
    Monday, February 13, 2012 8:50 AM

All replies

  • VC2010 doesn't allow managed multi targetting. That means that if you compile with the VC2010 compiler then it will target .NET 4 always.

    The best you can hope for is set the supportedRuntime attribute in the application configuration and then test.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Proposed as answer by Helen Zhao Wednesday, February 8, 2012 9:42 AM
    • Marked as answer by Paul Zhou Thursday, February 16, 2012 8:15 AM
    Tuesday, February 7, 2012 2:24 PM
  • Hi kamalesh,

    Thanks for your post in the MSDN Forum.

    After doing some research, I think you can follow his advice to fix the issue. What's more, I'd like to move this thread to "Common Language Runtime Forum" for better support, where more experts live. It is because that we discuss general questions about Visual C++ in Visual C++ General Forum.

    Thanks again for your understanding.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, February 9, 2012 2:13 AM
  • hi,

    Thanks a lot for the resp. hmm, sure will give it a try and hope it resolves.  

    hi all, any other suggestions for the same. is there any command line params or setting additional to the config file that could help me resolve the sceneario?

    Thanks again,

    kamalesh.


    kamalesh

    Thursday, February 9, 2012 10:33 AM
  • Hi Kamalesh,

    Crescens2k has provide a solution that if the application is build with .NET 4.0 and the application references some assemblies that build with .NET 3.5/2.0.

    You can read the document("application_compatibility_and_deployment" section):

    http://msdn.microsoft.com/en-us/library/ms171868.aspx#application_compatibility_and_deployment

    Moreover, why you can not build your project with .NET 3.5 in VS2010? Just choose the target Framework version of .NET 3.5: Open properties of the project->Application tag->Target Framework, choose .NET Framework 3.5. Then build the project. I think it is simple.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Paul Zhou Thursday, February 16, 2012 8:15 AM
    Monday, February 13, 2012 8:50 AM
  • hi paul, 

    thanks for the resp. As i mentioned in my first post, our application is not done as a vcxproject or a sln. So i am not sure how we target it. We also dont use MSBuild in which case we can set the traget frameworkversion from cmd line. Which is why i was asking if there is a way to do it with these two possibilities ruled out. Plus, my question was mainly on compiling in a machine that has .net 4.0 and running on a machine which doenst have 4.0

    And i had seen the link you had posted already and i am still trying to find a way how to specify the supported version during compile time with the above said limitations.

    Thanks

    kamalesh.


    kamalesh

    Thursday, February 16, 2012 11:15 AM