[RESOLVED] [2005] Remoting Serialization problem-VBForums
Results 1 to 12 of 12

Thread: [RESOLVED] [2005] Remoting Serialization problem

  1. #1

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Resolved [RESOLVED] [2005] Remoting Serialization problem

    Hi!

    I'm kind of new in Remoting domain, and I'm facing some problem,

    I've create a DLL that store a Class that 2 application need,
    One of them say program "A" register and instantiate the "service" like this

    Code:
       RemoteTcpSetting("port") = pServicePortNumber
       RemoteTcpSetting("name") = pServiceName
    
       Dim channel As New System.Runtime.Remoting.Channels.Http.HttpChannel(RemoteTcpSetting, Nothing, Nothing)
    
       If ChannelServices.GetChannel(pServiceName) Is Nothing Then
           ChannelServices.RegisterChannel(channel, False)
       End If
     RemotingConfiguration.RegisterWellKnownServiceType(GetType(MMOutlookSyncServer.clsSyncControler), pServiceName, WellKnownObjectMode.Singleton)
    
       'Instantiate the service 
       oSyncControler = CType(Activator.GetObject(GetType(MMOutlookSyncServer.clsSyncControler), "http://127.0.0.1:" & pServicePortNumber.ToString & "/" & pServiceName), MMOutlookSyncServer.clsSyncControler)
    In the second program say, Program "B", I simply instantiate the class SyncControler to the already registered one
    Code:
     oSyncControler = CType(Activator.GetObject(GetType(MMOutlookSyncServer.clsSyncControler), "http://127.0.0.1:" & pServicePortNumber.ToString & "/" & pServiceName), MMOutlookSyncServer.clsSyncControler)
    All the above work great I can manipulate the oSyncControler member and property perfectly.

    Thing go a bit more problematic, when I bring the code from the program "B" into a Outlook AddIns DLL. Every procedure/method that I call bring error.
    One of them, when I try to get a Typed DataSet from the "service"
    Code:
     Me.DataGridView1.DataSource = oSyncControler.SyncLog
    give me this error:
    Code:
    Parse Error, no assembly associated with Xml key a2:http://schemas.microsoft.com/clr/nsassem/MMOutlookSyncServer/MMOutlookSyncServer%2C%20Version%3D8.3.104.3%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3De6d769c29d13d867 dsSyncLog
    A another method that I've try
    Code:
    oSyncControler.WriteSyncHeader("Remoting sync controler started on TCP port :" & pServicePortNumber.ToString, MMOutlookSyncServer.clsSyncControler.eSyncResult.Message)
    give me this error:
    Code:
    Invalid method signature 'xsd:string a2:clsSyncControler+eSyncResult'.
    I've read a bit about this problem and it seam that is something to do with Type version or something, and it suggest to do Manual Serialization, or manual type conversion. But I'm note sure if this is really needed, since all file are Local to the computer, and all type should be Known.

    Hope to be clear enough

    Hugo
    Using VS 2010 on Fw4.0

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: [2005] Remoting Serialization problem

    Ok. Where to start!

    Firstly you state

    Every procedure/method that I call bring error
    If this is the case then you need to check your remoting checkup is actually working. To do this wny not have your MMOutlookSyncServer.clsSyncControler class implement a simple function
    Code:
    Public Function Test() as Boolean
      Return True
    End Function
    This is a simple way to test if your basic remoting scenairo is working.

    With regards paramaters or function returns you have been set on the right track with serialization. You could do this simply (although inefficiently) by writing and reading your dataset to XML.

    Although you may only be passing your messages on the local machine your software has no way of knowing this. You are setting up communcation between two processes and you must agree a way of passing parameters between them.

    I would recommend first confirming that your remoting setup is working then taking it from there.

    NOTE: You may want to consider using a TCPChannel rather than a HTTPChannel.

  3. #3

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    Thanks for your reply

    Yes simple Sub with no parameter work fine.

    It's something with Parameter Type and return type.

    If a change my HTTPChannel to a TCPChannel like this
    Code:
     
       Dim RemoteTcpSetting As IDictionary = New Hashtable()
       RemoteTcpSetting("port") = pServicePortNumber
       RemoteTcpSetting("name") = pServiceName
    
       Dim channel As New System.Runtime.Remoting.Channels.Tcp.TcpChannel(RemoteTcpSetting, Nothing, Nothing)
       
       If ChannelServices.GetChannel(pServiceName) Is Nothing Then
             ChannelServices.RegisterChannel(channel, False)
       End If
                RemotingConfiguration.RegisterWellKnownServiceType(GetType(MMOutlookSyncServer.clsSyncControler), pServiceName, WellKnownObjectMode.Singleton)
    
    'Instantiate
    
       oSyncControler = CType(Activator.GetObject(GetType(MMOutlookSyncServer.clsSyncControler), "tcp://127.0.0.1:" & pServicePortNumber.ToString & "/" & pServiceName), MMOutlookSyncServer.clsSyncControler)
    
      oSyncControler.ClearLog()
    I always have a error, when hiting the line "oSyncControler.ClearLog()"
    An existing connection was forcibly closed by the remote host

    That why I went with HTTPChannel
    Using VS 2010 on Fw4.0

  4. #4

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    ....
    Last edited by Zakary; Jan 6th, 2009 at 01:01 PM.
    Using VS 2010 on Fw4.0

  5. #5
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: [2005] Remoting Serialization problem

    Can I confirm that both your client and server are using the same DLL?

    I would recommend the next step as extending the paramters you pass to our TEST Function. For example
    Code:
    Public Function Test(BYVal Msg As String) As String
      Return Msg
    End Function
    If you confim this works then try a test version with your dataset object. Let me know what happens.

    Can I form that eSyncResult is serlialzable?

  6. #6

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    Yes, I've check and both project refer to the same DLL (witch is MMOutlookSyncServer.dll)

    And Yes, the Enum eSyncResult is define Serialization
    Code:
        <Serializable()> _
        Public Enum eSyncResult
            Syncing = 10
            Synced = 30
            Message = 40
            All = 900 ' For filtering purpose
            IsError = 1000
        End Enum
    OK I've do some test, like you suggest
    Code:
        Public Function Test01() As String
            Return Date.Now.ToString
        End Function
    
        Public Function Test02() As Date
            Return Date.Now
        End Function
    
        Public Function Test03() As DataSet
            Return New DataSet
        End Function
    
        Public Function Test04() As dsSyncLog
            Return m_SyncLog
        End Function
    All Test01, Test02, Test03 work but not Test04.
    I thought that my typed dataset wasn't "Serializable", but the attribute is there in the DataSet definition.

    The error is:
    Parse Error, no assembly associated with Xml key a2:htt p://schemas.microsoft.com/clr/nsassem/MMOutlookSyncServer/MMOutlookSyncServer%2C%20Version%3D8.3.104.3%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3De6d769c29d 13d867 dsSyncLog


    I don't know if it have something to do with my problem, but sometime the reference to my DLL sometime broke, I've to remove the reference and add it again. it like if the reference is bind to a specific version, but the "Specific Version" property is set to false.
    Using VS 2010 on Fw4.0

  7. #7
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: [2005] Remoting Serialization problem

    Can you confirm that both projects refer to the same version of MMOutlookSyncServer.dll ?

    Also, do you have any custom data types inside dsSyncLog. If so make sure these are all marked as Serializable as well.

    The error you are getting is suggests that you are not doing the serilization and deserilzation in the same assembly. I would need to see more of dsSyncLog to be sure, but I assume you are doing something along the following lines.

    1. Declare and create dsSyncLog inside your remoting dll (MMOutlookSyncServer.dll)
    2. Adding to dsSyncLog a class from your outlook addin application
    3. Trying to access that class from your other client.

    Do you think this could be happening?

  8. #8

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    Yes all program refer to the same MMOutlookSyncServer.dll

    My dsSyncLog is a typed DataSet and contain typed DataTable
    And every Table definition have those attribute
    Code:
    <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), 
         Global.System.Serializable(),  
         Global.System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")>
    But I don't thing that the problem is related to this DataSet since other Function/Sub like this one

    Code:
         oAddInMainObj.SyncControler.WriteSyncHeader("Remoting sync controler started on TCP port :" & oAddInMainObj.ServiceTCPPort.ToString, MMOutlookSyncServer.clsSyncControler.eSyncResult.Message)
    Also generate error

    Code:
    "Invalid method signature 'xsd:string a2:clsSyncControler+eSyncResult'."
    But as I said earlier eSyncResult is declared Serializable....
    Using VS 2010 on Fw4.0

  9. #9
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: [2005] Remoting Serialization problem

    I still suspect that the problem has something to do with the data you are adding to m_SyncLog. Can you try updating your Test04 to return a new instance of dsSyncLog

    Code:
    Public Function Test04() As dsSyncLog
            Return new dsSyncLog() 
        End Function
    I assume that dsSyncLog is declared inside MMOutlookSyncServer.dll and that you have not overriden the default construtor.

  10. #10

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    No, I have not overrides the Constructor.
    Yes the dsSyncLog Definition and instance is within MMOutlookSyncServer.dll

    MMOutlookSyncServer.dll:
    Code:
        Public Function Test05() As dsSyncLog
            Return New dsSyncLog
        End Function
    OutlookAddIn Code

    Code:
      
       oAddInMainObj.SyncControler = CType(Activator.GetObject(GetType(MMOutlookSyncServer.clsSyncControler), "http://127.0.0.1:" & oAddInMainObj.ServiceTCPPort.ToString & "/" & oAddInMainObj.ServiceName), MMOutlookSyncServer.clsSyncControler)
       Debug.Print(oAddInMainObj.SyncControler.Test05.Namespace)
    Still give me the same error
    Code:
    System.Runtime.Serialization.SerializationException was caught
      Message="Parse Error, no assembly associated with Xml key a2:http://schemas.microsoft.com/clr/nsassem/MMOutlookSyncServer/MMOutlookSyncServer%2C%20Version%3D8.3.104.3%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3De6d769c29d13d867 dsSyncLog"
      Source="mscorlib"
      StackTrace:
        Server stack trace: 
           at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessGetType(String value, String xmlKey, String& assemblyString)
           at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessType(ParseRecord pr, ParseRecord objectPr)
           at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessAttributes(ParseRecord pr, ParseRecord objectPr)
           at System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
           at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
           at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
           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 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at MMOutlookSyncServer.clsSyncControler.Test05()
           at MMOffice.clsAddInExt.OnConnection(Object Application, ext_ConnectMode ConnectMode, Object AddInInst, Array& custom) in G:\SUITEMAITRE8\SQL\SourceNET\MaitreMarketing\MMOfficeV2\Class\clsAddInExt.vb:line 45
    Using VS 2010 on Fw4.0

  11. #11

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    Another strange thing, is that I can't debug the MMOutlookSyncServer.dll even if place break point.

    And everything work fine, if I do the same thing from a standard WinForm project.
    Using VS 2010 on Fw4.0

  12. #12

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: [2005] Remoting Serialization problem

    Finally I will replace all specific type to Base type, within all method that need serialization.
    Enum to Int32
    and handle Typed Dataset as MemoryStream, ...
    Using VS 2010 on Fw4.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.