我有一个C#/ .NET(VS2010)IE插件,它使用Marshal.GetActiveObject()
来运行一个应用程序实例(COM对象),然后通过Invoke()
方法向它发送命令。在XP中,它工作正常。在W7/Vista中,它需要IE和目标应用是“以管理员身份运行”,否则它产生的例外:是否可以提升IE .NET插件的安全性?
[Operation unavailable (Exception from HRESULT:0x8000401E3 MK_E_UNAVAILABLE))]
下面的代码:
private void _BtnPlace_onclick(IHTMLEventObje)
{
....
....
object AutoCADApp = null;
try
{
// Does not return the object from the Running Objects Table unless run 'As Administrator'
AutoCADApp = System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");
}
catch (Exception ex)
{
MessageBox.Show("Unable to locate a running version of AutoCAD on this machine. Please make sure AutoCAD is running.\n\n [" + ex.Message + "]\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
object acadDoc = GetProperty(AutoCADApp, "ActiveDocument");
InvokeMethod(acadDoc, "SendCommand", keyin);
}
如何任何想法解决安全问题,使这个附加运行在W7/Vista(要求它提示升级特权是好的)?