locked
TargetFrameworkVersion="196613" RRS feed

  • Question

  • How do you parse the TargetFrameworkVersion property value in the managed C++ projects for VS.NET 2005/2008?

    I mean how do I map the value "196613" to .NET Framework version?

    Best regards,
    Paul. 

    Thursday, July 21, 2011 9:10 AM

Answers

  • Hi Paul,

     

    Here is the definition of the enumFrameworkVersion

     

    enum enumFrameworkVersion
    {
     eFrameworkVersionUnknown = 0,
     eFrameworkVersion20 = 131072,
     eFrameworkVersion30 = 196608,
     eFrameworkVersion35 = 196613
    };
    

     

    You can follow these codes:

     

     

    #include "stdafx.h"
    
    #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
    #ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
    #endif
    
    #include <atlbase.h>
    
    #include <iostream>
    using namespace std;
    
    #import <VCProjectEngine.dll> raw_interfaces_only raw_native_types
    using namespace VCProjectEngineLibrary;
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	CoInitialize( NULL );
    	
    	HRESULT hr = S_OK;
    	// Create the VCProjectEngine
    	CComPtr<VCProjectEngine> spEngine;
    	hr = CoCreateInstance( __uuidof(VCProjectEngineObject), NULL, CLSCTX_INPROC_SERVER, __uuidof(VCProjectEngine), (void**)&spEngine );
    	if( FAILED( hr ) || !spEngine )
    	{
    		cout << "Error: cannot create VCProjectEngine object." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    
    	CComPtr<IDispatch> spDispProj;
    	hr = spEngine->LoadProject( CComBSTR( L"D:\\******\\sample.vcproj" ), &spDispProj );
    	if( FAILED( hr ) || !spDispProj )
    	{
    		cout << "Error: cannot open the specified project." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    	CComQIPtr<VCProject> spProject = spDispProj;
    	if( !spProject )
    	{
    		cout << "Error: cannot query VCProject interface." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    	VCProjectEngineLibrary::enumFrameworkVersion spFv;
    	hr = spProject->get_TargetFrameworkVersion(&spFv);
    	switch((long)spFv)
    	{
    	case 0:
    		printf("unknow Version Framework");
    		break;
    	case 131072:
    		printf(".NET Framework 2.0");
    		break;
    	case 196608 :
    		printf(".NET Framework 3.0");
    		break;
    	case 196613:
    		printf(".NET Framework 3.5");
    		break;
    	}
    	return 0;
    }
    
    
    

     

    Best regards,

    Jesse


    Jesse Jiang [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 Paul Selormey Friday, July 22, 2011 7:34 AM
    Friday, July 22, 2011 5:46 AM

All replies

  • Hi Paul,

     

    Here is the definition of the enumFrameworkVersion

     

    enum enumFrameworkVersion
    {
     eFrameworkVersionUnknown = 0,
     eFrameworkVersion20 = 131072,
     eFrameworkVersion30 = 196608,
     eFrameworkVersion35 = 196613
    };
    

     

    You can follow these codes:

     

     

    #include "stdafx.h"
    
    #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
    #ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
    #endif
    
    #include <atlbase.h>
    
    #include <iostream>
    using namespace std;
    
    #import <VCProjectEngine.dll> raw_interfaces_only raw_native_types
    using namespace VCProjectEngineLibrary;
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	CoInitialize( NULL );
    	
    	HRESULT hr = S_OK;
    	// Create the VCProjectEngine
    	CComPtr<VCProjectEngine> spEngine;
    	hr = CoCreateInstance( __uuidof(VCProjectEngineObject), NULL, CLSCTX_INPROC_SERVER, __uuidof(VCProjectEngine), (void**)&spEngine );
    	if( FAILED( hr ) || !spEngine )
    	{
    		cout << "Error: cannot create VCProjectEngine object." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    
    	CComPtr<IDispatch> spDispProj;
    	hr = spEngine->LoadProject( CComBSTR( L"D:\\******\\sample.vcproj" ), &spDispProj );
    	if( FAILED( hr ) || !spDispProj )
    	{
    		cout << "Error: cannot open the specified project." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    	CComQIPtr<VCProject> spProject = spDispProj;
    	if( !spProject )
    	{
    		cout << "Error: cannot query VCProject interface." << endl;
    		CoUninitialize(); 
    		return 1;
    	}
    	VCProjectEngineLibrary::enumFrameworkVersion spFv;
    	hr = spProject->get_TargetFrameworkVersion(&spFv);
    	switch((long)spFv)
    	{
    	case 0:
    		printf("unknow Version Framework");
    		break;
    	case 131072:
    		printf(".NET Framework 2.0");
    		break;
    	case 196608 :
    		printf(".NET Framework 3.0");
    		break;
    	case 196613:
    		printf(".NET Framework 3.5");
    		break;
    	}
    	return 0;
    }
    
    
    

     

    Best regards,

    Jesse


    Jesse Jiang [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 Paul Selormey Friday, July 22, 2011 7:34 AM
    Friday, July 22, 2011 5:46 AM
  • Hello Jesse,

    Thanks for the reply. I was actually doing a similar thing but thought the numbers might have some meaning and a way to parse them since older projects files do not have these numbers so that I could tell what it will be for .NET 1.0/1.1, if needed. Currently, I read the project version attribute to determine the .NET 1.0 or .NET 1.1.

    Again, thanks for the reply.

    Best regards,
    Paul. 

    Friday, July 22, 2011 7:34 AM