InDistress
Member
- Joined
- Mar 10, 2007
- Messages
- 14
- Programming Experience
- Beginner
Howdy all,
I need some help because for the life of me I can't figure out why I'm getting this Type Initializer error.
I have an OpenFileDialogue control that once a user has selected a file calls a procedure from a public module I created. Effectively what this public module is used for is opening an excel spreadsheet that is then populated with data from my apps database - it's long and kind of complicated to explain so I won't elaborate unless you need me to.
The problem is - when the debugger hits my Call GetListOfWorksheets, it throws the following error at me:
System.TypeInitializationException - The Type Initializer for 'WindowsApplication1.TranslationCode' threw an exception
Data - {System.Collections.ListDictionaryInternal}
Helplink - Nothing
Inner Exception - {"Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."}
- [System.Runtime.InteropServices.COMException]
etc. etc.
Now as far as I can fathom, it's a problem with the InteropServices. I've included the TranslationCode.vb code module and procedure I'm trying to call inside that module.
I know I'm missing something obvious, but I just can't see it.
Thanks in advance all.
I need some help because for the life of me I can't figure out why I'm getting this Type Initializer error.
I have an OpenFileDialogue control that once a user has selected a file calls a procedure from a public module I created. Effectively what this public module is used for is opening an excel spreadsheet that is then populated with data from my apps database - it's long and kind of complicated to explain so I won't elaborate unless you need me to.
The problem is - when the debugger hits my Call GetListOfWorksheets, it throws the following error at me:
System.TypeInitializationException - The Type Initializer for 'WindowsApplication1.TranslationCode' threw an exception
Data - {System.Collections.ListDictionaryInternal}
Helplink - Nothing
Inner Exception - {"Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."}
- [System.Runtime.InteropServices.COMException]
etc. etc.
Now as far as I can fathom, it's a problem with the InteropServices. I've included the TranslationCode.vb code module and procedure I'm trying to call inside that module.
VB.NET:
Imports Excel = Microsoft.Office.Interop.Excel
Public Module TranslationCode
Dim ExcelApp As New Excel.Application
Dim ExcelFilePath As String
Dim ExcelWB As New Excel.Workbook
Dim ExcelWS As Excel.Worksheet
Dim AddSLAInfo, AddLGAInfo, AddSSDInfo, AddSDInfo As Boolean
Dim SLAColumnIndex, LGAColumnIndex, SSDColumnIndex, SDColumnIndex As Integer
Dim IF_PCColumnIndex, IF_SUBColumnIndex As Integer
Dim IF_PCValue, IF_SUBValue As String
Dim IF_MaxColumnValue As Integer
Dim IF_RowCounter As Integer
Dim conString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\data.mdb;Persist Security Info=True"
Dim MyConnection As New System.Data.OleDb.OleDbConnection
Dim oleCommand As New System.Data.OleDb.OleDbCommand
Dim reader As System.Data.OleDb.OleDbDataReader
Dim oledbStr As String
#Region ".....GET LIST OF WORKSHEETS FROM INPUT FILE"
Public Sub GetListOfWorksheets()
ExcelFilePath = Trim(UF009.UF009_TB_InputFilePath.Text)
ExcelApp = New Excel.Application
ExcelWB = ExcelApp.Workbooks.Open(ExcelFilePath)
For Each ExcelWS In ExcelWB.Worksheets
UF009.UF009_ComB_Worksheets.Items.Add(ExcelWS.Name)
Next
End Sub
#End Region
I know I'm missing something obvious, but I just can't see it.
Thanks in advance all.