RegAsm regfile 开关没有提供与代码库开关相同的输出
好吧,我知道这是非常具体的,但我为此浪费了整个工作日,所以我真的需要一些合理的解释,这样我的老板和我的妻子就不会解雇我
根据 MSDN :/regfile
开关“为程序集生成指定的 .reg 文件”/codebase
开关“在注册表中创建一个代码库条目,指定程序集的文件路径”
我猜测这是执行相同操作的两种不同方法。事实是,我错了:
方法 1
C:\>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "C:\SERVER.dll" /regfile
Registry script 'C:\SERVER.reg' generated successfully
Reg 文件输出:
REGEDIT4
[HKEY_CLASSES_ROOT\xfeed.server.X]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\xfeed.server.X\CLSID]
@="{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32\1.0.0.0]
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\ProgId]
@="xfeed.server.X"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories\ {62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
方法 2
但是当我直接执行代码库切换命令而不是使用 reg 文件时, 注册表中受影响的键不同(并且有效,与前面的输出相反)
C:\>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "C:\SERVER.dll" /codebase
Types registered successfully
注册表输出与代码库:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/SERVER.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32\1.0.0.0]
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/SERVER.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\ProgId]
@="xfeed.server.X"
正如您所注意到的,内容现在位于 Wow6432Node 中,并且信息更加全面(尤其是 CodeBase !!!)
如果有人能给我一个合理的理由,那么我可以避免提及超自然活动,因为一个工作日损失的原因,我将非常感激
Ok, I know this is pretty specific, but I lost my whole working day on it so I really need some rational explanation to it, so my boss and my wife wouldn't fire me
According to MSDN :
The /regfile
switch "Generates the specified .reg file for the assembly"
The /codebase
switch "Creates a Codebase entry in the registry specifiying the file path for an assembly"
I guessed that it was 2 different ways of doing the same stuff. Truth was, I was wrong :
METHOD 1
C:\>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "C:\SERVER.dll" /regfile
Registry script 'C:\SERVER.reg' generated successfully
Reg File output :
REGEDIT4
[HKEY_CLASSES_ROOT\xfeed.server.X]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\xfeed.server.X\CLSID]
@="{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32\1.0.0.0]
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\ProgId]
@="xfeed.server.X"
[HKEY_CLASSES_ROOT\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories\ {62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
METHOD 2
But when I execute the codebase switch command directly rather that using the reg file,
the keys impacted in the regsitry are different (and work, on the contrary of the preceding output)
C:\>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "C:\SERVER.dll" /codebase
Types registered successfully
Registry ouptut with codebase :
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}]
@="SERVER.XLS"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/SERVER.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\InprocServer32\1.0.0.0]
"Class"="SERVER.XLS"
"Assembly"="SERVER, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e3de07ee666a5f5"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/SERVER.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{8F4A5B5E-8DD7-30A3-993F-18C7E2C457CF}\ProgId]
@="xfeed.server.X"
As you can notice, stuff is now in the Wow6432Node and infos are much more comprehensive (notably CodeBase !!!)
If anyone could give me a rational reason to this, so I could avoid mentioning paranormal activity as a cause for a lost working day, I would be very grateful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
codebase 标志告诉 regasm 您想要使用对文件实际位置的引用来注册 DLL。如果您有一个 dll 与已部署的应用程序一起存储并且您不希望将其存储在 GAC 中,那么这会非常有用。如果不使用此标志,您必须将 DLL 放入 GAC 中才能获得其完整功能。
regfile 标志告诉 regasm 您想要输出注册表文件而不是实际注册 dll。
如果您希望注册表文件输出还包含除注册表之外的 dll 位置的数据,并且我认为您假设这是一种非此即彼的情况,那么可以将它们一起使用。
编辑:根据您的评论进一步解释。
RegAsm 通常会注册有关 .dll 的基本信息,因为假设它将被加载到 GAC 中。 GAC 中的任何内容都以允许系统控制程序集并将其加载到内存的方式进行注册。当您在 32 位系统上并使用 codebase 标志时,它几乎直接将“codebase”值键添加到定义程序集的注册表项中,然后将其值设置为 .dll 物理所在的路径。
当以这种方式注册时,它基本上告诉计算机和任何想要使用程序集的东西在哪里可以找到代码,以及如何将其加载到内存中。有时,这会导致超出 GAC 所需的额外密钥,以便调用进程知道访问程序集的最佳方式。
现在,由于您使用的是 64 位系统,因此您面临着额外的挑战。有一些规则可以在整个计算机中保持 32 位和 64 位应用程序的分离。这就是为什么有 2 个程序文件夹,以及注册表有 wow32 部分的原因。如果注册了 32 位 dll,则在使用 /codebase 标志完成后,需要将其存储在注册表的此部分中,以便 32 位应用程序可以找到它(这是它们有权访问的注册表的唯一部分) )。如果它是 64 位 dll,则不需要位于注册表的这一部分中。
现在,由于这些信息,如果您使用文件的输出来编写安装程序的注册表脚本部分,您将需要检查目标计算机以确定该信息是否需要位于 users wow 部分,或者正常注册表部分,并在运行此脚本之前对其进行适当的更改。
The codebase flag tells regasm that you want to register a DLL with a reference to the actual location of the file. This is useful if you have a dll being stored with a deployed application and you dont want it in the GAC. Without using this flag you must put your DLL in the GAC for its full functionality.
The regfile flag tells regasm that you want to output a registry file INSTEAD of actually registering the dll.
These can be used together if you want a registry file output that also contains the data for a dll location other than the registry, and I think you were assuming it was an either-or situation.
EDIT: Further explanation based on your Comment.
RegAsm normally registers the basic information about a .dll because the assumption is that it will be loaded into the GAC. Anything in the GAC is registered in a way that allows the system to control and load the assembly into memory. When you are on a 32bit system and use the codebase flag, it almost directly adds the "codebase" valuekey to the registry keys where the assembly is defined, then sets the value of this to the path where the .dll is physically located.
When registered this way, it basically tells the computer and anything looking to use the assembly where it can find the code, and how to load it into memory. Sometimes this causes extra keys beyond what the GAC would need so that a calling process knows the best way to access the assembly.
Now, since you are on a 64 bit system, you face an additional challenge. There are rules in place for keeping 32-bit and 64-bit applications separated throughout the computer. That is why there is 2 program files folders, and why the registry has the wow32 section. If a 32 bit dll gets registered, it needs to be stored in this section of the registry when it is done with the /codebase flag so that 32 bit applications can find it (this is the only part of the registry that they have access to). If it was a 64 bit dll, it would not need to be in this part of the registry.
Now, because of this information, if you are using the output of the file to write a registry script portion of an installer, you will want to check the target machine to determine whether the information needs to be in the users wow section, or normal section of registry, and make the appropriate change to this script before running it.