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. WCF and WF
  4. Converting a WCF project from C# to VB

Converting a WCF project from C# to VB

Scheduled Pinned Locked Moved WCF and WF
csharpwcfcomhelptutorial
16 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.
  • N Not Active

    Lighten up, no debate was called for, notice the joke icon. However, you seem very defensive in your choice. Guilty feelings, or feelings of inadequency perhaps? ;P


    I know the language. I've read a book. - _Madmatt

    M Offline
    M Offline
    Mark Salsbery
    wrote on last edited by
    #7

    One would think someone who wants to use VB would have a better sense of humor! :)

    Mark Salsbery Microsoft MVP - Visual C++ :java:

    N 1 Reply Last reply
    0
    • M Mark Salsbery

      One would think someone who wants to use VB would have a better sense of humor! :)

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #8

      He's just feeling frustrated with all the # edges taken off his language ;P


      I know the language. I've read a book. - _Madmatt

      B 1 Reply Last reply
      0
      • B bubk

        I'll try to be a little bit more specific This is the block of code I am trying to translate

                                ThreadStart start = delegate
                                {
                                    form = new TProgress(null, port);
                                    form.sport = sport;
                                    form.Show();
                                    form.GetThread = new Thread(new ParameterizedThreadStart(form.GetInvoke));
                                    form.GetThread.Start(transfer);
                                };
                                HelpClass.Form.BeginInvoke(start);
        

        This is what I've got so far, my problem is on the first line AddressOf

                            'Dim start As New ThreadStart(AddressOf) <-- Not sure what this is a delegate of a function, form, ect...
                            Dim form As New TProgress(DBNull.Value, port)
                            form.sport = sport
                            form.Show()
                            form.GetThread = New Thread(New ParameterizedThreadStart(AddressOf form.GetInvoke))
                            form.GetThread.Start(Transfer)
                            'HelpClass.Form.BeginInvoke(start)
        

        thanks

        Worked on my Machine!

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #9

        That looks like Forms, not WCF. In the docs there's sample code for invoking a delegate asynchronously: Control.BeginInvoke Method (Delegate)[^]

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        B 1 Reply Last reply
        0
        • N Not Active

          He's just feeling frustrated with all the # edges taken off his language ;P


          I know the language. I've read a book. - _Madmatt

          B Offline
          B Offline
          bubk
          wrote on last edited by
          #10

          See now if he had inclosed his joke in {} followed by ; I would have gotten the joke right away :-D

          Worked on my Machine!

          1 Reply Last reply
          0
          • M Mark Salsbery

            That looks like Forms, not WCF. In the docs there's sample code for invoking a delegate asynchronously: Control.BeginInvoke Method (Delegate)[^]

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            B Offline
            B Offline
            bubk
            wrote on last edited by
            #11

            Sorry, still having trouble here is the entire proc I am trying to recreate in VB

                public IEnumerable<object> SendQuery(string ip, FilesTransfer transfer, int sport)
                {
                    int port = 0;
                    switch (transfer.Action)
                    {
                        case Action.Invite:
                            {
                                port = HelpClass.GetAvailablePort();
                                if (MessageBox.Show(string.Format("Accept {0} files from {1}", transfer.Files.Count, transfer.Name), "Files", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    ThreadStart start = delegate
                                    {
                                        form = new TProgress(null, port);
                                        form.sport = sport;
                                        form.Show();
                                        form.GetThread = new Thread(new ParameterizedThreadStart(form.GetInvoke));
                                        form.GetThread.Start(transfer);
                                    };
                                    HelpClass.Form.BeginInvoke(start);
                                    break;
                                }
                                else return new List<object>() { (int)InviteRusult.Cancel, 0 };
            
                            }
                        default:
                            {
                                return new List<object>() { (int)InviteRusult.Busy, 0 };
                            }
                    }
                    return new List<object>() { (int)InviteRusult.Ok, port };
                }
            

            An online C# to VB converter spit this out, but the IDE doesn't like 'Dim start As ThreadStart = Function() Do

                Public Function SendQuery(ByVal ip As String, ByVal transfer As FilesTransfer, ByVal sport As Integer) As System.Collections.Generic.IEnumerable(Of Object) Implements ITransfer.SendQuery
                    Dim port As Integer = 0
                    Select Case transfer.Action
                        Case Action.Invite
                            If True Then
                                port = HelpClass.GetAvailablePort()
                                If MessageBox.Show(String.Format("Accept {0} files from {1}", transfer.Files.Count, transfer.Name), "Files", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                                    'Dim start As ThreadStart = Function() Do
                                    '    form = New TProgress(Nothing, port)
                                    '    form.sport = sport
                                    '    form.Show()
            
            M 1 Reply Last reply
            0
            • B bubk

              Sorry, still having trouble here is the entire proc I am trying to recreate in VB

                  public IEnumerable<object> SendQuery(string ip, FilesTransfer transfer, int sport)
                  {
                      int port = 0;
                      switch (transfer.Action)
                      {
                          case Action.Invite:
                              {
                                  port = HelpClass.GetAvailablePort();
                                  if (MessageBox.Show(string.Format("Accept {0} files from {1}", transfer.Files.Count, transfer.Name), "Files", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                  {
                                      ThreadStart start = delegate
                                      {
                                          form = new TProgress(null, port);
                                          form.sport = sport;
                                          form.Show();
                                          form.GetThread = new Thread(new ParameterizedThreadStart(form.GetInvoke));
                                          form.GetThread.Start(transfer);
                                      };
                                      HelpClass.Form.BeginInvoke(start);
                                      break;
                                  }
                                  else return new List<object>() { (int)InviteRusult.Cancel, 0 };
              
                              }
                          default:
                              {
                                  return new List<object>() { (int)InviteRusult.Busy, 0 };
                              }
                      }
                      return new List<object>() { (int)InviteRusult.Ok, port };
                  }
              

              An online C# to VB converter spit this out, but the IDE doesn't like 'Dim start As ThreadStart = Function() Do

                  Public Function SendQuery(ByVal ip As String, ByVal transfer As FilesTransfer, ByVal sport As Integer) As System.Collections.Generic.IEnumerable(Of Object) Implements ITransfer.SendQuery
                      Dim port As Integer = 0
                      Select Case transfer.Action
                          Case Action.Invite
                              If True Then
                                  port = HelpClass.GetAvailablePort()
                                  If MessageBox.Show(String.Format("Accept {0} files from {1}", transfer.Files.Count, transfer.Name), "Files", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                                      'Dim start As ThreadStart = Function() Do
                                      '    form = New TProgress(Nothing, port)
                                      '    form.sport = sport
                                      '    form.Show()
              
              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #12

              I don't know a lick of VB.NET, but based on the doc I linked to...

              Delegate Sub InvokeDelegate()
              ...
              HelpClass.Form.BeginInvoke(New InvokeDelegate(AddressOf start))
              ...
              Public Sub start()
              Dim form As New TProgress(DBNull.Value, port)
              form.sport = sport
              form.Show()
              form.GetThread = New Thread(New ParameterizedThreadStart(AddressOf form.GetInvoke))
              form.GetThread.Start(Transfer)
              End Sub 'InvokeMethod

              This uses a named-method for the delegate. The C# version uses an anonymous method for the delegate - I have no idea how that's done in VB. The VB.NET or Windows Forms forums would be a great place to ask though :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              B 1 Reply Last reply
              0
              • M Mark Salsbery

                I don't know a lick of VB.NET, but based on the doc I linked to...

                Delegate Sub InvokeDelegate()
                ...
                HelpClass.Form.BeginInvoke(New InvokeDelegate(AddressOf start))
                ...
                Public Sub start()
                Dim form As New TProgress(DBNull.Value, port)
                form.sport = sport
                form.Show()
                form.GetThread = New Thread(New ParameterizedThreadStart(AddressOf form.GetInvoke))
                form.GetThread.Start(Transfer)
                End Sub 'InvokeMethod

                This uses a named-method for the delegate. The C# version uses an anonymous method for the delegate - I have no idea how that's done in VB. The VB.NET or Windows Forms forums would be a great place to ask though :)

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                B Offline
                B Offline
                bubk
                wrote on last edited by
                #13

                OK, well thanks for looking at it anyway, I appreciate it, I'll keep searching, I just started working with WCF, so I though what better way to learn than to try and convert this project thanks again...

                Worked on my Machine!

                M 1 Reply Last reply
                0
                • B bubk

                  OK, well thanks for looking at it anyway, I appreciate it, I'll keep searching, I just started working with WCF, so I though what better way to learn than to try and convert this project thanks again...

                  Worked on my Machine!

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #14

                  bubk wrote:

                  I just started working with WCF

                  This is a VB.NET language issue unrelated to WCF :)

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  B 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    bubk wrote:

                    I just started working with WCF

                    This is a VB.NET language issue unrelated to WCF :)

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    B Offline
                    B Offline
                    bubk
                    wrote on last edited by
                    #15

                    yep, I totally agree and understand, the reason I posted here is I thought maybe there would be a better chance of finding someone who had WCF experience and c#/vb experience :)

                    Worked on my Machine!

                    M 1 Reply Last reply
                    0
                    • B bubk

                      yep, I totally agree and understand, the reason I posted here is I thought maybe there would be a better chance of finding someone who had WCF experience and c#/vb experience :)

                      Worked on my Machine!

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #16

                      Sure, and some may still jump in on this thread, but this specific issue has absolutely nothing to do with WCF so for this issue I bet there's more VB.NET experts on the VB.NET board....just sayin :)

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      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