簡體   English   中英

通過服務中的.NET遠程連接到服務

[英]connect to a service with .NET remoting in a service

出於晦澀的原因,我需要使用WITHNET從服務本身的遠程連接到服務。

需要說明的是:有一個客戶端應用程序連接到該服務:

IEngine engine = (IEngine)Activator.GetObject(typeof(IEngine), "tcp://169.18.1.100:1966/Engine");

對服務進行特定調用時,它將加載帶有計算內容的插件dll的AppDomain。 但是現在,該dll需要從其嵌入的服務中調用函數,並且由於它位於自己的AppDomain中,因此無法直接調用它們。

那么我可以從AppDomain內調用它嗎?

IEngine engine = (IEngine)Activator.GetObject(typeof(IEngine), "tcp://localhost:1966/Engine");

該對象發布有:

RemotingServices.Marshal(this, engineUri);

它至少適用於單個調用,但是可能存在IEngine的線程化和發行或要考慮的其他問題?

我希望清楚。

如果您存儲傳遞給RemotingServices.MarshalIEngine實例,則無需從服務本身調用Activator.GetObject ,因為它將與客戶端應用程序使用的實例相同。 可能需要進行一些重組,但是它將保存從服務中通過網絡堆棧對IEngine所有調用:

IEngine this.engine = new Engine();
RemotingServices.Marshal(this.engine, engineUri);

// this.engine will be the same instance used by client applications and can also be passed around within your service.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM