I want to get Excel events in late binding without Excel dll. I can get events with my code in target cpu in "AnyCpu" and "x64" but am unable to get the same result in target cpu "x86". I need to run my application in "x86".
I have created my Excel object as follows:
Dim ExcelType As Object = Type.GetTypeFromProgID("Excel.Application")
Dim exlApp As Object= Activator.CreateInstance(ExcelType)
Dim evSheetActivate As EventInfo = ComType.GetEvent("SheetActivate")
If my TargetCpu is "AnyCpu" or "x64", object ExcelType
shows "Microsoft.Office.Interop.Excel.ApplicationClass".
If my TargetCpu is "x86", ExcelType
shows "System.__ComObject".
If it comes like "System.__ComObject" I am unable to get my events.
Am I able to cast "System.__ComObject" into "Microsoft.Office.Interop.Excel.ApplicationClass", or is there any other solution to resolve this?