Debugging a Plugin

What do I need?

To debug your own Plugin, you will need to run the VastPark Player under debug mode in Visual Studio.
There is a sample client solution archive at http://vp.src.s3.amazonaws.com/public_trunk.zip.

We recommend you use VS2010 with the Sample.Client.Legacy solution. The express version is available to download for free here : http://www.microsoft.com/express/downloads/.

When you have the Sample.Client.Legacy solution open in VS2010, add your Plugin project to the solution. This is to make sure that it recognizes the plugin's dlls with the source code.

Unpublished Plugin

One can run their own plugin on the Sample.Client VastPark Player without publishing.

This is done by making a zip file that contains the plugin's dlls and a file named blueprint.xml that allows the PluginManager know what files it needs to load.

Make sure to include any other dlls that your plugin needs in the blueprint and place the dlls in the zip file.

Then point to where the zip is located in your file system in the Imml Source.

An example is:

<Plugin Name="MyPlugin" Enabled="True" Source="D:\MyPlugin\bin\Debug\Myplugin.zip” />

Make sure that you update the dlls every time you rebuild your plugin.

You should now be able to run and step through your plugin.

Already Published Plugin

In the Solution Explorer, expand the Platform folder, and then Legacy, and go to the VastPark.Plugin project. Open the PluginManger.cs file for editing.

Scroll down to the method with this signature:

private void _Load(VastPark.Imml.Scene.Controls.Plugin immlPlugin, Blueprint blueprint, Dictionary<string, MemoryStream> streams, IParkEngine parkEngine)

We will insert the following code under the line - string pluginDir = _PluginDirectory;

#if DEBUG
            bool usingDebug = false;
            if(blueprint.Source.Contains("MyPlugin.dll"))
            {
                pluginDir = @"D:\MyPlugin\bin\Debug\”;
                usingDebug = true;
            }
#endif 

This bit of code tells the VastPark Player to use your local Debug version of your Plugin rather than getting the published one via metaforik. Substitute “MyPlugin.dll” with the name of the file specified in the Plugin Source attribute in your blueprint.xml. The string pluginDir is set to the output directory of your Plugin when built in Debug mode.

Recompile the VastPark.Plugin project, run the client and you should now be able to step through your Plugin code.

This then allows you to run your plugin locally without needing to re-publish it every single time.

Frequently Asked Questions:

1) Can I use the method for running unpublished plugins on the normal VastPark Player as well?

Yes you can, it just won't be able to debug like the VastPark Player inside Visual Studio. Remember to link to the .zip file, it will not work if you link to the .dll file.

2) Does the name of the plugin in the project have to be the same as the <Plugin> element in the IMML?

No it does not. You have to give it a name in the IMML though, or it won't run.