2011-06-29 16 views
4

SQL ServerからいくつかのCOM呼び出しを(サードパーティのDLLに)ラップする.netアセンブリを呼び出そうとしています。アセンブリは、(私は安全ではないと外部からのアクセスに登録してみました)罰金登録するが、私は手順を実行したときに私はこのエラーを取得:SQLCLR - COM呼び出しをラップする

A .NET Framework error occurred during execution of user-defined routine or aggregate "ManagedCodeCallTest": System.UriFormatException: Invalid URI: The URI is empty. System.UriFormatException: at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Uri..ctor(String uriString) at System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath(String fileName) at System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type type, Assembly resourceAssembly) at System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(Int32& fDesignTime, IntPtr& bstrKey, RuntimeTypeHandle rth) at ManagedCode.MyClass.ArielComponentCall()

任意のアイデア?私は可能なことをしようとしていますか?私はライセンスされたdllについて何かを読んだが、情報は非常に曖昧だった。

編集:ケースでCLRコードは役立ちます:

[SqlProcedure] 
public static void ArielComponentCall() 
{ 
    Ariel.ApplicationClass application = new Ariel.ApplicationClass(); 

    object arielDoc = application.OpenDocument(@"P:\Projects\COAT\Ariel1.run"); 
} 

このクラスを含むプロジェクトは、COMオブジェクトへの参照を持っています。

答えて

2

SQL ServerのSqlClr実装には、 "blessed"というa listのSQL Serverで動作するアセンブリメソッドが含まれています。これはHost Protection Attributesによって管理されています。より正確には

SQL Server disallows the use of a type or member that has a HostProtectionAttribute that specifies a HostProtectionResource value of SharedState, Synchronization, MayLeakOnAbort, or ExternalProcessMgmt. This prevents the assemblies from calling members that enable sharing state, perform synchronization, might cause a resource leak on termination, or affect the integrity of the SQL Server process.

あなたのアセンブリのSQL Serverの「アクセス」の設定によっては、エラー(SAFE)を投げ、またはブロックされた方法(UNSAFEEXTERNAL ACCESS)で何もしません。

残念ながら、System.ComponentModel.LicenseContextクラスにはホスト保護属性SharedStateがあり、許可されていないコードの一部です。その結果、コードのどこかに、LicenseManagerのメソッド呼び出しがあり、何もしなくなります。

どちらの方法でも、comコンポーネントのクラッシュがSQL Server全体をクラッシュさせるため、SQL Serverプロセス内でcomコンポーネントを実行することはお勧めできません。

関連する問題