我在VB中有以下代码
Private Sub RefreshCharts()
On Error GoTo err_getICHELPER_REFRESH
Application.Cursor = xlWait
Dim objOperationRefresh
Set objOperationRefresh = CreateObject("Charting.AutomationProxy")
Dim a As Variant
Set a = Application
objOperationRefresh.RefreshApplication a
Application.StatusBar = "Refreshing .. "
Do While Len(objOperationRefresh.RefreshStatus) = 0
DoEvents
Loop
Application.StatusBar = "Refreshing Complete."
Set objOperationRefresh = Nothing
Application.StatusBar = ""
Exit Sub
err_getICHELPER_REFRESH:
我已经在C#中进行了转换,但CreateObject("Charting.AutomationProxy").
除外在c#3.0中的含义是什么?
由于
答案 0 :(得分:3)
你可以使用反射:
Type type = Type.GetTypeFromProgID("Charting.AutomationProxy");
object instance = Activator.CreateInstance(type);
与VB和VB.NET相反,C#在C#4.0之前不支持动态类型。由于这是一个COM对象,另一种可能性是生成强类型包装器,这将大大简化使用:在“添加引用”对话框中,从“COM组件”选项卡中选择组件或使用tlbimp.exe实用程序。