无法加载文件或程序集…或其依赖项之一。 HRESULT 异常:0x80FC3C2C
异常消息:无法加载文件或程序集 System.DirectoryServices 或其依赖项之一。 HRESULT 异常:0x80FC3C2C
CLR SQL 过程引发异常。从程序集中的方法引发异常,其中初始化了 System.DirectoryServices 中的类之一,并且该程序集由具有 CLR 过程的程序集使用。
环境:
- MS SQL Server 2005 标准。
- .NET Framework 2.0
- 创建程序集的
- 数据库将参数 TRUSTWORTHY 设置为 ON使用 PERMISSION_SET = UNSAFE 创建的程序集
Exception message: Could not load file or assembly System.DirectoryServices or one of its dependencies. Exception from HRESULT: 0x80FC3C2C
Exception raised from CLR SQL procedure. Exception raised from the method in the assembly where one of the classes from System.DirectoryServices is initialized and that assembly is used by the assembly with CLR procedure.
Environment:
- MS SQL Server 2005 Std.
- .NET framework 2.0
- Database where assembly is created has parameter TRUSTWORTHY set to ON
- Assembly created with PERMISSION_SET = UNSAFE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
就我而言,问题与数据库的所有者有关。
当您遇到此错误时,这种情况也经常发生。
恢复数据库后,修复主数据库中的数据库所有者可能会有所帮助:
如果这没有帮助,还请尝试以下操作:
In my case the issue was related to the owner of the database.
It happens pretty often too when you face this error.
After restore of db it might help to fix db owner in master database:
If this does not help, try the following also:
请记住,这个答案来自我的培训班笔记...您必须将 PERMISSION_SET 设置为 EXTERNAL_ACCESS 才能访问服务器的文件系统或访问另一台服务器。这是有道理的,因为您正在使用 System.DirectoryServices 访问另一台服务器(域控制器)。
Keep in mind this answer is from my notes from a training class ... You have to set PERMISSION_SET to EXTERNAL_ACCESS to access the server's file system or to access another server. This would make sense since you are using System.DirectoryServices to access another server (the domain controller).
我认为 SQL Server 内部根本不支持 System.DirectoryServices 程序集。 SQL Server 只允许非常具体(硬编码)的程序集列表 (SQL Server 2005、SQL Server 2008 )的使用,以免损害其稳定性。
话虽如此,似乎有一种方法可以实现它,无论如何请参阅问题/答案(没有尝试过)。
I think System.DirectoryServices assembly is simply not supported inside SQL Server. SQL Server does only allow a very specific (hardcoded) list of assemblies (SQL Server 2005, SQL Server 2008) to be used, in order to not jeopardize it's stability.
Having said that, there seems to be a way to achieve it anyway see this question/answer (haven't tried it).
最后,我找到了解决方法。我将对 System.DirectoryServices 的引用添加到链接到 MS SQL 的程序集中,并在 CLR 过程代码中从该命名空间创建一个类。因此,System.DirectoryServices 程序集从放置 DS 主要代码的类中变得可见。
Finally, I found the workaround. I added the reference to the System.DirectoryServices to the assembly that is linked to the MS SQL and in the CLR procedure code create a class from this namespace. And so System.DirectoryServices assembly became visible from the class where the main code for DS is placed.