You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to Refer "Microsoft.Office.Interop.Excel" which is embedded interop types while compile a class.
If I use dynamic type,it can compile succefully and run.
public class Module{
public void Main(){
dynamic xlApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
dynamic wb = xlApp.Workbooks.Add();
MessageBox.Show(wb.Name);
}
}
When I change the Type, compile Error occur.
public class Module{
public void Main(){
var xlApp = (Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
var wb = xlApp.Workbooks.Add();
MessageBox.Show(wb.Name);
}
}
The text was updated successfully, but these errors were encountered:
Coding with Net Framework 4.8
I want to Refer "Microsoft.Office.Interop.Excel" which is embedded interop types while compile a class.
If I use dynamic type,it can compile succefully and run.
When I change the Type, compile Error occur.
The text was updated successfully, but these errors were encountered: