Share via


Best Practices and Troubleshooting

 

Applies To: Windows Server 2012 Essentials, Windows Home Server 2011, Windows Storage Server 2008 R2 Essentials, Windows Small Business Server 2011 Essentials

When running tasks that need to prompt the user for information, it is recommended that you build Windows Forms based wizards and property pages. It is possible to launch the user interface for your add-in directly from a task. You should not perform workloads in your add-in that could block the user interface.

Thread Safety

It is critical that your add-in be thread safe. To that end, you should be familiar with the proper usage of the following methods and use them when necessary in your Windows Forms code:

A common practice is to call InvokeRequired to verify if BeginInvoke is necessary. For more information about thread safety, see How to: Make Thread-Safe Calls to Windows Forms Controls (https://go.microsoft.com/fwlink/?LinkId=178748).

Because collections are unpredictably changed, you may see the following exception when using the ReadOnlyObservableCollection API:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

To avoid this problem, a good practice is to use the ThreadSafeReadOnlyObservableCollection API.

Troubleshooting

If your add-in does not load, you should look in %ProgramData%\Microsoft\Windows Server\Logs\Dashboard.log and search for pluginmanager. The most common error will be “Invalid Plugin File”, which usually means that you have a missing dependency or a compilation problem with your assembly. The way to diagnose these problems is to use a reflection tool to ensure that it can find all of your assembly dependencies, and that the resources are correctly embedded.

If you do not see your assembly type name in the log, then your .addin file is not in the correct format. Verify that your .addin file is in the correct format. You should also make sure that your assembly and all of its dependencies are in the bin directory (or in the GAC for system dependencies like System.Drawing).