Results 1 to 2 of 2

Thread: Help with C# vs VB Code

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    1

    Help with C# vs VB Code

    I am working on a service to transfer files for work from a client machine to a server machine. I started to write the service in C# so I could get my feet wet with C#. The code works perfect for what I wanted it to do. Now I want to convert the service to VB, where I am more comfortable working. Unfortunately my client is seeing the interfaces slightly different with the VB interface with regards to the parameters being passed it. Can someone see what the difference might be, I haven't been able to see where the difference lies.

    First, the C# code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using Autosync;
    using System.IO;
    
    namespace AutosyncServer
    {
        [ServiceContract]
        public interface IAutosyncServer
        {
            [OperationContract]
            RemoteFileInfo GetDatabase(Clientinfo info);
    
            [OperationContract]
            Clientinfo PutDatabase(RemoteFileInfo request);
        }
    
       
        [MessageContract]
        public class Clientinfo
        {
            [MessageBodyMember]
            public AutoSyncObject clientinfo;
        }
        
        [MessageContract]
        public class RemoteFileInfo : IDisposable
        {
            [MessageHeader(MustUnderstand = true)]
            public AutoSyncObject clientinfo;
    
            [MessageBodyMember(Order=1)]
            public Stream filestream;
    
            public void Dispose()
            {
                if (filestream != null)
                {
                    filestream.Close();
                    filestream = null;
                }
            }
        }
    
    }
    Now the VB Code:
    Code:
    Imports System.IO
    Imports System
    Imports System.Collections.Generic
    Imports System.Runtime.Serialization
    Imports System.ServiceModel
    Imports Autosync
    
    <ServiceContract()>
    Public Interface IAutosyncService
    
        <OperationContract()>
        Function GetDatabase(ByVal request As ClientInfo) As RemoteFileInfo
    
        <OperationContract()>
        Function PutDatabase(ByVal request As RemoteFileInfo) As ClientInfo
    
    End Interface
    
    <MessageContract()>
    Public Class ClientInfo
        <MessageBodyMember()>
        Public clientinfo As AutoSyncObject
    End Class
    
    <MessageContract()>
    Public Class RemoteFileInfo
        Implements IDisposable
    
        <MessageHeader(MustUnderstand:=True)>
        Public ClientInfo As AutoSyncObject
    
        <MessageBodyMember(Order:=1)>
        Public filestream As Stream
    
    #Region "IDisposable Support"
        Private disposedValue As Boolean ' To detect redundant calls
    
        ' IDisposable
        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If Not Me.disposedValue Then
                If disposing Then
                    If filestream IsNot Nothing Then
                        filestream.Close()
                        filestream = Nothing
                    End If
                End If
    
                ' TODO: free unmanaged resources (unmanaged objects) and override Finalize() below.
                ' TODO: set large fields to null.
            End If
            Me.disposedValue = True
        End Sub
    
        ' This code added by Visual Basic to correctly implement the disposable pattern.
        Public Sub Dispose() Implements IDisposable.Dispose
            ' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.
            Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub
    #End Region
    
    End Class
    When I make the call to GetDatabase I get Value of type 'Autosync.AutosyncObject' cannot be converted to AutosyncClient.AutosyncServer.AutosyncObject.

    The call is:
    Dim myObj As Autosync.AutoSyncObject = client.GetDatabase(test, inputstream)

    On the PutDatabase I get Value of type 'Autosync.AutosyncObject' cannot be converted to '1-dimensional array of Object'

    The call is:
    Dim myObj As Autosync.AutoSyncObject = client.PutDatabase(test, uploadStreamWithProgress)

    I changed nothing in the client other than calling the VB service instead of the C# service. Any ideas what I am doing differently in my VB code?

    Thanks!

  2. #2
    New Member
    Join Date
    Aug 2011
    Posts
    1

    Re: Help with C# vs VB Code

    Thanks for code....

Posting Permissions

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



Click Here to Expand Forum to Full Width