admin管理员组文章数量:1321805
I'm using a .NET 8 DLL from which a function AddOne
is exported:
[UnmanagedCallersOnly(EntryPoint ="AddOne")]
public static int AddOne(int x)
{
Console.WriteLine("Inside AddOne");
return x + 1;
}
Then I build the DLL using this command:
dotnet publish -f net8.0 -c Debug -r win-x64 -p:PublishAot=true -p:NativeLib=Shared -p:SelfContained=true
I copy the .pdb and .dll file from the path ClassLibrary\bin\Debug\net8.0\win-x64\native
into the path of my host application.
The host application is a .NET framework console application. I consume the dll with this code:
[DllImport("ClassLibrary.dll")]
private static extern int AddOne(int x);
But when I try to debug into the dll, my breakpoint on the line Console.WriteLine("Inside AddOne");
is never hit.
What am I doing wrong?
Full source code is in this commit:
I'm using a .NET 8 DLL from which a function AddOne
is exported:
[UnmanagedCallersOnly(EntryPoint ="AddOne")]
public static int AddOne(int x)
{
Console.WriteLine("Inside AddOne");
return x + 1;
}
Then I build the DLL using this command:
dotnet publish -f net8.0 -c Debug -r win-x64 -p:PublishAot=true -p:NativeLib=Shared -p:SelfContained=true
I copy the .pdb and .dll file from the path ClassLibrary\bin\Debug\net8.0\win-x64\native
into the path of my host application.
The host application is a .NET framework console application. I consume the dll with this code:
[DllImport("ClassLibrary.dll")]
private static extern int AddOne(int x);
But when I try to debug into the dll, my breakpoint on the line Console.WriteLine("Inside AddOne");
is never hit.
What am I doing wrong?
Full source code is in this commit: https://github/JYPDWhite/DllExportTest/commit/6868cc1cece734e7645ffba061eed915a79dd3c3
Share Improve this question edited Jan 15 at 17:39 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Jan 15 at 16:12 WhiteWhite 3591 silver badge10 bronze badges1 Answer
Reset to default 1Enable mixed-mode debugging:
If you're using .NET Framework code, which has no debug launch profile, follow these steps:
Right-click the project in solution explorer and select Properties
On the left menu, select Debug.
In the Debugger engines section, select the Enable native code debugging property
To apply the property change, close the Properties pane.
本文标签: cDebugging a DLL with exported functions using UnmanagedCallersOnlyStack Overflow
版权声明:本文标题:c# - Debugging a DLL with exported functions using [UnmanagedCallersOnly] - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742106600a2421046.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论