0

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

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194

1 Answers1

0

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

Community
  • 1
  • 1
pero
  • 4,169
  • 26
  • 27
  • But why does Console application can work well? neither of them marked as "Serializable". –  Sep 18 '09 at 07:14
  • What is the caller type in console case ? – pero Sep 18 '09 at 07:39
  • Totally same between WPF application and Console. I mean their invoking code to Assembly B –  Sep 18 '09 at 10:50
  • 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. –  Sep 21 '09 at 01:21