C
C#8mo ago
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;
}
No description
No description
10 Replies
Silme94
Silme94OP8mo ago
Buddy
Buddy8mo ago
Because obviously you'll need all the dependencies too?
Silme94
Silme94OP8mo ago
how do i do that
Buddy
Buddy8mo ago
Also if you are making a http library in C++, please don't require any .NET dependencies. Make it in pure C / C++
Silme94
Silme94OP8mo ago
uh not an easy task using socket to make http request
Buddy
Buddy8mo ago
Yes it is? Depends what features you need HTTP 1.1 is easy as hell
Silme94
Silme94OP8mo ago
well u have a lot to do, like parsing response headers but this isn't the issue why i shouldn't use
Buddy
Buddy8mo ago
For one .. Runtime? It requires a lot of dependencies I highly doubt anyone will use said library if you need .NET dependencies. Most C / C++ devs will even only use header-only libraries Generally HTTP protocol is simple, it's all just text. https://osasazamegbe.medium.com/showing-building-an-http-server-from-scratch-in-c-2da7c0db6cb7
Buddy
Buddy8mo ago
Computerphile
YouTube
Coding a Web Server in 25 Lines - Computerphile
Just how simple can a web server be? Laurence Tratt, Shopify / Royal Academy of Engineering Research Chair in Language Engineering at Kings College London builds it up. More about Laurie: https://bit.ly/C_LaurenceTratt https://www.facebook.com/computerphile https://twitter.com/computer_phile This video was filmed and edited by Sean Riley. ...
Buddy
Buddy8mo ago
The latter is using Rust but the logic pretty much remains the same You just need to translate to C / C++
Want results from more Discord servers?
Add your server