marshalbyrefobject

Accessing a member on Form may cause a runtime exception because it is a field of a marshal-by-reference class

隐身守侯 提交于 2019-11-28 02:38:23
问题 Accessing a member on Form may cause a runtime exception because it is a field of a marshal-by-reference class I know what this warning is and know how to solve it. My question is why could this cause a runtime error? 回答1: You are probably talking about warning CS1690, repro code: public class Remotable : MarshalByRefObject { public int field; } public class Test { public static void Run() { var obj = new Remotable(); // Warning CS1690: Console.WriteLine(obj.field.ToString()); } } In a

How to solve “Must be MarshalByRefObject” in a good but multiple-inheritance amputated language like C#?

霸气de小男生 提交于 2019-11-28 02:38:19
问题 How to solve "Must be MarshalByRefObject" in a good but multiple-inheritance amputated language like C#? The problem is very simple, in several cases you just have to inherit from this class (infrastructure requirements). It does not matter here really, which cases. So, what do you do if you've already inherited from some other class (your domain model requirements)? Btw good application frameworks, like spring.net always make sure you DON'T have to inherit from this class no matter what kind

“Object has been disconnected or does not exist at the server” exception

我只是一个虾纸丫 提交于 2019-11-27 18:29:00
I need to use cross-appdomain calls in my app, and sometimes I have this RemotingException: Object '/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmkhdinj7g2kpkhc_7.rem' has been disconnected or does not exist at the server. The target object is still alive, I have checked it. UPD I've set breakpoint in the finalizer of the target object, and it never hits. Thus, this object is alive and wasn't GC'ed. That is probably because the local garbage collector at the server side collects the object. You can prevent that by renewing the leasing. You can read more about that in these articles: Managing

How do the In and Out attributes work in .NET?

孤者浪人 提交于 2019-11-27 05:06:38
I have been trying to serialize an array across an AppDomain boundary, using the following code: public int Read(byte[] buffer, int offset, int count) { return base.Read(buffer, offset, count); } As a guess, after noticing the attributes elsewhere, I marked the method's parameters with [In] and [Out] attributes, which seemed to cause the parameters to behave as if they were passed by reference. For example: public int Read([In, Out] byte[] buffer, int offset, int count) { return base.Read(buffer, offset, count); } Before I added the attributes, the contents of the buffer variable were lost

Can JAXB marshal by containment at first then marshal by @XmlIDREF for subsequent references?

半城伤御伤魂 提交于 2019-11-27 02:21:37
I'm wondering if it's possible to annotate my classes so that the first time the marshaller encounters an object, it generates an XML element of the appropriate type, but any subsequent reference to this object by anything else will have an XML IDREF entry created? You can leverage the concept of JAXB's XmlAdapter to do something like the following: input.xml The following is the XML document I will use for this example. The 3rd phone-number entry is a reference to the 1st phone-number entry, and the 5th phone-number entry is a reference to the 4th.: <?xml version="1.0" encoding="UTF-8"

Can JAXB marshal by containment at first then marshal by @XmlIDREF for subsequent references?

筅森魡賤 提交于 2019-11-26 10:02:13
问题 I\'m wondering if it\'s possible to annotate my classes so that the first time the marshaller encounters an object, it generates an XML element of the appropriate type, but any subsequent reference to this object by anything else will have an XML IDREF entry created? 回答1: You can leverage the concept of JAXB's XmlAdapter to do something like the following: input.xml The following is the XML document I will use for this example. The 3rd phone-number entry is a reference to the 1st phone-number