SQLCLR调用WEBService的问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:25:14
我现在手头有个功能,就是先做Excel处理,比如前10行删除(标题,不规则的),剩下的就是标准的table可以SELECT了,以前用程序做,但是现在希望让CLR自己来做,这样Agent自己就可以做了,全部无人自动化。RPT文件转换Excel也是功能之一.
不过,因为处理Excel需要把Office程序集引用到SQL里,这样就有可能会出现需要引用很多dll的情况,最坏就是把.net的CLR全引用进来,或者互相依赖,引用不进来,已经碰到了.
所以转换下想从Web Service来实现.不过最终出错了.
在执行用户定义例程或聚合 "Ws_ChangeRpt" 期间出现 .NET Framework 错误:
System.InvalidOperationException: Cannot load dynamically generated serialization assembly. In some hosting environments assembly load functionality is restricted, consider using pre-generated serializer. Please see inner exception for more information. ---> System.IO.FileLoadException: LoadFrom()、LoadFile()、Load(byte[]) 和 LoadModule() 已被主机禁用。
这个好像是序列化的问题吗?我在网上搜了好多,只有微软的一篇机器翻译的文章有提到.但是才疏学浅,实在理解不了.
请问达人能不能指引下方向,或者您有什么高级的解决方案.小弟感激不尽啊.

When the CLR loads an assembly, the CLR verifies that the same assembly is in the GAC. If the same assembly is in the GAC, the CLR verifies that the Module Version IDs (MVIDs) of these assemblies match. If the MVIDs of these assemblies do not match, you receive the error message that the "Symptoms" section mentions.

When an assembly is recompiled, the MVID of the assembly changes. Therefore, if you update the .NET Framework, the .NET Framework assemblies have different MVIDs because those assemblies are recompiled. Additionally, if you update your own assembly, the assembly is recompiled. Therefore, the assembly also has a different MVID.

MS说这个主要是因为.net framework的更新造成了assemblies会重新编译,生成新的MVIDs;即使你不更新Framework,而是更新自己的assembly,MVID也会改变.所以造成了你的问题.

MS说可以在你的数据库里面用ALTER ASSEMBLY 语句去修改程序集.例如,ALTER ASSEMBLY ComplexNumber FROM 'C:\Program Files\Microsoft SQL Server\90\Tools\Samples\1033\Engine\Programmability\