CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2005

    How to use C# dll?

    myDLL.dll was generated from IKVM. Use in C# project is perfectly fine.

    HOW to:

    1. call a static method in C++. in C# code, it is `com.myApp.Initialiser.initialise(object, string, int)`
    2. create a new instance in C++. in C# code it is `new com.myApp.requests.MyRequest()`

    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    #include <stdio.h>
    #include <cstring>
    #include <string>
    #include <windows.h>
    typedef void (*Initialise)(void*, std::string, int);
    int main(){
        HINSTANCE myDLL = LoadLibrary(TEXT("myDLL.dll"));
        HINSTANCE ikvmCoreDLL = LoadLibrary(TEXT("IKVM.OpenJDK.Core.dll"));
        if(myDLL && ikvmCoreDLL){
            cout << "dlls loaded" << endl;
            //how to do 1 and 2 using myDLL.dll?
            Initialise ptr = (Initialise) GetProcAddress(myDLL, "initialise"); //not working
        return 0;
    Last edited by Newb_; June 20th, 2018 at 05:18 PM.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: How to use C# dll?

    Is your C# dll marked as a COM dll? If not, you can't call it from a native c++ application. However, you can call it from a managed C++ app.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)