Visual Studio custom tool for code generation… how do I find out what's going wrong?

冷暖自知 提交于 2019-12-04 07:15:24

I ran into this issue with a custom-tool that I wrote yesterday. Extremely frustrating. The reg file was correct, the custom-tool ran perfectly in the Experimental Hive. But it simply refused to run in regular VisualStudio.

I'm guessing that VisualStudio reads the registry and then caches pieces of the registry somewhere.

Executing the following appear to reset this cache

devenv /setup

After executing this, my custom-tool worked perfectly.

To debug:

Run Process Monitor to reverse engineer the VS2010/COM/.NET/Fusion assembly-loading nightmare, looking at what registry entries of yours VS picks and which ones it tries to find but fails with NOTFOUND on.

To hopefully fix without having to debug:

Option 1:

Add a binding path:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\BindingPaths\<A new GUID>]
"<Path the the folder containing your DLL>"=""

Option 2:

I'm not sure about this, but I think you could create a proper VS2010 package (instructions), which will take care of registering the executable file locations.

For both options, neither gacutil, tlbexp, nor regasm is required. VS2010 does its own thing when finding DLLs.

Perhaps too late but: Writing a custom tool in VS.NET
You might have skipped one of these steps:

Register your Generator for COM interop

You have to generate a GUID and use tlbexp.exe and regasm.exe. I assume you have to use these tools instead of putting the generator in the GAC.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!