我有一個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(要求它提示升級特權是好的)?