通过在SQL本身注册来调用dll [英] Calling dll by registering in SQL itself

查看:113
本文介绍了通过在SQL本身注册来调用dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ALTER DATABASE scribe_devtest SET TRUSTWORTHY

GO



创建大会消息

AUTHORIZATION [mylogin]

FROM'C:\ Windows \ Microsoft.NET.NET \ Framework64 \v4.0.30319 \ System.Messaging.dll'

WITH PERMISSION_SET = UNSAFE
GO





CREATE ASSEMBLY SqlMSMQ

授权[mylogin]

FROM'C:\ Windows \ Mesrosoft.NET \ Framework64 \v4.0.30319 \SqlMSMQ.dll'

WITH PERMISSION_SET = UNSAFE

GO



CREATE PROCEDURE testdllproc

@queue nvarchar(200),

@msg nvarchar(MAX)

AS EXTERNAL NAME SqlMSMQ。[SqlMSMQ.SqlMSMQ] .SendMessage

GO



问题:

on

exec testdllproc'。\ private $ \ test','< abcde>'



错误是:

Microsoft .NET Framework中发生错误尝试加载程序集ID 65581.服务器可能资源不足,或者PERMISSION_SET = EXTERNAL_ACCESS或UNSAFE可能不信任程序集。再次运行查询,或检查文档以了解如何解决程序集信任问题。有关此错误的更多信息:

System.IO.FileLoadException:无法加载文件或程序集'sqlmsmq,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 0c63af21be52a322'或其依赖项之一。主机存储中的程序集与GAC中的程序集具有不同的签名。 (来自HRESULT的异常:0x80131050)有关详细信息,请参阅Microsoft知识库文章949080.

System.IO.FileLoadException:

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName ,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection )

在System.Reflection.RuntimeAssembly.InternalLoad( String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)

在System.Reflection.Assembly.Load(String assemblyString)





这个虽然mylogin是dbowner,但似乎是ba权限问题。

此外,我还使用Windows身份验证进入SQL。这是一个问题吗?

ALTER DATABASE scribe_devtest SET TRUSTWORTHY on
GO

CREATE ASSEMBLY Messaging
AUTHORIZATION [mylogin]
FROM 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Messaging.dll'
WITH PERMISSION_SET = UNSAFE
GO


CREATE ASSEMBLY SqlMSMQ
AUTHORIZATION [mylogin]
FROM 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\SqlMSMQ.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE PROCEDURE testdllproc
@queue nvarchar(200),
@msg nvarchar(MAX)
AS EXTERNAL NAME SqlMSMQ.[SqlMSMQ.SqlMSMQ].SendMessage
GO

Problem:
on
exec testdllproc '.\private$\test','<abcde>'

Error is:
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65581. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'sqlmsmq, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c63af21be52a322' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.
System.IO.FileLoadException:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)


This seems to b a permission issue although mylogin is dbowner.
Also i have looged in to SQL with windows autentication. Is that an issue?

推荐答案

\ test','< abcde>'



错误是:

尝试加载程序集ID 65581时,Microsoft .NET Framework中发生错误。服务器可能资源不足,或者PERMISSION_SET = EXTERNAL_ACCESS或UNSAFE可能不信任程序集。再次运行查询,或检查文档以了解如何解决程序集信任问题。有关此错误的更多信息:

System.IO.FileLoadException:无法加载文件或程序集'sqlmsmq,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 0c63af21be52a322'或其依赖项之一。主机存储中的程序集与GAC中的程序集具有不同的签名。 (来自HRESULT的异常:0x80131050)有关详细信息,请参阅Microsoft知识库文章949080.

System.IO.FileLoadException:

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName ,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection )

在System.Reflection.RuntimeAssembly.InternalLoad( String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)

在System.Reflection.Assembly.Load(String assemblyString)





这个虽然mylogin是dbowner,但似乎是ba权限问题。

此外,我还使用Windows身份验证进入SQL。这是一个问题吗?
\test','<abcde>'

Error is:
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65581. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'sqlmsmq, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c63af21be52a322' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.
System.IO.FileLoadException:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)


This seems to b a permission issue although mylogin is dbowner.
Also i have looged in to SQL with windows autentication. Is that an issue?


这篇关于通过在SQL本身注册来调用dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆