For test purposes, i have first created my program as a standalone exe project and everything works fine. When i re-create the project as an interop dll, i get an error.
In both projects, i create a datatable in a module file with the following code
Friend SelectedHistoryTable As DataTable
Form1 is called from FoxPro via interop.
Form1 then calls Form2 which adds the column names to the table
SelectedHistoryTable = New DataTable("SelectedHistory")
Dim DateTimeCol As New DataColumn("DateTime")
SelectedHistoryTable.Columns.Add(DateTimeCol)
For j As Integer = 0 To lstTags.Items.Count - 1
Dim NewTagCol As New DataColumn(lstTags.Items.Item(j).ToString())
SelectedHistoryTable.Columns.Add(NewTagCol)
Next j
Form1 then calls Form3 which adds data to the table
Dim NewRow As DataRow
NewRow = SelectedHistoryTable.NewRow()
This works fine as a standalone app, but i cant get this section of code working when i am compiling it as a dll.
The last line (that creates the newrow) causes a NullReferenceException
Object reference not set to an instance of an object.
I can't see why this table does not have scope on this form in the dll project but it does in the standalone project.
Can anyone help?
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).