Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using DotNET API in MFC application

Using DotNET API in MFC application

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpsecurityjsonhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ComplexLifeForm
    wrote on last edited by
    #1

    Hi All, I wanted to use NET API in my MFC application, since this was new to me I started out with a simple application listed below #include "stdafx.h" #include "myapp.h" #using #using using namespace System; // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs _tprintf(_T("Fatal Error: MFC initialization failed\n")); nRetCode = 1; } else { // TODO: code your application's behavior here. Console::WriteLine("This is a MFC app using NET API"); } return nRetCode; } Till few days back I was able to successfully compile and run this simple application using VC++ 2005 with SP1, however now when I am trying to compile the application I am getting the following error 1>.\myapp.cpp(45) : error C3666: 'System::Security::IEvidenceFactory::IEvidenceFactory' : override specifier 'new' not allowed on a constructor 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : error C3611: 'System::Security::IEvidenceFactory::GetLifetimeService': a sealed function cannot have a pure-specifier 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : error C4687: 'System::Console': a sealed abstract class cannot implement an interface 'System::Security::IEvidenceFactory' 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : fatal error C1903: unable to recover from previous error(s); stopping compilation 1> This diagnostic occurred while impor

    R H 2 Replies Last reply
    0
    • C ComplexLifeForm

      Hi All, I wanted to use NET API in my MFC application, since this was new to me I started out with a simple application listed below #include "stdafx.h" #include "myapp.h" #using #using using namespace System; // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs _tprintf(_T("Fatal Error: MFC initialization failed\n")); nRetCode = 1; } else { // TODO: code your application's behavior here. Console::WriteLine("This is a MFC app using NET API"); } return nRetCode; } Till few days back I was able to successfully compile and run this simple application using VC++ 2005 with SP1, however now when I am trying to compile the application I am getting the following error 1>.\myapp.cpp(45) : error C3666: 'System::Security::IEvidenceFactory::IEvidenceFactory' : override specifier 'new' not allowed on a constructor 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : error C3611: 'System::Security::IEvidenceFactory::GetLifetimeService': a sealed function cannot have a pure-specifier 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : error C4687: 'System::Console': a sealed abstract class cannot implement an interface 'System::Security::IEvidenceFactory' 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : fatal error C1903: unable to recover from previous error(s); stopping compilation 1> This diagnostic occurred while impor

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      You cannot use the .NET framework from a native application (MFC, C, C++, whatever). If you want to use applications that exploit the features of .NET framework, then you will need to write code in one of those managed languages (C#, VB.NET, CLI/C++)

      Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

      1 Reply Last reply
      0
      • C ComplexLifeForm

        Hi All, I wanted to use NET API in my MFC application, since this was new to me I started out with a simple application listed below #include "stdafx.h" #include "myapp.h" #using #using using namespace System; // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs _tprintf(_T("Fatal Error: MFC initialization failed\n")); nRetCode = 1; } else { // TODO: code your application's behavior here. Console::WriteLine("This is a MFC app using NET API"); } return nRetCode; } Till few days back I was able to successfully compile and run this simple application using VC++ 2005 with SP1, however now when I am trying to compile the application I am getting the following error 1>.\myapp.cpp(45) : error C3666: 'System::Security::IEvidenceFactory::IEvidenceFactory' : override specifier 'new' not allowed on a constructor 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : error C3611: 'System::Security::IEvidenceFactory::GetLifetimeService': a sealed function cannot have a pure-specifier 1> This diagnostic occurred while importing type 'System::Security::IEvidenceFactory ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : error C4687: 'System::Console': a sealed abstract class cannot implement an interface 'System::Security::IEvidenceFactory' 1> This diagnostic occurred while importing type 'System::Console ' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 1>.\myapp.cpp(45) : fatal error C1903: unable to recover from previous error(s); stopping compilation 1> This diagnostic occurred while impor

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        You can make a dll and use of it on the c++ or vice versa.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups