2

I have a service that calls methods in other libraries through reflection. However, some of these libraries have external dependencies such as app.config files that it sometimes uses to perform its work.

Is there any best practise on how to do this, or any libraries that can help with this kind of situation?

For example: if my service should call external dll on method foo(), foo() then uses app.config to get a list of strings, but crashes when used directly with reflection.

4

1 に答える 1

0

外部アプリケーションを呼び出すには、新しい AppDomain を作成する必要があります。

外部アプリケーションの使用を具体化するためのインターフェイスを定義します。

MarshallByRefObject から派生し、シリアル化可能としてマークされたクラスを作成し、外部アプリケーションへの呼び出しを実装します。

適切な設定 (構成ファイルなど) なしで AppDomain を定義する

CreateInstanceAndUnwrap の実装をインターフェイスとして呼び出して呼び出します。

于 2015-01-16T18:34:09.480 に答える