-3

I have a whole pile of C# classes that I need to convert to VB but I don't understand what some of the C is about.

Here's a typical C# class-

using System;

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.MessageContractAttribute(IsWrapped = false)]
public partial class CreateServiceToken_1_RequestMessage
{
    [System.ServiceModel.MessageHeaderAttribute(Namespace = "http://www.reuters.com/ns/2008/03/01/webservices/rkd/Cache_1")]
    public ThomsonReutersKnowledgeDirect.CacheRequest CacheRequest;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1", Order = 0)]
    public ThomsonReutersKnowledgeDirect.CreateServiceToken_Request_1 CreateServiceToken_Request_1;

    public CreateServiceToken_1_RequestMessage()
    {
    }

    public CreateServiceToken_1_RequestMessage(ThomsonReutersKnowledgeDirect.CacheRequest CacheRequest, ThomsonReutersKnowledgeDirect.CreateServiceToken_Request_1 CreateServiceToken_Request_1)
    {
        this.CacheRequest = CacheRequest;
        this.CreateServiceToken_Request_1 = CreateServiceToken_Request_1;
    }
}

Telerik's online convertor gives me this in VB:

<System.Diagnostics.DebuggerStepThroughAttribute()> _
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
<System.ServiceModel.MessageContractAttribute(IsWrapped:=False)> _
Partial Public Class CreateServiceToken_1_RequestMessage

    <System.ServiceModel.MessageHeaderAttribute([Namespace]:="http://www.reuters.com/ns/2008/03/01/webservices/rkd/Cache_1")> _
    Public CacheRequest As ThomsonReutersKnowledgeDirect.CacheRequest

    <System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="http://www.reuters.com/ns/2006/05/01/webservices/rkd/TokenManagement_1", Order:=0)> _
    Public CreateServiceToken_Request_1 As ThomsonReutersKnowledgeDirect.CreateServiceToken_Request_1

    Public Sub New()
    End Sub

    Public Sub New(CacheRequest As ThomsonReutersKnowledgeDirect.CacheRequest, CreateServiceToken_Request_1 As ThomsonReutersKnowledgeDirect.CreateServiceToken_Request_1)
        Me.CacheRequest = CacheRequest
        Me.CreateServiceToken_Request_1 = CreateServiceToken_Request_1
    End Sub
End Class

Problem is that this produces all sorts of errors such as 'System.ServiceModel' is not defined.
Is the <> enclosed stuff required for VB or just left overs from C#?

BTW I'm using VS 2010

Malcom
  • 61
  • 1
  • 9
  • 1
    That looks more like C# than C++. Are you sure it's the latter? – chue x Jul 14 '14 at 23:42
  • Oops yes c# It occurred to me to add a project ref to 'System.ServiceModel' and the errors went away. Still don't understand what it all means but I'll play a bit more and return. cheers – Malcom Jul 14 '14 at 23:44
  • @Malcom - Perhaps edit your question now that you've spotted the "VC" "c#" error? – Enigmativity Jul 14 '14 at 23:56
  • Do you have a reference to the System.ServiceModel assembly? (This assembly contains the System.ServiceModel.MessageContractAttribute class). – Dave Doknjas Jul 15 '14 at 01:44
  • Why convert them to VB? Why can't you just compile them as C# assemblies and then reference the assembly from VB? Depending on your version of VS, a solution can have both VB and C# projects. – Chris Dunaway Jul 15 '14 at 18:31

1 Answers1

1

The 'stuff in <>' is needed, they are attributes.

Without knowing more, I would say that your errors are due to missing imports\usings.

Look at the top of the C# file, there are many using something.something statements. These should have corresponding Imports something.something in the VB file.

BanksySan
  • 27,362
  • 33
  • 117
  • 216