Let's first see the MSDN document about this method: http://msdn.microsoft.com/en-us/library/system.appdomain.docallback.aspx

The three examples are good, but helping yourself to understand better, you may need to twist them a little...

Summary (the following is based on my understanding, for any mistake please comment below :))

There are three scenarios for DoCallBack method applies:

1. use Static DoCallBack method,
In this, neither default or new domain owns the field and MyCallBack code, they share the same.

2. use DoCallBack method by value, --modified with [Serializable]
In this, default domain owns the first-hand data and the new domain just owns a second-hand copy.

3. use DoCallBack method by reference, -- let class inherit from MarshalByRefObject
In this, default domain owns the only real data but the new domain just keep a reference to the data (class fields and methods).

Hope this explains better, addition to the MSDN document.

So, we can also explain why everytime we try to make a new Form in a new Domain, it always seems to be failed... as Form class inherit from MarshalByRefObject, and in a new Domain it only keeps the reference, yes just a reference, all the Callbacks and data happen in the Default Domain actually.

相关文章:

  • 2021-11-16
  • 2021-07-08
  • 2021-06-20
  • 2022-01-26
  • 2022-02-10
  • 2021-09-12
  • 2021-07-10
  • 2021-10-11
猜你喜欢
  • 2021-11-19
  • 2021-05-21
  • 2022-01-31
  • 2022-02-02
  • 2021-12-24
  • 2021-09-17
  • 2021-10-30
相关资源
相似解决方案