我正在尝试在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程序集引用了错误的版本号?
答案 0 :(得分:3)
我遇到了这个问题,我最终解决了这个问题。我在64位服务器上引用了x86程序集。我将引用的程序集重建为Any CPU,安装在服务器上,重新添加对项目的引用,将项目重建为Any CPU,然后然后 SQL Server可以解析引用并安装程序集
“您正在引用为错误平台构建的程序集”这样的消息会非常有用:)
答案 1 :(得分:3)
如果您正在运行x64 SQL Server,请检查您的项目是否构建到Any CPU平台的目标。我遇到了同样的问题并制作了下表;
A1参考组件; A2参考。
A1 \ A2 x86 x64 Any CPU
x86 X V X
x64 V V V
Any CPU V V V