Aktive login: Gæst  Log ind

Vælg site:

Henriks Wiki

RSS RSS

Menu


Funktioner




Søgefunktion

Søg
»

Seneste ændringer


Drives med

This site is povered by
I have been writing a ScrewTurn plugin and have had my problem debugging it.

I read the ScrewTurn articles on debugging plugins, and find it annoying to include my code in the ST core just to be able to debug my code.

I worked a bit with an alternative setup, and found this alternative method I would like to share. It involves three steps

  • Include the plugin project in the Screwturn solution.
  • Create a post build event in the plugin project.
  • Fix one line of code in the screwturn source, that will not affect the use of screwturn at all.

This method og debugging, separates the screwturn code completely from the plugin code. The method doesn't alter how ScrewTurn works at all. You can add new and remove finished plugin projects as you wish without changing a line of ScrewTurn code.

You can even update the ScrewTurns sourcecode, either with a fresh set of sources, or by adding minor updates, just remember to keep the assembly loader to load the pdb files also, as described below.

What I have done is

1) I have a folder with the screwturn code, where the ST solution file also exists. At some other folder I have a plugin project that references the ST pluginframework code. I have also added my plugin project to the screwturn solutiuon. There is no need to move the plugin project to the screwturn solution path.

2) In my plugin project properties page, I have create a post build event, that copies the result (binaries) of my plugin project into the correct locations of the screwturn website. This post build event code is generic, since it references the plugins path with $(Target*) and the ST solution with $(SolutionDir) so it doesn't matter how these are placed, for you to use this exact code without changes.


copy /Y "$(TargetPath)" "$(SolutionDir)WebApplication\public\Plugins"
copy /Y "$(TargetDir)$(TargetName).pdb" "$(SolutionDir)WebApplication\public\Plugins"

3) I then changed one ST core code line to load the PDB file also, as shown below:

from:

asm = Assembly.Load(LoadAssemblyFromProvider(Path.GetFileName(assembly)));

to:

asm = Assembly.Load(
         LoadAssemblyFromProvider(Path.GetFileName(assembly)), 
         LoadAssemblyFromProvider(Path.GetFileNameWithoutExtension(assembly)+".pdb")
      );

The line is located in the core project in the file ProviderLoader a few lines down in method LoadFrom, that is exactly in line number 242 for ST version 3.0.3.555.

Maybe this minor change could be implemented permanently by the core developers, in the debug version of ScrewTurn.

This method of debugging make a nice separation between the plugin code and the screwturn code. I hope this may be a help to others to easier debug plugins.
Dette system vedligeholdes af Henrik K. Larsen, Se www.bitfix.dk