我有一个.NET程序集,应该为32 b和64 b COM互操作注册。我们的安装脚本成功地注册了这个程序集,一切都按预期工作。
我们希望我们的卸载脚本完全删除安装脚本中的注册,但我无法做到这一点。一些注册表项总是保留。
我设置了一个可重现的测试用例:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /codebase /tlb
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /codebase /tlb
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /u /tlb
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /u /tlb
如您所见,这为32 b和64 b注册了库(使用了Framework
和Framework64
目录),并导出和注册了类型库(/tlb
参数)。
注销库(.dll和.tlb文件)也是如此。
完整输出为
C:\>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /codebase /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types registered successfully
Assembly exported to 'C:\Path\To\MyLibrary.tlb', and the type library was registered successfully
C:\>C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll"
/codebase /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types registered successfully
Assembly exported to 'C:\Path\To\MyLibrary.tlb', and the type library was registered successfully
C:\>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll" /u /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types un-registered successfully
Type library 'C:\Path\To\MyLibrary.tlb' un-registered successfully
C:\>C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\regasm.exe "C:\Path\To\MyLibrary.dll"
/u /tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
Copyright (C) Microsoft Corporation. All rights reserved.
Types un-registered successfully
Type library 'C:\Path\To\MyLibrary.tlb' un-registered successfully
PS C:\>
请注意,在这两种情况下,输出都提到类型库已成功注销。
但是,如果我查看注册表,我会看到HKEY_CLASSES_ROOT\TypeLib\{E9E332B2-... snip ... -E6B627A4642E}\1.0\0\win32
处的类型库残余
如果我注解掉32 b xor 64 b registration/unregistration语句,那么注册表将回到原始状态,没有任何残余,只有当我同时注册/取消注册32 b和64 b时,才有残余,尽管输出声称已经取消注册了所有内容。
我怀疑这是一个regasm bug,但我会等待社区的反馈。
1条答案
按热度按时间tp5buhyn1#
我已经很晚了,但是如果其他人也遇到了同样的问题,我希望这个答案能有所帮助。
为了完全删除库和它的typelib,您需要用途: