« Is it just me or should the ErrorProvider provide and indexer or a HasErrors property. | Main | Windows 2003 Server used as a workstation vs. Windows XP Professional »

.NET COM Add-In installs but doesn’t run from the IDE

Managed Add-Ins built with Visual Studio .NET use the DLL mscoree.dll to load.

 

Microsoft is aware of a problem affecting some developers where the add-in works fine when built and installed by an add-in setup project, but fails to load when recompiled by the IDE. What drives this behavior is a registry key value that is written with a full path by the installer but without a path by the IDE’s build process.

 

Every add-in class has to have a GUID registered under HKCR\CLSID in the registry. The registration includes an “InprocServer32” key which points to the mscoree.dll.

 

If the value includes a full path, the add-in always loads (all other issues aside). If the value is just “mscoree.dll”, the add-in only works for some people. It is not known at this time by Microsoft what configuration differences cause this behavior.

 

When you get tired of the build, install, run manually, attach debugger cycle, which does work reliably, and wish you could just press F5 and hit your breakpoint, do the following:

 

-         Add a new text file to your solution with the name “FixMscoree.vbs”.

-         Edit the following into the file, replacing the guid with the one your add-in uses:

' Run with project build event: cscript $(SolutionDir)FixMscoree.vbs

Dim wshShell,wshEnv,sPath

 

Set wshShell = CreateObject("Wscript.Shell")

set wshEnv = wshShell.Environment("process")

sPath = wshEnv("SYSTEMROOT")

sPath = sPath & "\System32\mscoree.dll"

 

'guid is of the form {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

wshShell.RegWrite "HKCR\CLSID\{77C3AFCA-8AF6-4b7f-8D7C-657CDB17856E}\InprocServer32\", sPath, "REG_SZ"

 

Set wshEnv = Nothing

Set wshShell = Nothing

-         Set ProjectàPropertiesàBuild EventsàPost-build Event Command Line to “cscript $(SolutionDir)FixMscoree.vbs

 

To the best of my knowledge there are no relevant knowledgebase articles on this problem yet. If you know of one, please post or send the reference.

 

Comments

Great thanks - works a treat!

I'd add to your "only works for some people" that mine worked fine for hundreds of runs of a project and then just stopped working for no apparent reason between one run and the next. Same user, same machine, same session, same project, no new software installed, no config changes made...

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)