Closed
Description
Hello
I'm trying dllexport for .NET Core
When I use System.Reflection.Assembly.GetExecutingAssembly (), it throws an exception
Unhandled exception. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
Unhandled exception: System.IO.FileNotFoundException: Failed to load file or assembly "System.Runtime, Version = 4.2.2.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" or one of its dependencies. The system can not find the file specified.
v1.7beta3:
Manager: Tried both x86, x64
and Direct-Mod/Cecil
and Rebase System Object
in all possible variants.
Project type: .NET Core 3.1.100 Class Library
Code:
using System.Runtime.InteropServices;
namespace Test
{
public static class Class1
{
[DllExport("AppInfo", CallingConvention = CallingConvention.StdCall)]
public static string AppInfo()
{
string ApiVer = "9";
string AppID = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
//string AppID = "Test";
return string.Concat(ApiVer, ",", AppID);
}
}
}
Calling code
using System;
using System.Runtime.InteropServices;
namespace Console_Core
{
class Program
{
[DllImport("Test.dll")]
public static extern string AppInfo();
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine(AppInfo());
}
}
}
Thank you for your contribution to this project