无法获取 StrongNameKeyPair 的公钥
我已将开发移植到另一台计算机,如果我运行项目,则会出现以下异常:
无法获取 StrongNameKeyPair 的公钥。
HibernateException:创建代理实例失败
在原始计算机上它可以正常工作,没有问题。
我在谷歌上发现一些加密存在问题,我应该尝试“sn -m n”,但我不知道如何。 sn.exe 位于更多文件夹中,我尝试从命令行运行一些,但它写道:
无法打开注册表项 -- 无法格式化错误消息 00000005
我不知道问题是否是因为 NHibernate,还有更多类似的对话框,并且仅在一种情况下抛出此异常。
有部分代码会抛出异常:
public IList<DTO> GetAll(GridSortOptions sortOptions, DTOListModel<DTO> listModel)
{
return GetAllCriteria(sortOptions, CreateCriteria(), listModel).List<DTO>();
}
解决方案中没有一个项目使用签名。 我不明白这个错误到底意味着什么以及我应该寻找什么。
I have ported developing to another computer and if i run project, i have this exception:
Unable to obtain public key for StrongNameKeyPair.
HibernateException: Creating a proxy instance failed
On original computer it works OK without problems.
I found on google that it is problem with some crypting and I should try "sn -m n", by I don't know how. sn.exe is in more folders, i tryed some run from command line but it writes:
Failed to open registry key -- Unable to format error message 00000005
I don't know if problem is because NHibernate or not, there are more similar whitch dialogs and it throw this exception only in one case.
there is part of code whitch throw exception:
public IList<DTO> GetAll(GridSortOptions sortOptions, DTOListModel<DTO> listModel)
{
return GetAllCriteria(sortOptions, CreateCriteria(), listModel).List<DTO>();
}
No one project from solution use signing.
I don't understand what exactly this errors means and what i should look for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
NHibernate 正在动态创建 .NET 程序集(动态代理)并需要对它们进行签名。默认情况下,Windows 操作系统将加密密钥存储配置为计算机级别,并将密钥存储在 C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys 中。您的用户很可能可以在此文件夹中创建(例如)文本文件,但不能删除它,因为您没有完全控制权。
您的选项是
通过修改可能不建议的权限来完全控制 C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys。
通过运行 Windows SDK 中的“sn.exe -m n”将加密密钥存储更改为用户级别。 http://msdn.microsoft.com/en- us/library/k5b5tt23(v=VS.90).aspx 这会将加密密钥存储放在您的用户本地配置文件下,您应该始终对其拥有完全控制权。
网上有几篇文章描述了类似的问题。例如,请参阅 http://support.targetprocess.com/Default.aspx ?g=posts&t=305。
NHibernate is dynamically creating .NET assemblies (dynaic proxies) and needs to sign them. By default the Windows OS configures the crypto key storage to be machine level and stores the keys in C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys. Most likely your user can create (for example) a text file in this folder, but not delete it because you do not have full control.
Your options are
Get full control of C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys by modifying permissions which might not be recommended.
Change your crypto key storage to user level by running the "sn.exe -m n" from the Windows SDK. http://msdn.microsoft.com/en-us/library/k5b5tt23(v=VS.90).aspx This will put crypto key stores under under your users local profile which you should always have full contorl to.
There are several articles online that describe a similar problem. For example, see http://support.targetprocess.com/Default.aspx?g=posts&t=305.
今天在不同的用例(在 W2008R2 机器上运行的 .NET 服务)中遇到了类似的问题,但出现了完全相同的错误。
使用 procmon,我将其追溯到 C:/ProgramData/Microsoft/Crypto/RSA/MachineKeys 中的密钥写入失败。
按照此处所述的指南添加对文件夹具有特殊权限的所有人解决了问题:http://toastergremlin.com /?p=432
另外,请确保添加 EVERYONE @ 本地计算机,而不是 EVERYONE @ 您的域!
Had a similar issue today with a different use case (a .NET service running on a W2008R2 box) but exactly the same error.
Using procmon I traced it back to a failed write on a key in C:/ProgramData/Microsoft/Crypto/RSA/MachineKeys.
Following the guidance to add EVERYONE with special permissions on the folder as noted here fixed the problem: http://toastergremlin.com/?p=432
Also, make sure you add EVERYONE @ local machine and not EVERYONE @ your domain!
对于遇到此问题的其他人来说,我在物理机器上也遇到了同样的例外。一夜之间什么都没有改变,但这个异常从早上开始出现。
结果是磁盘空间不足的问题,动态代理程序集无法写入磁盘。只是意识到这一点是因为我碰巧注意到 Windows“磁盘空间不足”图标短暂出现。 :-P
清除一堆(大)临时文件使问题消失。
For anyone else who comes across this, I just had the same exception, on a physical machine. Nothing changed overnight, but this exception started presenting in the morning.
Turned out to be low disk space issue, and the dynamic proxy assemblies couldn't be written to disk. Only realised this because I happened to notice the Windows 'low disk space' icon when it appeared briefly. :-P
Clearing out a bunch of (big) temp files made the problem go away.
我今天遇到了同样的问题,并且不喜欢所提供的解决方案。它们是:
下面可能是一个肮脏的黑客,但它工作得很好,我不需要向 IT 解释为什么我希望所有最终用户计算机重新配置。
只需确保在生成第一个代理之前在程序的最开始调用此方法即可。
我想真正的解决方案是升级到 NHibernate 3.3,它应该不再有这个问题,但现在这不是一个选择。
I had the same issue today and didn't like the provided solutions. These were:
The following may be a dirty hack but it works quite well and I don't have to explain to IT why I want all of the end users computers reconfigured.
Just make sure you call this method at the very beginning of your program before the first proxy is generated.
I guess the real solution would be to upgrade to NHibernate 3.3 which suppesdly doesn't have this problem anymore, but that's not an option right now.