473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

C# & .NET Remoting: "not marked as serializable" -- but it is!

mmfranke
Hello.

Hi.

I'm writing a logging service that uses .NET remoting. The idea is that the service publishes an EventProcessor object that clients can access via .NET Remoting, passing it DiagnosticEvent objects for processing.

I've altered the main program for the service slightly so that I can run it more easily as a "regular" application during debugging. I have an assembly that contains the "diagnostics" classes that do the work, the service app itself, and a test client app that lets you create a DiagnosticEvent and "dispatch" it.

That is, I'm trying to pass an argument to a member function of a remotable object. As I understand it, that means I have to mark it as serializable, which I have.

The problem is that I'm getting errors telling me that the DiagnosticEvent object which I'm passing to the remote object is "not marked for serialization" -- even though it is. When I try adding a function that takes a TestObject, expecting the same error, I then get an exception about "unable to load" due to a problem with deserialization.

I'm clearly missing something basic. I'm new to .NET, BTW.

(ASIDE: One more little hitch is that I've been wrestling with static initialization of the remote object. It's a singleton class, and it seems that I get messed up if the server application instantiates the class before remote applications get a chance to. But perhaps that's for another post.)

Can someone help me clear up my serialization issues? Here's some of the code:

The object I'm passing to the remote object is declared as:
Expand|Select|Wrap|Line Numbers
  1. [Serializable]
  2. public class DiagnosticEvent : ISimObject
  3. { . . . }
  4.  
...and so is my TestObject:
Expand|Select|Wrap|Line Numbers
  1. [Serializable]
  2. public class TestObject
  3. {
  4. public int m_Int;
  5. public string m_String;
  6. }
  7.  
Here's the code where the remote object is served up:

Expand|Select|Wrap|Line Numbers
  1. private static TcpChannel Publish()
  2. {
  3. TcpChannel channel = null;
  4.  
  5. if (channel == null)
  6. {
  7. // Create an instance of a channel
  8. channel = new TcpChannel(8080);
  9. ChannelServices.RegisterChannel(channel, false);
  10. }
  11.  
  12. // Register as an available service with the name GEDiag
  13. RemotingConfiguration.RegisterWellKnownServiceType(
  14. typeof(GESim.Diagnostics.EventProcessor),
  15. "GEDiag",
  16. WellKnownObjectMode.Singleton);
  17.  
  18. return channel;
  19. }
  20.  
Here's the code where the client connects to the remote object:

Expand|Select|Wrap|Line Numbers
  1. private void ConnectToEventProcessor()
  2. {
  3. // Create a channel for communicating w/ a remote object
  4. // Notice no port is specified -- because we're the client.
  5. if (null == s_Channel)
  6. {
  7. s_Channel = new TcpChannel();
  8. ChannelServices.RegisterChannel(s_Channel, false);
  9. }
  10.  
  11. if (null == m_RemoteEventProcessor)
  12. {
  13. // Create an instance of the remote object
  14. m_RemoteEventProcessor =
  15. (EventProcessor)Activator.GetObject(
  16. typeof(EventProcessor),
  17. "tcp://T00472343:8080/GEDiag");
  18. }
  19. }
  20.  
...and finally, the code where the remote object is exercised -- both with a TestObject and with the actual DiagnosticEvent object. Neither work, for the different reasons I mentioned above:

Expand|Select|Wrap|Line Numbers
  1. TestObject testObject = new TestObject();
  2. testObject.m_Int = 45;
  3. testObject.m_String = "Testing 123...";
  4.  
  5. int i = m_RemoteEventProcessor.Test(testObject);
  6.  
  7. m_RemoteEventProcessor.EnqueueEvent(theEvent);
  8.  
I'd be happy to send the solution (I've sculpted it down to something minimal).

Thanks, in advance.
Apr 17 '07 #1
0 2148

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rolf Brauser | last post by:
Hi, I want to have a table with a border of 1px arround it but table="1" is more than a pixel because this 3d effect is attached. Values below are not accepted How can I get this border with...
2
by: DC Gringo | last post by:
I have an image control (that pulls an image off an ESRI map server): <ASP:IMAGE ID="imgZonedCountry" RUNAT="server"></ASP:IMAGE> In the code behind I am setting the ImageURL to a String value...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
2
by: James Clark | last post by:
We've been using VC6 for some time and are trying to port some specific code to VC7.1 (VC++ .Net 2003). But I've come across problems where __forceinline doesn't inline simple inline assembly that...
2
by: Prakash | last post by:
Hi Friends, In my C# application, i have tried to serialize some structured data using Soapformatter. While calling the serialize funciton i got the exception message like "mscorlib....The...
12
by: Robbie Hatley | last post by:
I'm getting a bizarre error with this code: ... case WM_COMMAND: { switch (LOWORD(wParam)) // switch (control ID) { ... case IDC_RAIN_ENABLE_SIMPLE: {
5
by: Zytan | last post by:
I am trying to pass a variable that has been disposed into a function that accepts an object, and I get this exception. What does it mean? Why can't I pass in *anything* into a parameter of type...
5
by: Aneesh Pulukkul[MCSD.Net] | last post by:
How to convert a "Non Serializable" object to byte array. The object is a dynamically created Excel workbook. As per my understanding an object can be written and read from a stream Only if it's...
5
by: Nirdesh | last post by:
Hi, I am serializing a custom class holding some data for my project. This data internally contains a class which contains an event public delegate void MemberModifiedEventHandler(object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.