问题
I have a C++ DLL in bin folder of my ASP MVC5 web application project. (I have copied and pasted it from the original C++ project as I was unable to add a reference) I am able to call some of the functions of the DLL(used DLLImport). I have a problem in one of the functions. This can only be solved when I will be able to step into the code of the C++ DLL. I also have the code of the C++ project (built using Cmake). How do I reach the C++ code while debugging from my web application code. If I use F11 I should be able to reach the C++ code.
回答1:
Debug a C++ DLL used in ASP MVC application
1) First, make sure that make sure that the DLL you are referring to has a PDB file or other output file in its folder.
You should open the c++ project in VS IDE and then make sure that you built it with Debug and x64 mode. If so, build it again.
Then in c# web project, use DLLImport to reference the xxx.dll
in the output Debug folder which exists pdb and other whole files.
2) Second, go to Tools --> Options --> Projects and Solutions --> Web Projects --> Use the 64 bit version of IIS Express.
3) Third, if you debug a net core web project, please right-click on the project--> Properties-->Debug-->check Enable native Code Debugging.
If you debug a net framework web project, please right-click on the project--> Properties-->Web-->check Native Code.
4) Fourth, then close VS Instance, delete the bin and obj folder of the asp.net core project, then restart your web project and test again.
In addition, you can check this document Debug C# and C++ in the same debugging session.
Update 1
Due to the error, I think you should change to set IIS
to x64
since you use x64
native dll. Right-click on your project-->Properties
--> Web
-->change IIS bitness
to x64
.
来源:https://stackoverflow.com/questions/62210558/debug-a-c-dll-used-in-asp-mvc-application