【发布时间】:2014-03-05 04:53:01
【问题描述】:
我目前正在使用 Powershell 调用以下 com 对象,但无法将代码转换为 c#。我知道这应该很简单,而且可能是一个愚蠢的问题,所以如果我看起来像个白痴,我深表歉意。
Powershell:
$nDeviceId=517
$wug = New-Object -ComObject CoreAsp.EventHelper
$wug.SendChangeEvent(2,$nDeviceId,1)
当前的 C# 尝试:
Type type = TypeDelegator.GetTypeFromProgID("CoreAsp.EventHelper");
Object application = Activator.CreateInstance(type);
pplication.GetType().InvokeMember("SendChangeEvent", BindingFlags.InvokeMethod, null, application, new object[]{2,517,1});
感谢您的帮助!
更新: 当我运行 c# 代码时,我没有收到任何错误。
【问题讨论】:
标签: c# powershell