How to serialize a C++ object through .Net Remoting

B

benkial

Below is a custom exception class that I created to be shared by my C+
+ and
C# code. It works fine till I need to pass the exception object
through Remoting: every time a FtException is raized in the Remoting
server side, the client got the following error (see below). Based on
my Google search, I did the best I can to have a constructor that
takes SerializationInfo and StreamingContext as input. But it seemed
that
client side still cannot get the constructor to deserialize
FtException object.
What did I do wrong???

Also, how do I write the construction (right now is just a printf
statemet :) so that I can pass the _errMsg, and _errNo members and
recreate the object on the client side.

Thanks in advance,

Ben

============================================================
[Serializable]
public __gc class FtException : public System::Exception
{
public:
String *_errMsg;
int _errNo;

FtException(System::Runtime::Serialization::SerializationInfo __gc*
info,
System::Runtime::Serialization::StreamingContext __gc* context);
FtException(int errNo, String* errMsg);


System.Runtime.Serialization.SerializationException: The constructor
to deserialize an object of type Ft.ServiceUtils.FtException was not
found.

Server stack trace:

at
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object
obj, SerializationInfo info, StreamingContext context)
at
System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder
holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at
System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler
handler, ISerParser serParser)
at
System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler)
at
System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapResponseMessage(Stream
inputStream, IMessage requestMsg, Header[] h, Boolean bStrictBinding)
at
System.Runtime.Remoting.Channels.SoapClientFormatterSink.DeserializeMessage(IMethodCallMessage
mcm, ITransportHeaders headers, Stream stream)
at
System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage
msg)

Exception rethrown at [0]:
at Ft.FTConsole.OptionsDialog.tbPolicyServer_KeyUp(Object sender,
KeyEventArgs e) in ....
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Below is a custom exception class that I created to be shared by my C+
+ and
C# code. It works fine till I need to pass the exception object
through Remoting: every time a FtException is raized in the Remoting
server side, the client got the following error (see below). Based on
my Google search, I did the best I can to have a constructor that
takes SerializationInfo and StreamingContext as input. But it seemed
that
client side still cannot get the constructor to deserialize
FtException object.
What did I do wrong???

Also, how do I write the construction (right now is just a printf
statemet :) so that I can pass the _errMsg, and _errNo members and
recreate the object on the client side.
[Serializable]
public __gc class FtException : public System::Exception
{
public:
String *_errMsg;
int _errNo;

FtException(System::Runtime::Serialization::SerializationInfo __gc*
info,
System::Runtime::Serialization::StreamingContext __gc* context);
FtException(int errNo, String* errMsg);


System.Runtime.Serialization.SerializationException: The constructor
to deserialize an object of type Ft.ServiceUtils.FtException was not
found.

I think you need a constructor with no arguments.

Arne

PS: This is a C# group.
 
B

benkial

Below is a custom exception class that I created to be shared by my C+
+ and
C# code. It works fine till I need to pass the exception object
through Remoting: every time a FtException is raized in the Remoting
server side, the client got the following error (see below). Based on
my Google search, I did the best I can to have a constructor that
takes SerializationInfo and StreamingContext as input. But it seemed
that
client side still cannot get the constructor to deserialize
FtException object.
What did I do wrong???
Also, how do I write the construction (right now is just a printf
statemet :) so that I can pass the _errMsg, and _errNo members and
recreate the object on the client side.
[Serializable]
public __gc class FtException : public System::Exception
{
public:
String *_errMsg;
int _errNo;
FtException(System::Runtime::Serialization::SerializationInfo __gc*
info,
System::Runtime::Serialization::StreamingContext __gc* context);
FtException(int errNo, String* errMsg);
System.Runtime.Serialization.SerializationException: The constructor
to deserialize an object of type Ft.ServiceUtils.FtException was not
found.

I think you need a constructor with no arguments.

Arne

PS: This is a C# group.

Thanks for the reply. I added an constructor w/ no arguments
"FtException()".
But the same error of
"System.Runtime.Serialization.SerializationException" is
still there.

Ben

PS. I believe my question is still C# related. And I hope I am not the
only
C# developer that needs to struggle with the integration with an
existing
C++ library...
 
S

Samuel R. Neff

If you look at your assembly in a decompiler (Reflector) is the
constructor there? Seems like an odd problem, the only thing that
causes that error is missing the SerializationInfo, StreamingContext
constructor but you have it declared.

Not that it matters for this problem, but the serialization
constructor is usually declared protected.

While this may be related to c# integration, sounds like a weird
c++/cli problem and you may have better luck in a different group.

HTH,

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top