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.