Adding Excel Object Library conflicts between Excel.TextBox & Forms.TextBox in Office
I have implemented several basic Excel functions in my vb.net application (opening an xls workbook & accessing worksheet). However, it appears that when I add the Reference "Microsoft Excel 14.0 Object Library" the application is getting confused with the standard System.Windows.Forms objects and has the following error: InvalidCastException occured: Unable to cast object of type 'System.Windows.Forms.TextBox' to type 'Microsoft.Office.Interop.Excel.TextBox'. The Invalid Cast error is happening when calling a subroutine & passing the application form controls (check boxes, GridView, TextBox, etc) from my main "Form1" class into a UtilityFunction module. UtilityFunction has a reusable Windows Registry sub routine which retrieves/saves values at application startup/closing. This worked in the past, but now is crashing at the subroutine call in the Form1 class. The exception occurs during application runtime, not during the compile/build.
Also, I deleted the text controls from the form and created them manually, but I'm still getting the same exception error.
I have implemented several basic Excel functions in my vb.net application (opening an xls workbook & accessing worksheet). However, it appears that when I add the Reference "Microsoft Excel 14.0 Object Library" the application is getting confused with the standard System.Windows.Forms objects and has the following error: InvalidCastException occured: Unable to cast object of type 'System.Windows.Forms.TextBox' to type 'Microsoft.Office.Interop.Excel.TextBox'. The Invalid Cast error is happening when calling a subroutine & passing the application form controls (check boxes, GridView, TextBox, etc) from my main "Form1" class into a UtilityFunction module. UtilityFunction has a reusable Windows Registry sub routine which retrieves/saves values at application startup/closing. This worked in the past, but now is crashing at the subroutine call in the Form1 class. The exception occurs during application runtime, not during the compile/build.
Also, I deleted the text controls from the form and created them manually, but I'm still getting the same exception error.