converting c# to vb.net

Stevod2
Stevod2 used Ask the Experts™
on
I have a third party piece of c# code which implements an interface, then I use the c# to vb.net converter at www.developerfusion.com/tools/convert/csharp-to-vb to automatically convert the code to vb.net.

However, when I compile the vb code, I get the  error similar to below for six of the implemented  
interface members. The un-converted code works fine. Is there something funny about the syntax of the converted code which is causing a problem?
 
VB.NET compiler Error:
Class 'InMemoryTokenManager' must implement 'Sub ExpireRequestTokenAndStoreNewAccessToken(consumerKey As String, requestToken As String, accessToken As String, accessTokenSecret As String)' for interface 'DotNetOpenAuth.OAuth.ChannelElements.ITokenManager'.      Line 14      Col 16

vb.net code (Converted)
------------------------------
'-----------------------------------------------------------------------
' <copyright file="InMemoryTokenManager.cs" company="Andrew Arnott">
'     Copyright (c) Andrew Arnott. All rights reserved.
' </copyright>
'-----------------------------------------------------------------------

Imports System.Collections.Generic
Imports System.Diagnostics

Imports DotNetOpenAuth.OAuth.ChannelElements
Imports DotNetOpenAuth.OAuth.Messages

Public Class InMemoryTokenManager
    Implements IConsumerTokenManager
    Private tokensAndSecrets As New Dictionary(Of String, String)()

    Public Sub New(ByVal consumerKey As String, ByVal consumerSecret As String)
        If [String].IsNullOrEmpty(consumerKey) Then
            Throw New ArgumentNullException("consumerKey")
        End If

        m_ConsumerKey = consumerKey
        m_ConsumerSecret = consumerSecret
    End Sub

    Public ReadOnly Property ConsumerKey() As String
        Get
            Return m_ConsumerKey
        End Get
       
    End Property
    Private m_ConsumerKey As String

    Public ReadOnly Property ConsumerSecret() As String
        Get
            Return m_ConsumerSecret
        End Get

    End Property
    Private m_ConsumerSecret As String

#Region "ITokenManager Members"
    Public Function GetTokenSecret(ByVal token As String) As String
        Return Me.tokensAndSecrets(token)
    End Function

    Public Sub StoreNewRequestToken(ByVal request As UnauthorizedTokenRequest, ByVal response As ITokenSecretContainingMessage)
        Me.tokensAndSecrets(response.Token) = response.TokenSecret
    End Sub

    Public Sub ExpireRequestTokenAndStoreNewAccessToken(ByVal consumerKey As String, ByVal requestToken As String, ByVal accessToken As String, ByVal accessTokenSecret As String)
        Me.tokensAndSecrets.Remove(requestToken)
        Me.tokensAndSecrets(accessToken) = accessTokenSecret
    End Sub

    ''' <summary>
    ''' Classifies a token as a request token or an access token.
    ''' </summary>
    ''' <param name="token">The token to classify.</param>
    ''' <returns>Request or Access token, or invalid if the token is not recognized.</returns>
    Public Function GetTokenType(ByVal token As String) As TokenType
        Throw New NotImplementedException()
    End Function
#End Region
End Class

-----------------------------------------

c# code (unconverted)
---------------------------
//-----------------------------------------------------------------------
// <copyright file="InMemoryTokenManager.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics;

using DotNetOpenAuth.OAuth.ChannelElements;
using DotNetOpenAuth.OAuth.Messages;

public class InMemoryTokenManager : IConsumerTokenManager
{
  private Dictionary<string, string> tokensAndSecrets = new Dictionary<string, string>();

  public InMemoryTokenManager(string consumerKey, string consumerSecret)
  {
    if (String.IsNullOrEmpty(consumerKey))
    {
      throw new ArgumentNullException("consumerKey");
    }

    this.ConsumerKey = consumerKey;
    this.ConsumerSecret = consumerSecret;
  }

  public string ConsumerKey { get; private set; }

  public string ConsumerSecret { get; private set; }

  #region ITokenManager Members
  public string GetTokenSecret(string token)
  {
    return this.tokensAndSecrets[token];
  }

  public void StoreNewRequestToken(UnauthorizedTokenRequest request, ITokenSecretContainingMessage response)
  {
    this.tokensAndSecrets[response.Token] = response.TokenSecret;
  }

  public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret)
  {
    this.tokensAndSecrets.Remove(requestToken);
    this.tokensAndSecrets[accessToken] = accessTokenSecret;
  }

  /// <summary>
  /// Classifies a token as a request token or an access token.
  /// </summary>
  /// <param name="token">The token to classify.</param>
  /// <returns>Request or Access token, or invalid if the token is not recognized.</returns>
  public TokenType GetTokenType(string token)
  {
    throw new NotImplementedException();
  }
  #endregion
}


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
You need the implements call after the method that implements the interface method

Public Sub ExpireRequestTokenAndStoreNewAccessToken(ByVal consumerKey As String, ByVal requestToken As String, ByVal accessToken As String, ByVal accessTokenSecret As String) Implements ITokenManager.ExpireRequestTokenAndStoreNewAccessToken
        Me.tokensAndSecrets.Remove(requestToken)
        Me.tokensAndSecrets(accessToken) = accessTokenSecret
    End Sub

Commented:
You need to add that implements on any of the implemented methods. This is required in vb.net but is not in C#
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
In VB you explicitly flag the sub/function that implements each member of the interface.

In this case, I believe you need "Implements IConsumerTokenManager.ExpireRequestTokenAndStoreNewAccessToken" at the end of the appropriate sub.

So change:

    Public Sub ExpireRequestTokenAndStoreNewAccessToken(ByVal consumerKey As String, ByVal requestToken As String, ByVal accessToken As String, ByVal accessTokenSecret As String)

To:

    Public Sub ExpireRequestTokenAndStoreNewAccessToken(ByVal consumerKey As String, ByVal requestToken As String, ByVal accessToken As String, ByVal accessTokenSecret As String) Implements IConsumerTokenManager.ExpireRequestTokenAndStoreNewAccessToken
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
Guess I'm too slow today!...  =D

Commented:
IT's just my cat like reflexes.... :)

                  /\__/\
    ______/  o  o  \
  /~____     =ø=  /
 (______)__m_m)

Author

Commented:
Spot on guys. Thanks a bunch.

Stevod

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial