Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6078055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:47:25+00:00 2026-05-23T10:47:25+00:00

Im trying to convert the nServiceBus PubSub .net4 example into vb and I’m struggling

  • 0

Im trying to convert the nServiceBus PubSub .net4 example into vb and I’m struggling at one point which I think is a language issue but I thought I would ask the experts.

The code in question is from the publisher:

var eventMessage = publishIEvent ? Bus.CreateInstance<IEvent>() : new EventMessage();

When I try and run this in vb with

 Public Property Bus As IBus
 Dim eM As New EventMessage()
            eM = Bus.CreateInstance(Of IEvent)()

I get a object refrence not set to an instance of the object error

But then I get an error saying I cant use new on an interface which iBus is

any ideas on how I get around this?

Given the similarities between c# and vb.net I cant believe this isnt possible?

Any ideas welcome

Thanks

Chris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:47:26+00:00Added an answer on May 23, 2026 at 10:47 am

    The two parts of the conditional do not have the same type, but they are both assignable to IEvent (I believe), which is the type the C# compiler will make eventMessage have. Try this:

    Dim eM as IEvent
    If publishIEvent Then
        eM = Bus.CreateInstance(Of IEvent)()
    Else
        eM = New EventMessage()
    End If
    

    (probably not entirely correct syntax; my VB is getting rusty…)

    (By the way, I’d suggest using the name eventMessage in stead of eM.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert a file path which just have one slash to
Trying to convert this c code into MIPS and run it in SPIM. int
I am trying to convert an ASP.NET website into a web application project. The
I am trying to convert an int into three bytes representing that int (big
I'm trying to convert an incoming sting of 1s and 0s from stdin into
Trying to convert super(B, self).method() into a simple nice bubble() call. Did it ,
hi i am trying to convert &#x0A into &#x0D&#x0A in select query SELECT TOP
I'm trying to convert a .jar application into an applet. I've unpacked the .jar
I'm using lambda expression and trying convert into uint while adding into the Hashset.
I have an XML file and I'm trying convert it into a (table( HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.