473,795 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

mmfranke
1 New Member
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 "diagnostic s" 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 2308

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

Similar topics

5
14782
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 1px can someone give me any hints ? thanks for any help
2
1851
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 with url parameters like this: imgZonedCountry.ImageUrl = "http://server/servlet/com.esri.wms.Esrimap?param1=x&param2=y When it serves up the page, I'm getting "&amp;" in place of the "&"
12
4133
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
1794
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 we need to be inlined. VC6 has no such problems. A simple, stripped-down, example is as follows: __forceinline void func() { __asm
2
36634
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 type <Appname>.<structurename> in Assembly <Appname>, Version=1.0.2162.36249, Culture=neutral, PublicKeyToken=null is not marked as serializable."
12
2115
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
11231
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 object? Doesn't it cover them all? Zytan
5
21242
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 serialized. Any ideas? Thanks in advance.
5
20113
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 sender, MemberModifiedEventArgs e); /// <summary>
0
10443
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.