i am calling a WCF method using InvokeMember Method.The WCF method takes an integer and an out object as parameter. this is the code in WCF service:
public int SimpleTest(int n, out object OBJ)
{
OBJ = new Int32();
OBJ = 12;
return n;
}
when i use InvokeMember to call the function with parameters new Object[]{1 , obj} , obj becomes 12 as expected.
but when OBJ inside SimpleTest is set to a complex object (OBJ = new MyClass()) i get the following exception on the Page that called the method: Exception has been thrown by the target of an invocation.
the inner exception states that The underlying connection was closed: The connection was closed unexpectedly.
i can't understand why this exception occured. can anybody explain?
What does MyClass' constructor do? Does MyClass by any chance have a static constructor?
Exception has been thrown by the target of an invocation. can for example be raised by an exception inside a static constructor for a class, so it seems that the static constructor for MyClass is trying to connect to something (like a database), but is not able because the connection is already closed.
Remember that the static constructor is not run when you start the program, but before the first instance of MyClass is created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With