在管理员帐户中运行 Visual Studio 时无法触发拖放事件

Tru*_*uan 2 c# drag-and-drop administrator winforms

我使用 Visual Studio 2008、.net Framework 3.5

我有一个 webservice 应用程序(一个使用 webservice 的 winform 客户端),我必须在管理员帐户中运行它

我需要将文件从 Windows 资源管理器拖放到此应用程序的窗体中。

这是我的代码:

this.AllowDrop = true;

private void Form1_DragEnter(object sender, DragEventArgs e)
    {

        if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
            e.Effect = DragDropEffects.All;
    }

private void Form1_DragDrop(object sender, DragEventArgs e)
    {
        string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
        foreach (string s in fileList)
        {
            MessageBox.Show(s);
        }

    }
Run Code Online (Sandbox Code Playgroud)

当我以普通帐户运行时它可以工作,但在管理员帐户中则不能。怎么解决呢?

Emp*_*pus 5

这里也提出了这个问题: 拖放在 C# 中不起作用 答案是“从 Windows Vista 开始,由于用户界面权限隔离,您无法从运行在较低完整性级别的应用程序拖放到运行在较高完整性级别的应用程序”等级。”

请参阅http://blogs.msdn.com/b/patricka/archive/2010/01/28/q-why-doesn-t-drag-and-drop-work-when-my-application-is-running-elevated -a-mandatory-integrity-control-and-uipi.aspx了解详细信息

PS 引用重复的评论也是正确的。