Jump to content

Visual Studio Debugger


Recommended Posts

Is there any way to run ONI C# through a debugger ?  I tired generating .pdb for Assembly-CSharp.dll using dotPeek, but when a attach a debugger to oni in VS, I don't even see Assembly-CSharp.dll in the Modules windows.

Any tips to improve the debugging experience when modding ? printf debugging has its limits...

 

Thanks

Link to comment
Share on other sites

There is a way. It requires some work though. First you have to download the unity version for the game (currently it's 2020.3.3). Once that is done go to the unity installation folder and navigate to:

Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_development_mono\

from that folder we need three files:

  • WindowsPlayer.exe
  • UnityPlayer.dll
  • WinPixEventRuntime.dll

copy these to ONI's installation folder, rename 'WindowsPlayer.exe' to 'OxygenNotIncluded.exe' and replace the files. Keep in mind to make a backup of the original files otherwise you would have to verify the game files to retrieve the original ones.

Then in ONI's installation folder find "OxygenNotIncluded_Data\boot.config" open it with a text editor and add the following lines:

wait-for-managed-debugger=1
player-connection-debug=1

Now when you start the game via steam it should show a message box saying that you can attach a debugger. Make sure to have the Visual Studio Tools for Unity installed. You can then in VS go to Debug -> Attach Unity Debugger and should be able to attach VS to the game. 

Link to comment
Share on other sites

On 6/8/2023 at 9:06 PM, Josch said:

There is a way. It requires some work though. First you have to download the unity version for the game (currently it's 2020.3.3). Once that is done go to the unity installation folder and navigate to:

I tried and found that the unity version is 2020.3.30f1 .

Anyway, thank you for your tutorials!

I lanch the ONI game via debug,successfully.But I still dont know how to use Visual Studio to debug my mod.

Maybe I need to do something else.

Link to comment
Share on other sites

Thank you! It can be frustrating to get it to work. It's worth it though I guess.

17 hours ago, while said:

I tried and found that the unity version is 2020.3.30f1 .

Oh yeah the Player.log lists "Initialize engine version: 2020.3.30f1 (1fb1bf06830e)".

You could check if you have

<DebugType>portable</DebugType>

set in your .csproj file. Also try to copy the .pdb file next to the dll. I'm not sure if the absolute path to that is saved in managed DLLs too. In native DLLs it is so it would find the symbols.

Also make sure to use Attach Unity Debugger. That's important because that way Visual Studio connects to the mono runtime of unity. With "normal debugging" it won't work. 

Link to comment
Share on other sites

22 hours ago, Josch said:

Thank you! It can be frustrating to get it to work. It's worth it though I guess.

Oh yeah the Player.log lists "Initialize engine version: 2020.3.30f1 (1fb1bf06830e)".

You could check if you have

<DebugType>portable</DebugType>

set in your .csproj file. Also try to copy the .pdb file next to the dll. I'm not sure if the absolute path to that is saved in managed DLLs too. In native DLLs it is so it would find the symbols.

Also make sure to use Attach Unity Debugger. That's important because that way Visual Studio connects to the mono runtime of unity. With "normal debugging" it won't work. 

Wow,I it works! Debug can Save a lot of time.

Thanks a lot!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...