执行 CLR 存储过程来运行 Cognos Report 时出现 System.IO.FileNotFoundException
早上好。我当前遇到一个 CLR 存储过程调用在 Visual Basic (VS 2008) 中创建的程序集的问题。在最高级别,程序集执行 Cognos8 中包含的报告并将输出移动到网络上的特定目录。从简单的测试 EXE 调用该方法时没有问题,但当我尝试通过 CLR 存储过程执行时,我收到以下信息:
Msg 6522,Level 16,State 1,Procedure ReportRunner,Line 0
A .NET Framework执行用户定义例程或聚合“ReportRunner”期间发生错误:
System.IO.FileNotFoundException:无法加载文件或程序集“cognosdotnet assembly_2_0” Version=10.1.4707.501、Culture=neutral、PublicKeyToken=d6e6d7d808b7e5b7' 或其依赖项之一。系统找不到指定的文件。 System.IO.FileNotFoundException:
在 System.Reflection.Assembly._nLoad(AssemblyName fileName、String codeBase、Evidence assemblySecurity、Assembly locationHint、StackCrawlMark& stackMark、Boolean throwOnFileNotFound、Boolean forIntrospection)
在 System.Reflection.Assembly.nLoad(AssemblyName fileName、String )代码库、证据组装安全性、组装位置提示、 StackCrawlMark& stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection)
在 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,证据 assemblySecurity,StackCrawlMark& stackMark,布尔 forIntrospection)
在 System.Reflection.Assembly.LoadWithPartialNameInternal(字符串partialName,证据 securityEvidence, StackCrawlMark&stackMark)
在 System.Reflection.Assembly.LoadWithPartialName(StringpartialName, Evidence securityEvidence)
在 System.Xml.Serialization.TempAssembly.LoadGenerateAssembly(Type type, String defaultNamespace, XmlSerializerImplementation&contract)
在 System.Xml.Serialization.XmlSerializer.FromMappings (XmlMapping[]映射、类型类型) 在 System.Web.Services.Protocols.SoapClientType..ctor(类型类型)
在 System.Web.Services.Protocols.SoapHttpClientProtocol..ctor() 在 cognosdotnet_2_0.reportService1..ctor()
在 ReportRunnerv3.ReportRunner.ExecuteReport(Int32 inPLAN_ID、Int32 inContract_Sfx、字符串 inRptDate_DT、字符串 inPlanType、字符串 inInvstmentOnlyInd、字符串 inMOMInd、字符串 inGPSIInd、字符串 inPBTInd、字符串 inPICAInd、字符串 inClientAccomInd、字符串inInstSelectInd、String inRptType、Int32&outRC
) •cognosdotnet assembly_2_0 与“ReportRunner”程序集位于同一目录中 •cognosdotnet assembly_2_0 使用 CREATE ASSEMBLY 进行编目,权限集 = 不安全 •cognosdotnet assembly_2_0 也安装在GAC 中
以下是fuslogvw.exe 提供的消息:
* 程序集绑定器日志条目 (8/11/2011 @ 5:57:39 AM) *
操作失败。
绑定结果:hr = 0x80070002。系统找不到指定的文件。
程序集管理器加载自:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
在可执行文件 c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn\sqlservr.exe 下运行
---下面是详细的错误日志。
=== 预绑定状态信息 ===
日志:用户 = NT AUTHORITY\NETWORK SERVICE
日志:DisplayName = cognosdotnet assembly_2_0,版本 = 10.1.4707.501,文化 = 中性,PublicKeyToken = d6e6d7d808b7e5b7 (完全指定)
日志:Appbase = file:///c:/Program Files/Microsoft SQL Server/MSSQL10_50.SQLEXPRESS/MSSQL/Binn/
日志:初始 PrivatePath = NULL
日志:动态基础 = NULL
日志:缓存基础 = NULL
日志:AppName = NULL
调用程序集:System.Xml,版本=2.0.0.0,文化=中性,公钥令牌=b77a5c561934e089。
===
日志:此绑定在默认加载上下文中启动。 日志:找不到应用程序配置文件。
日志:使用 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config 中的计算机配置文件。
日志:策略后参考:cognosdotnet assembly_2_0,Version=10.1.4707.501,Culture=neutral,PublicKeyToken=d6e6d7d808b7e5b7
日志:Fusion 已托管。检查主机有关此程序集的信息。
日志:程序集不在 CLR 加载列表中。询问主机组装店。
日志:尝试使用程序集 cognosdotnet assembly_2_0、version=10.1.4707.501、culture=neutral、publickeytoken=d6e6d7d808b7e5b7、processorarchitecture=x86 来托管程序集存储。
日志:尝试使用程序集 cognosdotnet assembly_2_0、version=10.1.4707.501、culture=neutral、publickeytoken=d6e6d7d808b7e5b7、processorarchitecture=msil 来主机程序集存储。
日志:尝试使用程序集 cognosdotnet assembly_2_0、version=10.1.4707.501、culture=neutral、publickeytoken=d6e6d7d808b7e5b7 来托管程序集存储。
警告:主机程序集存储不包含此程序集。
错误:预下载检查期间发生不可恢复的错误(hr = 0x80070002)。
有人可以提供有关 SQL Server 为何无法找到 cognosdotnet assembly_2_0 的见解吗?
如果您需要更多信息,请告诉我。
感谢您的帮助。
——克里斯
Good Morning. I am currently experiencing an issue with a CLR Stored procedure calling an assembly created in Visual Basic (VS 2008). At the highest level, the assembly executes a report contained in Cognos8 and moves the output to a specificed directory on the network. I have no issue when calling the method from a simple test EXE, but when I try to execute via the CLR stored procedure, I am getting the following:
Msg 6522, Level 16, State 1, Procedure ReportRunner, Line 0
A .NET Framework error occurred during execution of user-defined routine or aggregate "ReportRunner":
System.IO.FileNotFoundException: Could not load file or assembly 'cognosdotnetassembly_2_0, Version=10.1.4707.501, Culture=neutral, PublicKeyToken=d6e6d7d808b7e5b7' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.LoadWithPartialNameInternal(String partialName, Evidence securityEvidence, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadWithPartialName(String partialName, Evidence securityEvidence)
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at cognosdotnet_2_0.reportService1..ctor()
at ReportRunnerv3.ReportRunner.ExecuteReport(Int32 inPLAN_ID, Int32 inContract_Sfx, String inRptDate_DT, String inPlanType, String inInvstmentOnlyInd, String inMOMInd, String inGPSIInd, String inPBTInd, String inPICAInd, String inClientAccomInd, String inInstSelectInd, String inRptType, Int32& outRC)
Notes
•cognosdotnetassembly_2_0 is located in the same directory as the "ReportRunner" assembly
•cognosdotnetassembly_2_0 was cataloged using CREATE ASSEMBLY with permission set = unsafe
•cognosdotnetassembly_2_0 is also installed in the GAC
The following is the message provided by fuslogvw.exe:
* Assembly Binder Log Entry (8/11/2011 @ 5:57:39 AM) *
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn\sqlservr.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = cognosdotnetassembly_2_0, Version=10.1.4707.501, Culture=neutral, PublicKeyToken=d6e6d7d808b7e5b7
(Fully-specified)
LOG: Appbase = file:///c:/Program Files/Microsoft SQL Server/MSSQL10_50.SQLEXPRESS/MSSQL/Binn/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: cognosdotnetassembly_2_0, Version=10.1.4707.501, Culture=neutral, PublicKeyToken=d6e6d7d808b7e5b7
LOG: Fusion is hosted. Check host about this assembly.
LOG: Assembly is not in CLR Loaded list. Asking host assembly store.
LOG: Try host assembly store with assembly cognosdotnetassembly_2_0, version=10.1.4707.501, culture=neutral, publickeytoken=d6e6d7d808b7e5b7, processorarchitecture=x86.
LOG: Try host assembly store with assembly cognosdotnetassembly_2_0, version=10.1.4707.501, culture=neutral, publickeytoken=d6e6d7d808b7e5b7, processorarchitecture=msil.
LOG: Try host assembly store with assembly cognosdotnetassembly_2_0, version=10.1.4707.501, culture=neutral, publickeytoken=d6e6d7d808b7e5b7.
WRN: Host assembly store does not contain this assembly.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
Can someone provide insight as to why SQL Server is unable to find cognosdotnetassembly_2_0?
If you need more information, please let me know.
Thanks for your assistance.
--Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这是不久前被问到的,但希望它能帮助将来的人,我将我所知道的包括在内。
这可能与 SQL CLR 系统内置的安全限制有关。我在尝试在 CLR SQL Sproc 内部使用 XML 序列化时遇到了问题,因为(您的错误日志也显示了这一点)XML 序列化实际上使用了反射,它比普通托管代码需要更多的安全权限。我猜您能够引用 Cognos 程序集,因为它是通过文件浏览添加的。如果您添加 GAC 的程序集,则列表非常有限,我确信它基于特定的接口或程序集属性,而您正在使用的 Cognos 程序集未实现或不提供该属性。
如果您的 CLR SQL 存储过程以更高的权限级别运行,它可能会起作用。很可能不会。
I know this was asked a while ago but in the hopes that it will help someone in the future I'm including what I know.
This is probably related to the Security restrictions that are built into the SQL CLR system. I had issues while trying to use XML Serialization inside of a CLR SQL Sproc, because (and your error log shows this as well) XML Serialization actually uses Reflection which requires more security permissions than normal managed code. I'm guessing you were able to reference the Cognos assembly because it was added via Browsing for the file. If you add a GAC'ed Assembly the list is very limited I'm sure it's based on a specific interface or assembly attribute, which isn't implemented or available in the Cognos Assembly you are using.
If your CLR SQL sproc runs with a higher permission level it might work. Most likely not.