# Debugging

While developing, you may encounter bugs that are not easily understandable by simply logging variables to the console. In such cases, a debugger can be incredibly useful. It allows you to inspect values in real time, helping you better understand what is happening and identify the root cause of the issue.

## Configure the Debugger

We assume that you have already set up your server-side plugin. If not, please create one first.

{% content-ref url="/pages/6WzmAEeQFvdFZHo16xaX" %}
[Creating a Plugin](/hogwarp/scripting/server-side/plugin/creating-a-plugin.md)
{% endcontent-ref %}

{% tabs %}
{% tab title="Visual Studio" %}

1. Open your project in `Visual Studio`.
2. Navigate to the `Debug` tab at the top of the IDE.
3. In the context menu, scroll down and click on `Debug Properties` at the bottom.

<figure><img src="/files/mFmfhPEJdQN5kJ17sJI7" alt=""><figcaption></figcaption></figure>

1. This will open the `Launch Profiles` window.
2. Click on `Create a new profile` at the top left.
3. Then, select `Executable` from the options.

<figure><img src="/files/R2O7BbQQ8pKFXSpDflRJ" alt=""><figcaption></figcaption></figure>

This will create your new profile. In our example, we renamed it to `Debug Server`. You can find the rename option above the profile, located at the far right.

<figure><img src="/files/jlG6JCaCXBJ4XAolryft" alt=""><figcaption></figcaption></figure>

1. Now, select the `Executable` and click on `Browse`.
2. After clicking, a dialog will open.
3. Navigate to and select `Server.Loader.exe`, then click `Open` at the bottom right.

<figure><img src="/files/EdRWaZ08aps898tzt8BB" alt=""><figcaption></figcaption></figure>

The dialog will close. Now, you need to define the `Working Directory`. To do this, click on `Browse...`. This will open another dialog.

<figure><img src="/files/wUSyUNebp49JBzDYXqPh" alt=""><figcaption></figcaption></figure>

Here, you need to select the folder containing your `Hogwarp server files`, where the `Server.Loader.exe` is located.

<figure><img src="/files/7iutBSV9bgIjnaNjh3CX" alt=""><figcaption></figcaption></figure>

Click `OK` to close the dialog. Now, you can close the `Launch Profiles` dialog as well.
{% endtab %}

{% tab title="JetBrains Rider" %}

* Open your project in `JetBrains Rider`.
* Navigate to `Add Configuration...` at the top right of the IDE.
* Click on it, and then select `Edit Configurations...` .<br>

<figure><img src="/files/GBTpLUyBLQm86lTVmFbV" alt=""><figcaption></figcaption></figure>

The `Run/Debug Configurations` window will open. Click on the `+` (plus) icon at the top left and create a `.Net Executable` .

<figure><img src="/files/NOoeu4OyvVZGPL6tYJlu" alt=""><figcaption></figcaption></figure>

Now, you should have a new configuration. In our case, we will rename it to `Debug Server`. To do this, click next to the Name property and enter the new name.

<figure><img src="/files/JRjVKSDzTp4BxIr1Jrb9" alt=""><figcaption></figcaption></figure>

Now, we need to configure the `Exe path`. To do this, click on the folder icon in the blank line to the right.

<figure><img src="/files/9ECGVUaM87cP9E6uIiP3" alt=""><figcaption></figcaption></figure>

After clicking, a dialog will open. Navigate to and select `Server.Loader.exe`, then click `Open` at the bottom right.

<figure><img src="/files/DYqELbCotgOnDUcJc4di" alt=""><figcaption></figcaption></figure>

The dialog will close. Now, click `OK` to close the `Run/Debug Configurations` dialog.
{% endtab %}
{% endtabs %}

## Start Debugging the Server

After configuring the debugger, you can now start your server within the IDE and begin debugging it.

{% tabs %}
{% tab title="Visual Studio" %}
To effectively debug your server, we recommend changing your configuration to use `Debug` mode instead of `Release` mode.

<figure><img src="/files/LIR9Vlsh6qle3qjGm0fR" alt=""><figcaption></figcaption></figure>

After making this change, ensure that your created profile is selected if it isn’t already.

<figure><img src="/files/6dGTUyPND6SgWWI4C5xk" alt=""><figcaption></figcaption></figure>

Now, click on your profile—in our case, `Debug Server`—and the server should start with debugging enabled. As an example, we added a breakpoint at `line 10` to demonstrate how it looks when it’s working.

<figure><img src="/files/F49FfgtoP6o0o9TrbevQ" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="JetBrains Rider" %}
To effectively debug your server, we recommend changing your configuration to use `Debug` mode instead of `Release` mode.

<figure><img src="/files/pnwYHsmm1uJBEEXCxyq9" alt=""><figcaption></figcaption></figure>

After making this change, ensure that your created profile is selected if it isn’t already.

<figure><img src="/files/1btUjEM6h8ir4V0T7TYs" alt=""><figcaption></figcaption></figure>

Now, click on the `bug icon` (debug icon), and the server should start with debugging enabled.

<figure><img src="/files/rIyu4iF2L7cR2vD20ueJ" alt=""><figcaption></figcaption></figure>

As an example, we added a breakpoint at `line 10` to demonstrate how it looks when debugging is active.

<figure><img src="/files/TsNQZyu7b55J5UWQew72" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hogwarp.com/hogwarp/scripting/server-side/debugging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
