反思我有一個COM對象......這是這樣創造的一個實例:Invoke方法使用的COM對象
Type type = TypeDelegator.GetTypeFromProgID("Broker.Application");
Object application = Activator.CreateInstance(type);
當我嘗試調用一個方法:
type.GetMethod("RefreshAll").Invoke(application, null);
- >type.GetMethod("RefreshAll")
返回null
。 當我試圖讓所有的方法與type.GetMethods()
,只有這些方法:
- GetLifetimeService
- InitializeLifetimeService
- CreateObjRef
- 的ToString
- 的Equals
- 的GetHashCode
- 的GetType
RefreshAll方法在哪裏?我該如何援引它?
雖然在當時的罰款答案,C#4使得它更容易下面 – MickyD 2015-02-07 00:12:41
注意通過'dynamic'關鍵字進行COM-互操作,從我的工具HTTPS使用'dynamic'未來://github.com/awaescher/RepoZ我發現它有很多內存泄漏。我轉向Nathan W的答案來解決這個問題!在這裏看到更多:https://stackoverflow.com/questions/33080252/memory-overflow-having-an-increasing-number-of-microsoft-csharp-runtimebinder-s/34123315 – Waescher 2017-08-22 12:26:45
請參閱其他意見MickyD的答案如何處理這個問題... – Waescher 2017-08-22 21:32:33