Problem with Interop Assembly . . .

swu

Active member
Joined
Mar 26, 2005
Messages
33
Programming Experience
1-3
I am trying to access Autodesk Land Desktop through an interop.

I need some basic .net troubleshooting. I created an interop with COMtoNET freeware so I can access the Land Desktop class library through .net. I think the library works with VB6, but there is a problem going to .net and autodesk is apparently too lazy to fix it.

Anyhoo, the interop I made can be loaded into vb.net. I can see the object model. I can even program in it and use the autocomplete feature. Everything works well till you try and execute some code that accesses the object model. I'm currious if there's a problem with the interop or my code.

Here's the code:

mports System
Imports AutoCAD = Interop.AutoCAD
Imports AeccLandLib = Interop.AutoCADLand


Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBoxTest As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.TextBoxTest = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(200, 24)
Me.Button1.TabIndex = 7
Me.Button1.Text = "Gather Data"
'
'TextBoxTest
'
Me.TextBoxTest.Location = New System.Drawing.Point(40, 48)
Me.TextBoxTest.Name = "TextBoxTest"
Me.TextBoxTest.Size = New System.Drawing.Size(200, 20)
Me.TextBoxTest.TabIndex = 10
Me.TextBoxTest.Text = "TextBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 94)
Me.Controls.Add(Me.TextBoxTest)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Civil 3D ProTools"
Me.ResumeLayout(False)

End Sub

#End Region



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim idwg As AeccLandLib.AeccDocument
Dim name As String
name = idwg.Name
TextBoxTest.Text = name
End Sub


End Class

Here's the error I get:

An unhandled exception of type 'System.nullreferenceException' occured in VBDotNetClientApplication.exe

Addt'l Info: Object reference not set to an instance of an object.

Here's a link to the posts on the discussion groups:

http://discussion.autodesk.com/thread.jspa?threadID=425290

Here's the post that suggested I try and make the interop assembly myself.

Maybe you could generate the Interop assembly yourself, instead of adding a reference to the type library, using tlbimp.exe?

"The Type Library Importer utility (tlbimp.exe) is a command line tool that reads COM type information (typically contained in *.tlb, *.dll or *.exe files) and generates a corresponding .NET interop assembly."

Here's my response:

Re: .net interop with Land DT
I tried using

http://www.aurigma.com/Products/COMtoNET/

In .net it seems to work, I can work my way throught he object model and my code appears correct. When I run it I get this error.

An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll

Additional information: Object variable or With block variable not set.

Is this due to problems with the type library?
 
Your problem is that you have only declared and not instantiated the variable idwg. I don't have knowledge of the Land Desktop class library so I can't be sure of the exact code but if I had to guess:
VB.NET:
Dim idwg As New AeccLandLib.AeccDocument()
The New method of the AeccLandLib.AeccDocument object may require parameters.
 
Back
Top