none
VS 2010 and managed C++ 2.0

    Question

  • When you want to compile a managed C++ with Visual Studio 2010 for 2.0 .Net Framework you must use Toolset V90.

    Are there any palns to lift this restriction in SP1 for Visual Studio, so that also Toolset V100 can be used.

    with best regards

       Hendrik

     

    Monday, February 21, 2011 1:18 PM

Answers

All replies

  • Hi Hendrik,

     

    VC++ 2010 (no SP1 required) supports compile a project with toolset V100 and .Net Framework 2.0 – 3.5. If we create a project using .net 2.0, the default toolset for the project is V90. We can modify the toolset in Project Properties to V100 to use VC++ 2010 CRT. Now your project is refer to .Net 2.0 and toolset V100. (This is not correct, if V100 is set, the framework is always .Net 4.0, see my next reply for explanation. The following way is used to target other framworks in VC++ 2010 using V90.)

     

    It is also available to modify the .Net framework version after creating project. Since this feature is not available in IDE, You have to change the target Framework by modifying the project (.vcxproj) file. Generally speaking,  in the editor, open the project (.vcxproj) file for your project,

    locate the entry for the target Framework version tag <TargetFrameworkVersion>. Change the value to the Framework version you want, for example: <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>.

     

    You are allowed to modify toolset using similar way: find and modify tag <PlatformToolset>, e.g. <PlatformToolset>v90</PlatformToolset>.

     

    For more information about changing Target Framework and Platform Toolset, please check http://msdn.microsoft.com/en-us/library/ff770576.aspx and blog article: http://blogs.msdn.com/b/vcblog/archive/2009/12/08/c-native-multi-targeting.aspx

     

    Regards,

    Yi

     

     

     


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 22, 2011 6:27 AM
  • If I compile it with Toolset V100 and use the output ( a dll ) in my C# project ( .Net 2.0) Visual Studio claims that the dll is for .Net 4.0.

    I change the toolset via Properties under 'General'.

    Maybe this has something to to with /clr:oldsyntax

    I have already <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> in my project file.

    ......

    <PropertyGroup Label="Globals">
        <ProjectGuid>{B35E77AD-2347-42EE-BEA1-2F183B001B21}</ProjectGuid>
        <RootNamespace>Jedox.Palo.Comm</RootNamespace>
        <Keyword>ManagedCProj</Keyword>
        <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
      </PropertyGroup>

    .....

    regards

      Hendrik

     

     


    Tuesday, February 22, 2011 8:21 AM
  • Hi Herndrik,

    Forgive me misunderstand your question. Yes, you are correct.

    This is because VC++ 2010 (V100) compiler only supports .Net Framework 4.0 (CLR 4.0) for managed code.  If you want to use CLR 2.0, .Net Framework 2.0 – 3.5, you have to use VC++ 2008 compiler (V90).  It is by design for VC++ compiler. And it is why we need C++ native multi targeting to support previous framework.

    I don’t believe it will be changed in SP1. You can download and try the SP1 beta at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=11ea69cb-cf12-4842-a3d7-b32a1e5642e2&displaylang=en.  For more information about changes in SP1, please check this blog article: http://blogs.msdn.com/b/vcblog/archive/2010/12/09/vs2010-sp1-beta-what-s-on-it-for-c-developers.aspx

    Thanks,

    Yi

     

     


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by h_schmieder Wednesday, March 02, 2011 9:10 AM
    Wednesday, February 23, 2011 2:40 AM
  • That's sad.

    Maybe I should give an explanation why it would be important for me.

     

    The manged C++ dll compiled with toolset V90 can NOT call methods of a native C++ compiled vith toolset V100, since the STL conatiners are not compatible (at least not list<T> ).

     

    For some methods of my managed C++ such a call would result in speedup and less memory consumption.

     

    regards

      Hendrik

     

     

     

    Wednesday, February 23, 2011 8:59 AM
  • Hi Hendrik,

     

    I understand you. However, why not upgrade your application into .Net 4.0 and V100?

     

    If we put the native C++ with V100 into a DLL, and a managed C++ with V90 load the native DLL, does the workaround work for you? Please note, this way will load two version of CRT, V90 and V100, it is not recommended.

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 23, 2011 10:57 AM
  • The native C++ with v100 is already a dll.

     

    To 4.0 :

    I was the one who had to check if we can upgrade from VS2005 to VS2010.

    And I was first testing with .Net 4.0 and V100.

    But everytime I tried to open a C#Form I got a security exception.

    On the other side our head of development wasn't happy about .Net 4.0 either, since he didn't want to rollout .Net 4.0 runtime with our setup.

     

    with best regards

       Hendrik

     

     

     

     

    Wednesday, February 23, 2011 12:22 PM
  • Hi Hendrik,

     

    Generally speaking, we recommend you upgrade your all  projects into .Net 4.0 and V100 CRT.  I also understand your situation for keeping using previous version for your business.  However, the behavior you mentioned is by design.  Since VS2010 SP1 will be release soon, I hope you can recheck whether newer version in SP1 fulfill your request and reconsider port projects into new SP1 with .Net 4.0 and V100 CRT.  You may try VS2010 SP1 RC at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=11ea69cb-cf12-4842-a3d7-b32a1e5642e2&displaylang=en

     

    We're always looking for suggestions and feedback from our customers. If you notice a problem with the product or have a suggestion, please use the MSDN Product Feedback Center to submit your feedbacks. Our developer will evaluate them seriously and take them into consideration when designing future release or service pack of the Visual C++.

     

     

     

    Regards,

    Yi

     

     

     


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thank you for your understanding.
    Thursday, February 24, 2011 2:01 AM
  • Why not move your MC++ code to C++/CLI? That way you can use that under .NET 4.0.
    http://blog.voidnish.com
    Thursday, February 24, 2011 2:50 AM
  • Hi Nishant,

    The problem is the OP don't like .Net 4.0.  His main project is using 2.0 and V90, and he want some new STL feature in V100.

    Cheers,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 3:12 AM
  • Ok, thanks Yi.

    To the OP : Well, you can't have it both ways I guess. Either move everything to 4.0 or go with what you have :-)


    http://blog.voidnish.com
    Thursday, February 24, 2011 3:39 AM
  • Hello,

    1)

    I would glady give feedback via http://connect.microsoft.com/feedback/default.aspx?siteid=210 ,

    but this shows just an empty page (even in 32bit IE)

     

    2)

    I need to make clarification.

    It is just one of seven C/C++ Projects which can NOT be used with V100 (unfortunatly).

    And we don't use any new VC2010 features or in other words the whole solution would also compile with VS2005.

    I don't know if managed C++ is the correct wording.

    We (must) use /clr:oldsyntax and in the cpp file

    #using <mscorlib.dll>
    using namespace System;
    using namespace System::Runtime::InteropServices;
    using namespace System::Reflection;
    using namespace System::Reflection::Emit;
    #include <vcclr.h>
    

    But i works, we can use it in our C# project.

    No need to rewrite it C++/CLI whatever that might be.

    Thursday, February 24, 2011 9:01 AM
  • Hi h_schmieder,

     

    For (1):

     

    This is correct link: http://connect.microsoft.com/VisualStudio.

     

    For (2): 

     

    I’m confused. If you don’t need any feature of V100, why you want do a (Managed and native) code with .Net 2.0 and V100?

     

    /clr:oldsyntax is used to compiler the old C++/CLI  syntax which is introduced in Managed Extensions for C++. From VC++ 2005 we start to use a new syntax for managed C++ code. For more information, please check http://msdn.microsoft.com/en-us/library/b23b94s7.aspx

     

    Managed C++ is refer to the code written by C++/CLI (.Net Framework).

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 9:54 AM
  • Note to the OP: The old MC++ syntax is now officially obsolete. You really need to upgrade to C++/CLI if you can (ironically even C++/CLI seems to be destined to go the same route in an year or so).
    http://blog.voidnish.com
    Thursday, February 24, 2011 2:21 PM
  • Hello,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 

    If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 02, 2011 3:45 AM
  • Hello,

     

    the original question is answered.

    This restriction will unfortunately still apply with SP1.

     

    best regards

       Hendrik

     

    Wednesday, March 02, 2011 8:52 AM
  • Hi Hendrik,

    Thank you for updating. Please mark the helpful reply as the answer to close the thread.

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 02, 2011 9:08 AM