This topic is now archived and is closed to further replies.

VB.Net calling a COM object error.

This topic is 5092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m using VB.Net to call a COM object that I created, and I''m geting the error:

An unhandled exception of type ''System.NullReferenceException'' occurred in BNetClient.exe

Additional information: Object reference not set to an instance of an object.


        Dim result As Integer

        Dim obj As BNet.CComm

        obj = New BNet.CComm

        result = obj.Bind("localhost", "9865")

It happens on my call to obj.Bind... Am I missing something? I have BNet loaded as a COM reference into the project, and the object viewer can correctly get the interface and all the methods, etc. I''ve stuck a breakpoint into the com object call but it never hits it, so I''m thinking its on the VB side or erroring out somewhere in the interopt/com libraries. I''m very new to (but a master of VB6) so please forgive me if this is a stupid question.

Share this post

Link to post
Share on other sites
At first sight this should work - a couple of questions - do you have on error resume next, and if so have you checked if after the new statement there actually is an object in obj? (sorry if I seem a bit paternalistic, but the only reasons why you should get that exception is that object not being initialized or an error happening inside the com object(although I think that would yield a COM interop exception, but I''m not sure about that))

Share this post

Link to post
Share on other sites