Reflection and WCF

I call the WCF method using the InvokeMember method. The WCF method accepts an integer and an out object as a parameter. this is the code in the WCF service:

 public int SimpleTest(int n, out object OBJ)
    {
        OBJ = new Int32();
        OBJ = 12;
        return n;
    }

when I use InvokeMember to call a function with parameters new Object[]{1 , obj}, obj becomes 12 as expected.
but when the OBJ inside SimpleTest is set to a complex object (OBJ = new MyClass()), I get the following exception on the page called the method: an Exception has been thrown by the target of an invocation.
internal exception indicates thatThe underlying connection was closed: The connection was closed unexpectedly.

I cannot understand why this exception occurred. can anyone explain?

+3
source share
2 answers

What does the constructor of MyClass do? Does MyClass have any static constructor?

Exception has been thrown by the target of an invocation. , , , , MyClass - (, ), , .

, , MyClass.

+1

WCF , .

, , , out . , , , - , .

, , vanilla object, EntityObject. , , , , KnownTypeAttribute, .

0

Source: https://habr.com/ru/post/1795426/


All Articles