Calling .NET DLL from VC++

Hi,

We have a scenario wherein we have a .NET comiled DLL that contains some classes and methods and we have to call the methods of those classes from our VC++ application. If we were doing it in C#, then it would have been a child's play as we could have included the dll simply but putting it under references and then using the corresponding namespace. But we have to do it in VC++.

How can we go about it We dont have any accompanying code of the DLL or any library file with that dll. We only have a stand alone DLL.

Jitin



Answer this question

Calling .NET DLL from VC++

  • Rajiv Srinivasan-MSFT

    You can just use C++/CLI (compiled with /CLT)and still jut reference the assembly.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Derwood

    Jitin Batra wrote:

    Thanks for the replies. We have done it. But now we are facing another problem. We need to catch some events. And the problem is that if we write the event handlers in our dll, they are not invoked and if we write event handlers for our events (corresponding to the events defined in the dll) in out vc++ application, then it does not even compile.

    Is there any way to catch and handle events in a dll Or we can only catch events in an executable file

    Jitin

    There's no such restriction. Could you show, with some sample code, how you are doing this



  • RobGibbens

    VC++ can work with both managed and unmanaged code at the same time. Mixed mode assemblies, it just works!

    http://msdn2.microsoft.com/en-us/library/x0w2664k(VS.80).aspx



  • mrobichaud

    I am creating an event handler in my C# dll and I am also defining the handler functions in the dll itself.

    //this is the code in the dll

    void function1()

    {

    //Some code to do some processing

    MyObject.MyEvent = new CreateEventHandler(handle1);

    } //end of function1

    private void handle1(object sender, EventArgs eventArgs)

    {

    //some processing on what to do if the event has occured.

    }

    when i call the function1 from my VC++ application, it is executed, but as the event is a user event, the system goes on processing and the user does not get any time to complete the event and the event handler therefore catches nothing.

    How can the event handler function be executed from VC++. The event here i am discussing is a user driven event. So the application has to wait for the user event.


  • Jyoti Ranjan

    Thanks for the replies. We have done it. But now we are facing another problem. We need to catch some events. And the problem is that if we write the event handlers in our dll, they are not invoked and if we write event handlers for our events (corresponding to the events defined in the dll) in out vc++ application, then it does not even compile.

    Is there any way to catch and handle events in a dll Or we can only catch events in an executable file

    Jitin


  • Calling .NET DLL from VC++