Debugging - pixeltris/USharp GitHub Wiki

Windows (Visual Studio)

If you're running .NET Framework or .NET Core you can use Visual Studio to debug your code. There are two ways to do this.

If you already have the editor running: in Visual Studio go to Debug->Attach to Process... (Ctrl+Alt+P) and select the UE4Editor.exe process in the list. Press the Select... button to the right of Attach to:. In the dialog select Managed (v4.6, v4.5, v4.0) if you're on .NET Framework, or Managed (CoreCLR) if you're on .NET Core. You can also select Native if you want to step into the UE4 C++ code (PDB symbols required). You can now click Attach to start debugging.

If you want to start the editor from Visual Studio: right click your C# project in Visual Studio and then click Properties. Click the Debug tab on the properties page. Under Start action select Start external program and enter the path of UE4Editor.exe which should be under \Engine\Binaries\Win64\UE4Editor.exe. For Command line arguments enter the full path of your .uproject in quotes e.g. "C:/MyProj/MyProj.uproject". You can also check Enable native code debugging if you want to debug the UE4 C++ code (PDB symbols required).

Note: Starting UE4Editor.exe with .NET Core enabled seems to crash the .NET debugger engine. You should attach the debugger after UE4 has fully opened when using .NET Core. "A fatal error has occurred and debugging needs to be terminated. For more details please see the Microsoft Help and Support web site. HRESULT=0x8000ffff. ErrorCode=0x0."

Note: For some reason a threading check fails check(FPlatformTLS::GetCurrentThreadId() == MasterThreadID) when closing the editor if .NET debugging is enabled without native debugging. This can be observed even with a clean install of UE4 without USharp.