views:

164

answers:

1

Hello there,

I built some assemblies, one of them is to provide some functionalities and some events. some relationship as below:

  • Assembly A is one interface facade component, it declares all service interfaces.
  • Assembly B is one "Mock" implementation of all interfaces declared Assembly A (include event)
  • Assembly C is one "Real" implementation of all interfaces declared Assembly A (include event)

And B will be responsible for creating C in second AppDomain and invoke methods in C, like below: Inside B assembly:

void MethodA()
{
...
AppDomain proxyAppDomain = AppDomain.CreateDomain(..)
ProxyGenerator proxyGenerator = (ProxyGenerator)proxyAppDomain.CreateInstanceAndUnwrap(...)
proxyGenerator.UpdateProgressEvent += OnUpdatePregress(..);
proxyGenerator.MethodA();
}

And, caller application will interact with Assembly B, rather than C directly.

Now, if caller application is Console type, everything works well, but if caller application is WPF type, it failed and reported that "SampleForm.Window1 in ... is not marked as Serializable" (SampleForm.Window1 is WPF main window).

It confused myself, who can help me on this?

Thanks, Kent

A: 

Apparently you are crossing app domain boundaries. All types that cross this must be serialized before sent and then deserialized in another app domain. Therefore types that cross app domains must be serializable.

You should probably change the code in a way that form in not sent cross.

Look at: net-problem-with-raising-and-handling-events-using-appdomains

Petar Repac
But why does Console application can work well? neither of them marked as "Serializable".
Kent
What is the caller type in console case ?
Petar Repac
Totally same between WPF application and Console. I mean their invoking code to Assembly B
Kent
Hmmmm, I should take back my comments that there's some difference between Console and WPF application:From Console, the calling way is "static"From WPF, the calling way is no-static.This caused different result.
Kent