Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. remoting/serialization problem

remoting/serialization problem

Scheduled Pinned Locked Moved C#
sysadminjsonhelpquestion
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    occcy
    wrote on last edited by
    #1

    hey! i've a nice remoting/serialization problem: i call a method of my server object, which needs a font parameter. if i access this font parameter in my server method i get a remoting exception. the cause of this problem is clear (?): if i read a property value of this font object, the server tries to call the property accessor on client side... meanwhile i call my method without font parameter and with parameters like fontname, fontsize(...) instead... but that's not the smoothest way, i think! is there a way to use font parameters without exception? font implements iserialization - but why becomes it not serialized? thanks in advance

    H 1 Reply Last reply
    0
    • O occcy

      hey! i've a nice remoting/serialization problem: i call a method of my server object, which needs a font parameter. if i access this font parameter in my server method i get a remoting exception. the cause of this problem is clear (?): if i read a property value of this font object, the server tries to call the property accessor on client side... meanwhile i call my method without font parameter and with parameters like fontname, fontsize(...) instead... but that's not the smoothest way, i think! is there a way to use font parameters without exception? font implements iserialization - but why becomes it not serialized? thanks in advance

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Yes, the Font is serializable, but what channel are you using for remoting? If you are hosting your remoting object in IIS, it can only use the HttpChannel. HTTP - by nature - is one way. The server can't initiate communications with the client. With you pass the name, size, etc., these are all value types (except for strings, which behave similarily) and are pass-by-value without using them as properties or the ref and out keywords. Also, what exactly is the exception? The Type and message would help.

      Microsoft MVP, Visual C# My Articles

      O 1 Reply Last reply
      0
      • H Heath Stewart

        Yes, the Font is serializable, but what channel are you using for remoting? If you are hosting your remoting object in IIS, it can only use the HttpChannel. HTTP - by nature - is one way. The server can't initiate communications with the client. With you pass the name, size, etc., these are all value types (except for strings, which behave similarily) and are pass-by-value without using them as properties or the ref and out keywords. Also, what exactly is the exception? The Type and message would help.

        Microsoft MVP, Visual C# My Articles

        O Offline
        O Offline
        occcy
        wrote on last edited by
        #3

        I'm using a TCP Channel. The Exception is something like that: "The Remotechannel has no Channelreceiver, it means that the Server has no registered Serverchannel or that the Application has no matching Clientchannel to communicate with the Server." The type of the exception is System.Runtime.Remoting.RemotingException

        H 1 Reply Last reply
        0
        • O occcy

          I'm using a TCP Channel. The Exception is something like that: "The Remotechannel has no Channelreceiver, it means that the Server has no registered Serverchannel or that the Application has no matching Clientchannel to communicate with the Server." The type of the exception is System.Runtime.Remoting.RemotingException

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          What type of client- or server-activated type are you using (and which one of those is it)?

          Microsoft MVP, Visual C# My Articles

          O 1 Reply Last reply
          0
          • H Heath Stewart

            What type of client- or server-activated type are you using (and which one of those is it)?

            Microsoft MVP, Visual C# My Articles

            O Offline
            O Offline
            occcy
            wrote on last edited by
            #5

            it's a client-activated object (registered client type).

            H 1 Reply Last reply
            0
            • O occcy

              it's a client-activated object (registered client type).

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              It's obvious the server is having trouble communicating with the client. What's not obvious is how you are registering the WKO on the server and connecting to it on the client. If you're using a config file to configure the remoting (both on the server and on the client, which in most cases is a better way so you don't have to recompile), could you post the relevent sections? Don't forget to escape your < and >, or check the "Do not treat <'s as HTML tags" below before posting.

              Microsoft MVP, Visual C# My Articles

              O 2 Replies Last reply
              0
              • H Heath Stewart

                It's obvious the server is having trouble communicating with the client. What's not obvious is how you are registering the WKO on the server and connecting to it on the client. If you're using a config file to configure the remoting (both on the server and on the client, which in most cases is a better way so you don't have to recompile), could you post the relevent sections? Don't forget to escape your < and >, or check the "Do not treat <'s as HTML tags" below before posting.

                Microsoft MVP, Visual C# My Articles

                O Offline
                O Offline
                occcy
                wrote on last edited by
                #7

                okay! i register my object in source code. here's an extract of the code to do this: //client: public void ConnectToServer(Type ObjectType) {  TCPChannel Channel=new TcpClientChannel("ClientChannel",null);  ChannelServices.RegisterChannel(Channel);  RemotingConfiguration.RegisterWellKnownClientType(ObjectType,"tcp://server:10000/server.rem"); } //server: public void PublishObject() {  TCPChannel Channel=new TcpServerChannel("ServerChannel",10000);  ChannelServices.RegisterChannel(Channel);  ServerObject Obj=new ServerObject();  RemotingServices.Marshal(Obj,"server.rem",typeof(ServerObject)); }

                H T 2 Replies Last reply
                0
                • H Heath Stewart

                  It's obvious the server is having trouble communicating with the client. What's not obvious is how you are registering the WKO on the server and connecting to it on the client. If you're using a config file to configure the remoting (both on the server and on the client, which in most cases is a better way so you don't have to recompile), could you post the relevent sections? Don't forget to escape your < and >, or check the "Do not treat <'s as HTML tags" below before posting.

                  Microsoft MVP, Visual C# My Articles

                  O Offline
                  O Offline
                  occcy
                  wrote on last edited by
                  #8

                  My MethodCall looks like that: Font MyFont=new Font("Arial",10); ServerObject.DoSomething(MyFont); The method throws an exception e.g. by accessing the Height Property.

                  1 Reply Last reply
                  0
                  • O occcy

                    okay! i register my object in source code. here's an extract of the code to do this: //client: public void ConnectToServer(Type ObjectType) {  TCPChannel Channel=new TcpClientChannel("ClientChannel",null);  ChannelServices.RegisterChannel(Channel);  RemotingConfiguration.RegisterWellKnownClientType(ObjectType,"tcp://server:10000/server.rem"); } //server: public void PublishObject() {  TCPChannel Channel=new TcpServerChannel("ServerChannel",10000);  ChannelServices.RegisterChannel(Channel);  ServerObject Obj=new ServerObject();  RemotingServices.Marshal(Obj,"server.rem",typeof(ServerObject)); }

                    H Offline
                    H Offline
                    Heath Stewart
                    wrote on last edited by
                    #9

                    Actually, this looks like a server-activated type. Using RemotingConfiguration.RegisterActivatedClientType would create the client-activated type. I'm having a friend look at this thread, though. He's a little better with this type of Remoting stuff than I.

                    Microsoft MVP, Visual C# My Articles

                    1 Reply Last reply
                    0
                    • O occcy

                      okay! i register my object in source code. here's an extract of the code to do this: //client: public void ConnectToServer(Type ObjectType) {  TCPChannel Channel=new TcpClientChannel("ClientChannel",null);  ChannelServices.RegisterChannel(Channel);  RemotingConfiguration.RegisterWellKnownClientType(ObjectType,"tcp://server:10000/server.rem"); } //server: public void PublishObject() {  TCPChannel Channel=new TcpServerChannel("ServerChannel",10000);  ChannelServices.RegisterChannel(Channel);  ServerObject Obj=new ServerObject();  RemotingServices.Marshal(Obj,"server.rem",typeof(ServerObject)); }

                      T Offline
                      T Offline
                      Tom Larsen
                      wrote on last edited by
                      #10

                      One thing that worries me from inspecting this code snip is that you might be mixing your client and server types. You register ObjectType as your remoted object but then use another object ServerObject on the server. The object being remoted must be the same or implement the same interface. This is important because even if ObjectType is derived from ServerType the Remoting Framework only has registered/recognizes ObjectType as remotable. ServerType is just another type it will handle outside of the Remoting Framework. Both the client and server parts need to be dealing with the same object or deal with an interface or you get the wrong behavior. Next once you seem to be using RemotingServices.Marshal in the wrong context. Marshal is used to transfer a MarshalByRefObject across application domains which has little to do with actually "publishing" the service. What I recommend doing is using configuration files on both the client and the server and using RemotingConfiguration.Configure. The client config file from your code snip should look something like this:

                      <configuration>
                      <system.runtime.remoting>
                      <application>
                      <client url="tcp://server:10000">
                      <wellknown
                      type = "ObjectType,ObjectAssembly"
                      url = "tcp://server:10000/server.rem" />
                      <!-- or atlernatively, the client activated version
                      <activated type="ObjectType,ObjectAssembly" />
                      -->
                      </client>
                      <channels>
                      <channel ref="tcp" port="10000" />
                      </channels>
                      </application>
                      </system.runtime.remoting>
                      </configuration>

                      Your server config file should look something like this:

                      <configuration>
                      <system.runtime.remoting>
                      <application>
                      <service>
                      <wellknown mode="SingleCall" type="ObjectType, ObjectAssembly" objectUri="server.rem" />
                      <!-- alternatively, the client activated version
                      <activated type="ObjectType, ObjectAssembly" />
                      -->
                      </service>
                      <channels>
                      <channel ref="tcp" port="10000" />
                      </channels>
                      </application>
                      </system.runtime.remoting>
                      </configuration>

                      If you use config files you don't have to worry about setup or teardown of ch

                      O 1 Reply Last reply
                      0
                      • T Tom Larsen

                        One thing that worries me from inspecting this code snip is that you might be mixing your client and server types. You register ObjectType as your remoted object but then use another object ServerObject on the server. The object being remoted must be the same or implement the same interface. This is important because even if ObjectType is derived from ServerType the Remoting Framework only has registered/recognizes ObjectType as remotable. ServerType is just another type it will handle outside of the Remoting Framework. Both the client and server parts need to be dealing with the same object or deal with an interface or you get the wrong behavior. Next once you seem to be using RemotingServices.Marshal in the wrong context. Marshal is used to transfer a MarshalByRefObject across application domains which has little to do with actually "publishing" the service. What I recommend doing is using configuration files on both the client and the server and using RemotingConfiguration.Configure. The client config file from your code snip should look something like this:

                        <configuration>
                        <system.runtime.remoting>
                        <application>
                        <client url="tcp://server:10000">
                        <wellknown
                        type = "ObjectType,ObjectAssembly"
                        url = "tcp://server:10000/server.rem" />
                        <!-- or atlernatively, the client activated version
                        <activated type="ObjectType,ObjectAssembly" />
                        -->
                        </client>
                        <channels>
                        <channel ref="tcp" port="10000" />
                        </channels>
                        </application>
                        </system.runtime.remoting>
                        </configuration>

                        Your server config file should look something like this:

                        <configuration>
                        <system.runtime.remoting>
                        <application>
                        <service>
                        <wellknown mode="SingleCall" type="ObjectType, ObjectAssembly" objectUri="server.rem" />
                        <!-- alternatively, the client activated version
                        <activated type="ObjectType, ObjectAssembly" />
                        -->
                        </service>
                        <channels>
                        <channel ref="tcp" port="10000" />
                        </channels>
                        </application>
                        </system.runtime.remoting>
                        </configuration>

                        If you use config files you don't have to worry about setup or teardown of ch

                        O Offline
                        O Offline
                        occcy
                        wrote on last edited by
                        #11

                        Many thanks for this hint. I'll change my remoting stuff in this way. But solves it the problem of serialization of my Font object too?

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups