1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If you would like to submit a tutorial please visit the main tutorial page here.
    You can not submit them from this forum.
    Dismiss Notice

Debugging ServUO with Visual Studio (Image heavy)

Discussion in 'Tutorials' started by Kalamus, Feb 14, 2014.

  1. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    This is a tutorial for setting up your ServUO project in Visual Studio for debugging. This is not a tutorial on how to debug with Visual Studio as there are plenty of resources on the web for this. I will show a couple basics however for this tutorial. I'm using Visual Studio 2010 but the process should be the same for other version.

    First open your ServUO project up in Visual Studio by double clicking your 'ServUO.sln' file. Once the project is loaded click Build Menu and select Build Solution to ensure you have the binaries needed for the following steps. as28.postimg.org_slsgyvdvx_image.png


    After the build process is finished, open the Solution Explorer window in Visual Studio if you don't already have it open. View menu -> Solution Explorer. as28.postimg.org_sbkyfiz9p_image.png


    Inside your Solution Explorer right click your Scripts project and select Properties. as28.postimg.org_92nvpif4d_image.png


    Go to the Debug tab on the left and select 'Start external program:' and click the '...' button to the right of that. as28.postimg.org_8foyzzi8d_image.png


    On the Select File dialog select ServUO.exe from your project folder and click Open. as28.postimg.org_c6yjmavwt_image.png


    You should see the path appear next to 'Start external program:' Now place '-debug' into the 'Command line arguments:' section. as28.postimg.org_ub1k6xtl9_image.png


    Now you can save your changes by using the Save button on the toolbar or by using File menu -> Save All. ServUO is now setup for debugging through Visual Studio.

    Now I will show you some basics by debugging the StaffOrb.cs. Find and open StaffOrb.cs in the Solution Explorer by double clicking it (Scripts/Items/- Staff Items/). Now find the OnDoubleClick method and place the text editor caret on the first 'if' statement inside that method. Open the Debug menu and select 'Toggle Breakpoint' (this can also be done by clicking the far left of the line in the text editor where the breakpoint icon appears). as28.postimg.org_isgbj6i31_image.png


    You should see a red circle on the far left showing that you have a Breakpoint like this. as28.postimg.org_jw0fv52q5_image.png


    Now right click your Scripts project in the Solution Explorer. Select the 'Debug' menu and 'Start new instance'. as28.postimg.org_5fd6gkd8t_image.png


    Visual Studio will now rebuild your project and after that is done you should see ServUO server launch. Now log into your server through UO and give yourself a StaffOrb if you don't already have one and double click it. UO should now freeze not letting you play any more and Visual Studio should be stopped on the breakpoint you set. as28.postimg.org_py82lmr65_image.png


    You can now step through the code line by line by pressing the F11 key (default for C# environment) or using the debug icons on the toolbar or Debug Menu. You can hover over variables with your mouse and it will pop up a display to show what their current values are like I did with 'from.map' below. as28.postimg.org_ixk2supe5_image.png


    Step through the code and line for line and watch what's going on. This allows you to see why bits of code might not run, what the variables are and what you expect them to be, ect.

    You can stop stepping line for line and let the server go back to running like normal until it hits another breakpoint by pressing the F5 key (default for C# environment) or using the debug icons on the toolbar or Debug Menu.

    This pretty much concludes this tutorial and I would suggest reading up more on Visual Studio debugging on the web as there are tons more things that can be done besides the basics I showed.
     
    #1 Kalamus, Feb 14, 2014
    Last edited: Feb 14, 2014
    • Like Like x 3
    • Thanks! Thanks! x 2
    • Winner Winner x 2
    • Two Thumbs Up Two Thumbs Up x 1
  2. IanE
    Offline

    IanE Member

    Joined:
    Dec 27, 2013
    Messages:
    220
    Likes Received:
    16
    Images don't work for me.
     
  3. Milva
    Online

    Admin Moderator

    Joined:
    Mar 3, 2013
    Messages:
    3,546
    Likes Received:
    389
    Images show for me :) Excellent Tutorial!
     
  4. Ravenwolfe
    Offline

    Moderator ServUO Developer

    Joined:
    Sep 7, 2013
    Messages:
    1,147
    Likes Received:
    123
    I don't see the images either.
     
  5. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    282
    Likes Received:
    32
    Sorry I thought all images were transferred to ServUO server so I used temp links for them. I've fixed the images.

    @Insanity any reason why these weren't copied to ServUO servers?
    Edit: Answered on IRC. Built in feature doesn't work the same, addon will be added back.
     
    #5 Kalamus, Feb 14, 2014
    Last edited: Feb 14, 2014
    • Like Like x 1
  6. Ravenwolfe
    Offline

    Moderator ServUO Developer

    Joined:
    Sep 7, 2013
    Messages:
    1,147
    Likes Received:
    123
    Looks great now, thanks!
     
  7. IanE
    Offline

    IanE Member

    Joined:
    Dec 27, 2013
    Messages:
    220
    Likes Received:
    16
    Looks great now Thanks!
     
  8. Hank
    Offline

    Hank Active Member

    Joined:
    Nov 14, 2013
    Messages:
    972
    Likes Received:
    152
    Excellent work and Thank you so very much for putting this together Kalamus i have no doubts that this will help many people for a long time.
    other then some minor hiccups that were out of Kalamus's control with the images.
     
  9. Praxiiz
    Offline

    Praxiiz Active Member

    Joined:
    Oct 22, 2013
    Messages:
    310
    Likes Received:
    87
    For those of you using the express version of Visual Studio, you will not see the Start External Program option in the Debug Tab under your project:
    ai22.photobucket.com_albums_b347_Praxiiz_debug.png

    As usual, the express version requires addition work to accomplish things that are easily done in the full version of Visual Studio. To enable the Start External Program, you'll need to open up Scripts.csproj in your Scripts folder and make the following edit:

    Under this line
    Code (XML):
    1.  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    Put the following, but make sure you update the path of servUO.exe to match your path!
    Code (XML):
    1.   <StartAction>Program</StartAction>
    2.   <StartProgram>C:\Users\Praxiiz\UltimaLiveTestServers\ServUO2\ServUO.exe</StartProgram>
    3.    <StartArguments>-debug</StartArguments>
    ai22.photobucket.com_albums_b347_Praxiiz_debug2.png
     
    • Like Like x 2
    • Two Thumbs Up Two Thumbs Up x 2
    • Helpful Helpful x 1
  10. Norman Lancaster
    Offline

    Norman Lancaster Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    1,091
    Likes Received:
    108
  11. m309
    Offline

    Admin Moderator ServUO Developer

    Joined:
    Mar 3, 2013
    Messages:
    1,243
    Likes Received:
    130
Similar Threads: Debugging ServUO
Forum Title Date
Custom Releases Xanthos Auction System [ fixed for newer ServUo Repos ] Oct 13, 2017
ServUO Discussion ServUO needs Refactoring and categorizing Aug 25, 2017
ServUO Discussion ServUo Aug 4, 2017
Windows Support Please need help Error SerVUO Aug 3, 2017
Looking For Help Looking for help (bridge servuo<->xenforo) Jul 22, 2017
Windows Support ServUO behind proxy server. Jul 21, 2017
ServUO Discussion Runic reforging updated needed on ServUO Jul 18, 2017