2017-10-11 9 views
1

(npgsql.dllに対して)いくつかの依存関係を持つSQL CLR関数をC#で作成しました。過去に依存関係がなくても、問題なくSQL Serverに新しいアセンブリとして追加できますが、今はできません。SQL Serverでサードパーティのclr dllをロード

私はこのエラーを取得する:

Msg 10301, Level 16, State 1, Line 17
Assembly 'Database1' references assembly 'system.directoryservices, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2 (The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.

編集: この問題は、単に 'system.directoryservices' ではない、私は別のnpgsql.dllを使用するときに、私は代わりに、エラーを次取得:

Msg 10301, Level 16, State 1, Line 20 Assembly 'Database1' references assembly 'system.threading.tasks.extensions, version=4.1.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.

これらのライブラリをGACに追加すると、開発者コマンドプロンプトが表示されません。

+0

**どの部分が存在しないのですか?**あなたは分かりませんか?参照しているこのDLLは、SQL Server .NET環境には存在しません。必要な場合は、独自のアセンブリをロードする前に、ロードしてSQL Server **に追加する必要があります。 –

+1

通常の状況下では、 'System.DirectoryServices'のようなアセンブリがGACからロードされます。 SQL Serverでは、これらの状況は適用されません。許可されているホワイトリストに登録されたアセンブリのリストを除いて、アセンブリをロードするための独自のロジックを持ち、GACを無視します。そのうち、 'System.DirectoryServices 'は1つではありません。 SQL Serverのアセンブリコレクションには、使用可能になる前に、その依存関係(およびその依存関係)を明示的に追加する必要があります。明らかに、あなたがすでに持っていたアセンブリの以前のバージョンは単にそれを参照していないだけです。 –

+0

@ Jeroen Mostertに感謝します。私はGACで 'System.DirectoryServices'を追加しようとしています。これは、このdllを.netパスで見つけて、Developer Command Promptを使用するためです。しかし、再び私は同じエラーがあります。それは私のバージョンのためですか?はいの場合はどうすれば修正できますか? –

答えて

1

この質問はすでに何度か尋ねられています。

DirectoryServices DLLをSQL Serverにインポートする前に(実際には危険性の高いアクション)、実際には、他の方法ではその機能については触れません。たとえば:

C# clr udf for Active Directory group membership

そうでない場合は、ここを見て:

How to register System.DirectoryServices for use in SQL CLR User Functions?

は、任意のストレッチによって素晴らしいオプションではありませんTRUSTWORTHYを、有効にするためにそこにある "修正" が、それはありますサポートされていない.NET Frameworkライブラリをロードする一般的な方法です。私は今のところよく見えており、TRUSTWORTHYを必要としない別の手段に取り組んでいますが、私はそれを推薦する前にもう少しテストをする必要があります。私は完全にテストして文書化する時間があれば、この情報で後でこれを更新します。

関連する問題