Posts
18
Comments
10
Trackbacks
0
Visual Studio 2008 closes at build, Outlook 2007 Add-In
I am currently working on a Microsoft Outlook Add-in component to the group of applications that happily live on my back. I was given a sample application by the BA that was meant to be a basic mock that I now need to neaten up and flesh out.
Yet for the life of me I was unable to get this project to run without it pulling down Visual Studio in the process. Many hours of searching and found an answer that for the moment is working. So I decided to replicate the information here on my site in the hopes that it will be easier to find for the next person looking for help.

The Back story:

  • 1. Open Microsoft Visual Studio 2008 Team Edition running .Net 3.5 SP 1
  • 2. Create a new Office 2007 Add-In (File > New Project > Visual C# > Office > 2007 > Outlook 2007 Add-In)
  • 3. Choose a Name for your project and select OK.
  • 4. Select Build or Run or press F5
  • 5. BOOM (well not so much a boom as a *poof*). Visual Studio is gone. You are back on the desktop and you don’t even get to tell Microsoft about it!
  • 6. Check the event view and we find a nice error that looks like this: .NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error

The Real Problem:

I finally found a solution here.

This is not a PowerCommands issue but rather a problem with the CLR itself where this problem manifests if assemblies are loaded in a certain order.

Installing PowerCommands and then creating a new Outlook 2007 project causes assemblies to get loaded in a way that this problem surfaces.

Looking at the source code for PowerCommands, we see a Reference to System.Core.dll. Attaching a debugger to the VS2008 IDE, we see the following being logged just before the crash: CLR: (C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Office.Runtime.v9.0\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Tools.Office.Runtime.v9.0.dll) Rejecting native image because dependency C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll is not native

This is supposed to be fixed for the next version of the CLR.

The Solution:

  • 1. Uninstall PowerCommands.
  • 2. Remove the native image cache of the VSTO DLL (per the workaround instructions).

Removing the native image cache:

Delete the native image generated for VSTO.

To do this, open a command prompt, navigate to the directory below, and enter the text indicated below in that directory to initiate the deletion.

This removes the Native Image Cache of the VSTO DLL. It does not delete the VSTO DLL.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>ngen /delete Microsoft.VisualStudio.Tools.Office.Runtime.v9.0

The main copy of the VSTO DLL will remain untouched, so no functionality is lost, there may be a small performance penalty. Neither the engineer nor I noticed a performance hit.

To re-install the VSTO DLL into the cache, run the NGEN command on the DLL. For example, here is the command to re-install. Note, you need to be in the same folder as the DLL.

ngen Microsoft.VisualStudio.Tools.Office.Runtime.v9.0.dll
posted on Wednesday, November 26, 2008 11:41 AM Print
News