I am trying to host a windows forms control in C# inside an html page and then host that web page in IIS in order to be accessible by other client machines.
The problem is: the user control uses some unmanaged code, which triggers a SecurityPermissionException
when accessing using another machine.
我已设法将我的守则推向一个基本例子,以找出错误,我似乎无法找到答案。
这里我对用户的控制:
// To handle strong named assembly
[assembly: AllowPartiallyTrustedCallers]
namespace WinFormsHTMLControl
{
[SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode = true)] // to allow assertions regarding unmanaged code permissions
public partial class HelloWorldControl : UserControl
{
#region Methods/Consts for Embedding a Window
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
#endregion
public HelloWorldControl()
{
InitializeComponent();
}
private void btnClick_Click(object sender, EventArgs e)
{
new SecurityPermission(PermissionState.Unrestricted).Assert();
IntPtr picBoxHandle = FindWindow("IEFrame", "Internet Explorer");
lblMessage.Text = picBoxHandle.ToString();
SecurityPermission.RevertAssert();
}
}
}
I ve signed the assembly with a key, I ve created a Permission Set in .NET Configuration Tool in order to grant acess to unmanaged code, and created a CodeGroup
pointing to the strong key used to name the assembly.
I ve also created an MSI in order to copy these settings to other machines (i ve done this both at Enterprise and Machine levels).
尽管如此,这部法典在我点击纽芬兰语时仍触发了<条码>安全发射飞跃条码>。
我在这里找不到什么东西?