Tutorial: Tracking (manually)
March 26, 2015
VisualBug 1.1 released
April 8, 2015

Tutorial: VisualBug [Manual Usage]

In this tutorial we’ll cover all you need to set up VisualBug in your project. Please check out the prerequirements of VisualBug before you start. VisualBug does not support applications built with a .Net Framework version prior to 4.5. This is due to internal mechanics which are not supported in prior versions. We excuse for this inconvenience. We may fix this in the future.

1. Download & Referencing

First get the latest VisualBug version here . Download it and unzip the package. You will find 4 assemblies in there: VisualBug, VisualBug.BugSpy, VisualBug.BugSpy.WinForm and VisualBug.BugSpy.Wpf. You will only need VisualBug.BugSpy. Add this one to your project references (Select ‘References’ in the solution explorer > Right-Click > Add Reference … > Browse VisualBug.BugSpy.dll [note that there is no Nuget package available at the moment!]) and all other projects which will use VisualBug.

Make sure that there is the VisualBug.BugSpy.WinForm/Wpf-assembly lying in the same directory as VisualBug.BugSpy after compilation! Maybe reference it as well and set ‘Copy Local’ to true. You don’t need both WinForm and WPF. Only the one you’re starting the BugSpy engine with.

2. Initializing the BugSpy tracking engine

After you’ve referenced the VisualBug.BugSpy-assembly you need to implement startup and shutdown for the tracking engine.

WinForm

You should do this in the Program.cs file. Using the example code from the WinForm sample application:

Spy.StartEngine()-call must happen inside the UI-Thread! Else BugSpy will not initialize successfully and throw an exception!

All you need to do is to ensure that Spy.StopEngine() is being called on exit. This ensures that VisualBug can disconnect correctly. Else you will have to restart VisualBug in order to use it again. We will address this issue in the future, but for now just ensure a clean exit and everything will work perfectly fine. In order to start BugSpy you need to call Spy.StartEngine(CompatibilityMode, object). Be aware that only WinForm does require the second parameter. This parameter has to be any instance of System.Windows.Forms.Control. This has to do with WinForm’s synchronization mechanics. In WPF you can use Dispatcher.CheckAccess() in order to check whether an invoke is required.

WPF

You should do this in the App.xaml.cs file. For this use the OnStartup() and OnExit() overrides:

NOTE: This time you won’t need the second argument of Spy.StartEngine(). The WPF dispatcher can be loaded and created from everywhere. The same rule as in WinForm-mode applies, though:

Spy.StartEngine()-call must happen inside the UI-Thread! Else BugSpy will create a new dispatcher for the current thread which does not cause any problems. But once you try to change a value you will encounter an exception because it uses the wrong Dispatcher and thus has no access to the members!

After this step you can already run your application. VisualBug should now connect to your application once both are running.

3. Tokenization

Please read the tutorial about Tokens since this is equally used in both WPF and WinForm. This is optional, though. You don’t need to use Tokens. However, you should read the tutorial about Tokens in order to understand which differences there are and what you have to pay attention to.

4. Tracking

Please read the tutorial about Tracking since this is equally used in both WPF and WinForm.

Zap
Zap
HTML Snippets Powered By : XYZScripts.com