Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

load_assembly_and_get_function_pointer_fn ptr getting failed

Open
#7,002 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, csharp
Domain
devtools

Research direction

Start with the native snippet's load_assembly_fn call and the MyDotNetLib.MyClass.Hello declaration. Verify how the assembly path, type name, method name, and returned function pointer are expected to be supplied, then reproduce the 0x80070057 result. Done means the pointer is obtained successfully and the native call reaches Hello.

Written by the indexing model from the issue text.

Description

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"); } } }

Dominant language
C#
Stars
3.7k
Forks
5.1k
Avg merge
8m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/samples

All issues in dotnet/samples

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.