Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_assembly_and_get_function_pointer_fn ptr getting failed #7002

Open
yashnikam opened this issue Nov 25, 2024 · 0 comments
Open

load_assembly_and_get_function_pointer_fn ptr getting failed #7002

yashnikam opened this issue Nov 25, 2024 · 0 comments

Comments

@yashnikam
Copy link

yashnikam commented Nov 25, 2024

I am trying to call managed code from native, but load_assembly_and_get_function_pointer_fn getting failed with following error Failed to load assembly or get function pointer. Error code: 0x80070057

code snippet:

const string_t dotnetlib_path = STR("/home/yash/code/nativehost/MyDotNetLib/bin/Debug/net7.0/MyDotNetLib.dll");
const char_t *dotnet_type = STR("MyDotNetLib.MyClass, MyDotNetLib");
const char_t *dotnet_type_method = STR("Hello");

typedef void (*HelloDelegate)();
HelloDelegate hello_delegate = nullptr;
rc = load_assembly_fn(dotnetlib_path.c_str(), dotnet_type, dotnet_type_method, nullptr, nullptr,(void**)&hello_delegate);

if (rc != 0 && hello_delegate == nullptr) {
    std::cerr << "Failed to load assembly or get function pointer. Error code: " << std::hex << std::showbase << rc << std::endl;
    
    return false;

Csharp code:

using System; using System.Runtime.InteropServices; namespace MyDotNetLib { public static class MyClass { public static void Hello() { System.Console.WriteLine("hello"); } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant