SQL Server“版本、区域性或公钥不匹配”在“创建程序集”期间加载使用 sgen 实用程序创建的 XMLSerializer 时

发布于 2024-09-12 15:27:49 字数 1583 浏览 11 评论 0原文

我正在尝试在 SQLServer 中创建一个调用 Web 服务的 CLR 函数。当我创建第一个程序集时,AssemblyInfo.cs 中的 AssemblyVersion 是 1.0.*。我将运行 sgen 来创建随附的 XMLSerializers 程序集,并且我没有看到任何问题。

>"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\sgen.exe" /force /assembly:Ra
elen.DemoCLRFunction.dll
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Serialization Assembly Name: Raelen.DemoCLRFunction.XmlSerializers, Version=1.0.
3868.13304, Culture=neutral, PublicKeyToken=null.
Generated serialization assembly for assembly C:\dev\freight-workspace\Raelen.De
moCLRFunction\Raelen.DemoCLRFunction\bin\Debug\Raelen.DemoCLRFunction.dll --> 'C
:\dev\freight-workspace\Raelen.DemoCLRFunction\Raelen.DemoCLRFunction\bin\Debug\
Raelen.DemoCLRFunction.XmlSerializers.dll'.

在 SQLServer 中,第一个程序集加载正常,但在尝试加载 XMLSerializers 程序集时出现以下错误:

Msg 10300, Level 16, State 2, Line 7
Assembly 'Raelen.DemoCLRFunction.XmlSerializers' references assembly 
'raelen.democlrfunction, version=0.0.0.0, culture=neutral, publickeytoken=null.',
which is not present in the current database. SQL Server attempted to locate and
automatically load the referenced assembly from the same location where 
referring assembly came from, but that operation has failed (reason: version, 
culture or public key mismatch). Please load the referenced assembly into the 
current database and retry your request.

我无法弄清楚为什么它试图引用版本 0.0.0.0。这确实是错误的原因吗?如果是,为什么 XMLSerializers 程序集引用了错误的版本号?

I'm trying to create a CLR function in SQLServer that calls a web service. When I create the first assembly, the AssemblyVersion in AssemblyInfo.cs is 1.0.*. I'll run sgen to create the accompanying XMLSerializers assembly, and I don't see any problems there.

>"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\sgen.exe" /force /assembly:Ra
elen.DemoCLRFunction.dll
Microsoft (R) Xml Serialization support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.3038]
Copyright (C) Microsoft Corporation. All rights reserved.
Serialization Assembly Name: Raelen.DemoCLRFunction.XmlSerializers, Version=1.0.
3868.13304, Culture=neutral, PublicKeyToken=null.
Generated serialization assembly for assembly C:\dev\freight-workspace\Raelen.De
moCLRFunction\Raelen.DemoCLRFunction\bin\Debug\Raelen.DemoCLRFunction.dll --> 'C
:\dev\freight-workspace\Raelen.DemoCLRFunction\Raelen.DemoCLRFunction\bin\Debug\
Raelen.DemoCLRFunction.XmlSerializers.dll'.

In SQLServer, the first assembly loads fine, but I'm getting the following error trying to load the XMLSerializers assembly:

Msg 10300, Level 16, State 2, Line 7
Assembly 'Raelen.DemoCLRFunction.XmlSerializers' references assembly 
'raelen.democlrfunction, version=0.0.0.0, culture=neutral, publickeytoken=null.',
which is not present in the current database. SQL Server attempted to locate and
automatically load the referenced assembly from the same location where 
referring assembly came from, but that operation has failed (reason: version, 
culture or public key mismatch). Please load the referenced assembly into the 
current database and retry your request.

I can't figure out why it's trying to reference version 0.0.0.0. Is that indeed the cause of the error, and if so, why is the XMLSerializers assembly referencing the wrong version number?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝眼睛不忧郁 2024-09-19 15:27:49

我遇到了这个问题,最终我解决了。我正在引用 64 位服务器上的 x86 程序集。我将引用的程序集重建为任何 CPU,安装在服务器上,重新添加对项目的引用,将我的项目重建为任何 CPU,然后 SQL Server 可以解析引用并安装程序集。

类似“您正在引用为错误平台构建的程序集”的消息会非常有用:)

I had this problem and I eventually worked it out. I was referencing an x86 assembly on a 64 bit server. I rebuilt the referenced assembly as Any CPU, installed in on the server, re-added the reference to the project, rebuilt my project as Any CPU, and then SQL Server could resolve the reference and install the assembly.

A message along the lines of "You're referencing an assembly that's built for the wrong platform" would have been rather useful :)

手长情犹 2024-09-19 15:27:49

如果您运行的是 x64 SQL Server,请检查您的项目构建目标是否为任何 CPU 平台。我也遇到了同样的问题,做了下表;

A1 引用的程序集; A2 参考文献。

A1 \ A2   x86   x64   Any CPU
x86        X     V     X
x64        V     V     V
Any CPU    V     V     V

If you are running x64 SQL server check if your project build target to the Any CPU platform. I have encountered the same problem and made the following table;

A1 the referenced assembly; A2 references.

A1 \ A2   x86   x64   Any CPU
x86        X     V     X
x64        V     V     V
Any CPU    V     V     V
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文