© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
22 replies
Silme94

C# DLL failed to load

Am trying to make a dll that can be called from C++, when i load the dll file i get this exception
Here is the C++ code where i try to call dll and full C# code

#include <iostream>
#include <Windows.h>

typedef void(__cdecl* DEBUG)();

int main() {
    HMODULE hModule = LoadLibraryA("HttCppLibrary.dll");
    if (hModule != NULL) {
        auto debug = (DEBUG)GetProcAddress(hModule, "DEBUG");
        debug();
        std::cout << "debug is called\n";
        FreeLibrary(hModule);
    }
    else {
        std::cout << "Failed to load DLL" << std::endl;
    }

    return 0;
}
#include <iostream>
#include <Windows.h>

typedef void(__cdecl* DEBUG)();

int main() {
    HMODULE hModule = LoadLibraryA("HttCppLibrary.dll");
    if (hModule != NULL) {
        auto debug = (DEBUG)GetProcAddress(hModule, "DEBUG");
        debug();
        std::cout << "debug is called\n";
        FreeLibrary(hModule);
    }
    else {
        std::cout << "Failed to load DLL" << std::endl;
    }

    return 0;
}
ssssssssq.PNG
zzzzzzzzb.PNG
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ C# dll
C#CC# / help
3y ago
✅ Separate C# Dll
C#CC# / help
16mo ago
✅ Using a C# DLL in C++
C#CC# / help
2y ago
Using a c++ dll in c#
C#CC# / help
2y ago