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
U

User 9845382

@User 9845382
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • VC++ DLL throws error when call it from C#[EntryPointNotFound]
    U User 9845382

    Here i created in DLL project in vc++ 2008. Following are two code files lib.h and lib.cpp. lib.h

    #include "stdafx.h";

    class \_\_declspec(dllexport) test
    {
    public:
        test();
        static void  hello();
        static void  hello1();
    };
    
    class \_\_declspec(dllexport) test1
    {
    public:
        test1();
        void  hello\_test1();
        void  hello1\_test1();
    
    };
    

    lib.cpp

    #include "stdafx.h"
    #include "lib.h"
    #include void test::hello()
    {
    printf("Hello");
    }

    void test::hello1()
    {
        printf("Hello1");
    }
    
    void test1::hello\_test1()
    {
        printf("Hello\_test1");
    }
    
    void test1::hello1\_test1()
    {
        printf("Hello1\_test1");
    }
    

    stdafx.h

    #include "targetver.h"
    #define WIN32_LEAN_AND_MEAN
    // Windows Header Files:
    #include

    dllMain.cpp

    #include "stdafx.h"

    BOOL APIENTRY DllMain( HMODULE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved
    )
    {
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
    break;
    }
    return TRUE;
    }

    I have written C# code to call the method of test and test1 classes: consoleApp

    [DllImport("lib.dll" )]
    public static extern void hello();

    \[DllImport("lib.dll")\]
    public static extern void hello1();
    
    \[DllImport("lib.dll")\]
    public static extern void hello\_test1();
    
    \[DllImport("lib.dll")\]
    public static extern void hello1\_test1();
    

    static void Main()
    {
    hello();
    hello1();
    hello_test1();
    hello1_test1();
    Console.ReadKey();
    }

    when i run above code i have got following error: EntryPointNotFoundException: Unable to find an entry point named 'hello' in DLL 'lib.dll' 1****<-Click 1 for image I know about how to call function only(without using Class) of vc++ DLL from C# but i don't know how to call method of any class and how to code that in proper way in vc++. I know somewhere is mistake in my above code, please experts guide me about my mistake because i tried all from my side. If anyone has full example like above then suggest me. Thanks in advance..

    C / C++ / MFC tutorial c++ csharp help
  • Login

  • Don't have an account? Register

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