-
-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
DllExport version
1.8.1
Environment
None
Ask the .NET DllExport project
I used BasicExport.ExtDotNetCoreLibrary4 as an example and modified Alg's code as shown above. This code requires the NBitcoin package.
public static class Class1
{
static Class1()
{
static Assembly _Load(string path)
{
if (!File.Exists(path)) return null;
Console.WriteLine("Load: " + path);
return Assembly.LoadFrom(path);
}
AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
_Load(Path.Combine
(
Path.GetDirectoryName(typeof(Class1).Assembly.Location),
e.Name?[..e.Name.IndexOf(',')] + ".dll"
));
}
[DllExport("testMethod", CallingConvention = CallingConvention.StdCall)]
public static string testMethod()
{
return "Yippee!";
}
[DllExport("GenerateAddress", CallingConvention = CallingConvention.StdCall)]
public static string GenerateAddress()
{
try
{
var key = new Key();
var address = key.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
return address.ToString();
}
catch (Exception ex)
{
return $"Error: {ex.Message}";
}
}
}
Then I got an exception when testing.
testcode:
static void Main(string[] args)
{
Console.WriteLine(testMethod2());
Console.WriteLine(GenerateAddress2());
}
[DllImport("ExtDotNetCoreLibrary4.dll", CallingConvention = CallingConvention.StdCall,EntryPoint = "testMethod")]
public extern static string testMethod2();
[DllImport("ExtDotNetCoreLibrary4.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "GenerateAddress")]
public extern static string GenerateAddress2();
The console output was:
Yippee!
Unhandled exception. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. at testconsole.Program.GenerateAddress2() at testconsole.Program.Main(String[] args) in System.IO.FileNotFoundException: System.Runtime, Version=6.0.0.0, Culture=neutral
I’ve looked at #219, #167,#132, but I didn’t find a solution. I might have missed something.
DllExport configuration
Installed: True; 1.8.1.36569+c2d3cd1; invoked: 1.8.1
Project type: Cs
Storage: ProjectFiles
Compiler.Platform: Auto
Compiler.imageBase: 0x8000000
Compiler.imageBaseStep: 0x400000
Compiler.ordinalsBase: 1
Compiler.rSysObj: True
Compiler.ourILAsm: True
Compiler.customILAsm:
Compiler.genExpLib: False
Compiler.peCheck: PeIl, Pe32orPlus
Compiler.patches: None
Compiler.refreshObj: False
PreProc.Type: None
PreProc.Cmd:
PostProc.Type: None
PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath)
PostProc.Cmd:
AssemblyExternDirectives:
TypeRefDirectives: System.Runtime.CompilerServices.DefaultInterpolatedStringHandler,,False,False,True;
TypeRefOptions: DefaultInterpolatedStringHandler
RefPackages:
SignAssembly(Debug):
PlatformTarget(Debug): x86
TargetFramework(Debug):
TargetFrameworks(Debug): net9.0;net8.0;netstandard2.1
TargetFrameworkVersion(Debug):
TargetFrameworkIdentifier(Debug):
RootNamespace(Debug):
AssemblyName(Debug):
DebugType(Debug):
Optimize(Debug):
DebugSymbols(Debug):
SignAssembly(Release):
PlatformTarget(Release): x86
TargetFramework(Release):
TargetFrameworks(Release): net9.0;net8.0;netstandard2.1
TargetFrameworkVersion(Release):
TargetFrameworkIdentifier(Release):
RootNamespace(Release):
AssemblyName(Release):
DebugType(Release):
Optimize(Release):
DebugSymbols(Release):
Identifier: 65D268EE-0B35-40C6-9D7C-0232BA10B163
Instance: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\MSBuild.exe
Project path: F:\Examples-master\DllExport\BasicExport\ExtDotNetCoreLibrary4\ExtDotNetCoreLibrary4.csproj
Action: Configure
MgrArgs:
MetaLib: tools\raw\lib\net20\DllExport.dll
MetaCor: tools\raw\lib\netstd\DllExport.dll
Proxy:
StoragePath: .net.dllexport.targets
ddNS: com.github._3F.DllExport
ddNS max buffer: 500
UseCecil: True
intermediateFiles: False
timeout: 30000
Options: None
RootPath: F:\Examples-master\DllExport\BasicExport\
PkgPath: F:\Examples-master\DllExport\BasicExport\packages\\DllExport.1.8.1\
SlnFile:
SlnDir: F:\Examples-master\DllExport\BasicExport\
DxpTarget: tools\net.r_eg.DllExport.targets
MsgLevel: Debug
LockIfError:Code of Conduct
- I agree to follow this project's Code of Conduct