'System.NullReferenceException' error when calling 3th party COM

hildebrand

New member
Joined
Sep 5, 2005
Messages
2
Programming Experience
Beginner
Hi,

I have a third-party OCX library (SmRemLib) to remote control a video software package using TCP/IP. Every time when I call a method I get An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll

Here is to code I use (VB.NET 2003):

VB.NET:
Imports SmRemLib
 
Public Class Form1
'...
Public Sub test()
Dim SmRem As Object
SmRem.Connect("192.168.0.19", 5554)
End Sub
 
End Class

Is there another way to call this Connect method without getting the Null Exception error? Thanks in advance.

edit:
Ok I found the fault, I had to define SmRem As New Object.
Now I have a new error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Anyone has a cure for this one?
 
Last edited:
Try STATThread

Add STATThread to the subroutine calling connect...as listed below

<STAThread()> _
Public Sub test()
Dim SmRem As Object
SmRem.Connect("192.168.0.19", 5554)
End Sub
 
STAThread has no effect

Thanks but when I add the STAThread attribute it has no effect. I keep getting the 'System.Runtime.InteropServices.COMException' in mscorlib.dll.
I think that the OCX module is written in VB 6 and is somehow not completely compatible with VB.NET.
Is there a workaround for this?
 
Back
Top