How to solve the FileIOPermission problem?

M

Marquis

I have put the C# Form onito the Internet as an ActiveX Control.
However, I cannot do the FileOpen Dialog as I don't have permission,
how to solve this problem?

Below is the error code:
System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Windows.Forms.FileDialog.set_RestoreDirectory(Boolean
value)
at ModelCarPonXLS.ModelCarPonXLSControl.bBrowse_Click(Object sender,
EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission
The Zone of the assembly that failed was:
Internet
 
G

Guest

Marquis said:
I have put the C# Form onito the Internet as an ActiveX Control.
However, I cannot do the FileOpen Dialog as I don't have permission,
how to solve this problem?

Hello Marquis,

The recommended way to resolve this is to sign the assembly in question
using a strong name key pair (created using the SN.exe tool) and create a
separate .NET Security Policy code group for the aforementioned assembly.
This code group would be given FullTrust, or at least file I/O permissions.

You can read the steps to achieve this at MSDN Blogs
(http://blogs.msdn.com/shawnfa/archive/2003/06/20/57023.aspx).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top