问题
I have a COM visible dll suitable for 32 and 64 bit architechtures that I use to add a menu item to the windows explorer context menu. Using "regasm myassembly.dll /codebase" I register the dll and see the new menu item. Great. Unregistering works fine also.
Now I want to create a .reg file so I can add the menu item to non development machines. I use "regasm myassembly.dll /codebase /regfile" that produces a reg file that I can import with regedit. The problem is, after importing the .reg, I cannot see the menu icon. Why might the registration have failed? Note I am on a 64 bit system.
回答1:
Registering a shell extension requires writing more registry keys than normally required to register a [ComVisible]
.NET assembly.
You also have to write the keys that Explorer reads to discover extensions.
You didn't mention at all how you took care of that, this normally requires a custom [ComRegisterFunction]
. But sure, the .reg file isn't going to contain those keys since a custom registration function requires running code.
回答2:
You should know that this is a really, really, bad idea. Please read this classic post on the subject.
http://blogs.msdn.com/b/oldnewthing/archive/2006/12/18/1317290.aspx
Then this recent update:
http://blogs.msdn.com/b/oldnewthing/archive/2013/02/22/10396079.aspx
Even if you insisted on trying this (or if the assembly was intended for something other that an Add-in), it's still a bad idea to try to use a .reg file to register the assembly.
There is a lot more that would need to happen besides the COM registration for the assembly to work. Most likely you would have to add it to the GAC so that .NET can find it. Also, a future version of .NET might require more information, or different information, to be added on the registry. Even today (I suspect), REGASM might need to put different information on different environments (x86 vs. x64).
来源:https://stackoverflow.com/questions/15834410/regasm-codebase-works-but-file-generated-with-regasm-codebase-regfile-does-no