Kommunikation zwischen AppDomains

HostingCommunication

Slots

“..If you simply want to pass some serializable data (e.g. a string), you can share data using so called slots..”
(http://social.msdn.microsoft.com/Forums/vstudio/en-US/5821f52f-3272-4f97-97c7-1c698f30260a/communicate-between-app-domains)

static void Main()
{
AppDomain newDomain = AppDomain.CreateDomain ("New Domain");

// Write to a named slot called "Message"
newDomain.SetData ("Message", "guess what...");

// Executes the code in another application domain that is identified by the specified delegate.
newDomain.DoCallBack(SayMessage);
AppDomain.Unload (newDomain);
}

static void SayMessage()
{
// Read from the "Message" data slot
Console.WriteLine (AppDomain.CurrentDomain.GetData ("Message"));
}

(http://www.albahari.com/nutshell/ch21.aspx)

Remoting

“…If you created an object in another domain e.g. with AppDomain.CreateInstanceAndUnwrap, all you need to call the object in another domain is to call an object’s method. The simplest way to make a cross-application domain call is just to make a call directly on that object, which actually is exposed from another domain via its proxy, existing in another domain.”
(http://stackoverflow.com/questions/6242573/simplest-way-to-make-cross-appdomain-call)

static void Main()
{
AppDomain newDomain = AppDomain.CreateDomain ("New Domain");
Foo foo = (Foo) newDomain.CreateInstanceAndUnwrap (typeof (Foo).Assembly.FullName, typeof (Foo).FullName);
Console.WriteLine (foo.SayHello());
AppDomain.Unload (newDomain);
}

public class Foo : MarshalByRefObject
{
public string SayHello()
{
return "Hello from " + AppDomain.CurrentDomain.FriendlyName;
}

public override object InitializeLifetimeService()
{
// This ensures the object lasts for as long as the client wants it
return null;
}
}

WCF

“…The Windows Communication Foundation (or WCF), previously known as “Indigo”, is a runtime and a set of APIs (application programming interface) in the .NET Framework for building connected, service-oriented applications…”
(http://en.wikipedia.org/wiki/Windows_Communication_Foundation)

Evolution-of-WCF1
Evolution of WCF – Remoting vs. WCF (http://www.c-sharpcorner.com/UploadFile/370e35/evolution-of-wcf/)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s