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. Managed C++/CLI
  4. How to work with manage code in the dll

How to work with manage code in the dll

Scheduled Pinned Locked Moved Managed C++/CLI
c++helpdotnetdebuggingtutorial
1 Posts 1 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.
  • R Offline
    R Offline
    Romiks
    wrote on last edited by
    #1

    Hi All, I have another problem with calling manage code from dll. I do the following: 1. Create dll project in the VS2005, add /clr option under project property->C++->general 2. Add header file to the project with interface: #define Base_API __declspec(dllexport) class BaseI_SqlDbConnection; class Base_API Base_SqlDbConnection { public: Base_SqlDbConnection(); BaseI_SqlDbConnection *m_pi; }; 3. Add define of class to the .cpp file. It is the simple wrapper on the SqlClient. using namespace System; using namespace Data; using namespace SqlClient; #ifdef _MANAGED #pragma managed(push, off) #endif BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } #ifdef _MANAGED #pragma managed(pop) #endif class BaseI_SqlDbConnection { public: BaseI_SqlDbConnection() : m_SqlDbConnection(gcnew SqlConnection){} gcroot m_SqlDbConnection; }; Base_SqlDbConnection::Base_SqlDbConnection() : m_pi(new BaseI_SqlDbConnection) { } 4. Call the class from MFC application looking like this: Base_SqlDbConnection test; With help of debugger, I found that the BaseI_SqlDbConnection() constructor doesn't want to call and object m_SqlDbConnection could not be created. I guess that the problem is in the managed code, but I am newbie for this. Please help me to resolve the problem or point me to the article about this.

    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