translate code from C# to VB.NET

I translated this from C# to VB.NET

C#:

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        var config = new HttpConfiguration() { EnableTestClient = true };
        routes.Add(new ServiceRoute("api/contacts", new HttpServiceHostFactory() { Configuration = config }, typeof(ContactsApi)));

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );
    }

VB.NET:

    Public Shared Sub RegisterRoutes(routes As RouteCollection)
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

        Dim config = New HttpConfiguration() With { _
            Key .EnableTestClient = True _
        }
        routes.Add(New ServiceRoute("api/contacts", New HttpServiceHostFactory() With { _
            Key .Configuration = config _         <-----------Name of field or property being initialized in an object initializer must start with '.'. 
        }, GetType(ContactsApi)))

        ' Route name
        ' URL with parameters
        ' Parameter defaults
        routes.MapRoute("Default", "{controller}/{action}/{id}", New With { _
         Key .controller = "Home", _
         Key .action = "Index", _
         Key .id = UrlParameter.[Optional] _
        })
    End Sub     

But I get an error (placed inline in VB.NET code):

What would the correct translation?

Answers


Remove the Key.

Public Shared Sub RegisterRoutes(routes As RouteCollection)
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

    Dim config = New HttpConfiguration() With { _
        .EnableTestClient = True _
    }
    routes.Add(New ServiceRoute("api/contacts", New HttpServiceHostFactory() With { _
        .Configuration = config _         <-----------Name of field or property being initialized in an object initializer must start with '.'. 
    }, GetType(ContactsApi)))

    ' Route name
    ' URL with parameters
    ' Parameter defaults
    routes.MapRoute("Default", "{controller}/{action}/{id}", New With { _
         .controller = "Home", _
         .action = "Index", _
         .id = UrlParameter.[Optional] _
    })
End Sub     

Need Your Help

Heroku not updating css for rails app

ruby-on-rails git heroku

I'm having trouble updating my rails app on heroku. I've gotten my app up but I tried to change my application.css file in /public/stylesheets/ but whenever I try to push to heroku, the CSS never