A
anthony.gilliam
Hi Programmer People,
I'm not an expert programmer, so please be understanding:
I've made a program that uses a DataGridView to display and edit a
DataSet. The DataSet is read from an .XML document. Changes on the
DataGridView are read and writen to the .XML using DataSet.ReadXml
and DataSet.WriteXml.
I've built and debuged the program on my computer and it works fine,
the XML file reads and writes properly. The problem I have is when I
try to open the program from a shortcut on another computer on my
local network. The .XML file will not load to the DataGridView. I
get this error:
************** Exception Text **************
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.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String
role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Data.DataSet.ReadXml(XmlReader reader, Boolean
denyResolving)
at System.Data.DataSet.ReadXml(String fileName)
at TdsInventory.OverviewForm.OverviewForm_Load(Object sender,
EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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
I've added these permissions to my code in the Main(string[] args)
function:
FileIOPermission f1 = new
FileIOPermission(PermissionState.None);
f1.AllLocalFiles = FileIOPermissionAccess.Read;
FileIOPermission f2 = new
FileIOPermission(FileIOPermissionAccess.Read,
@"C:\Projects\TdsInventory");
f2.AddPathList(FileIOPermissionAccess.Write |
FileIOPermissionAccess.Read,
@"C:\Projects\TdsInventory\PaperToner.xml");
I've also gone in the mscorcfg.msc .NET Configuration Tool under:
Runtime Security Policy->All_Code->LocalIntranet_Zone Code Group->Edit
Code Group Properties
And have made the following changes:
Membership Condition->Choose the condition type for this code group:
Zone
Membership Condition->Zone: Local Intranet
Permission Set->Permision set: FullTrust
Still, I compile the code and it runs fine on my computer, but will
load the .XML to the DataGridView on a Local Network computer. If
anyone knows what I need to do to make it work, I'd really appreciate
it!
TIA
I'm not an expert programmer, so please be understanding:
I've made a program that uses a DataGridView to display and edit a
DataSet. The DataSet is read from an .XML document. Changes on the
DataGridView are read and writen to the .XML using DataSet.ReadXml
and DataSet.WriteXml.
I've built and debuged the program on my computer and it works fine,
the XML file reads and writes properly. The problem I have is when I
try to open the program from a shortcut on another computer on my
local network. The .XML file will not load to the DataGridView. I
get this error:
************** Exception Text **************
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.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String
role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Data.DataSet.ReadXml(XmlReader reader, Boolean
denyResolving)
at System.Data.DataSet.ReadXml(String fileName)
at TdsInventory.OverviewForm.OverviewForm_Load(Object sender,
EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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
I've added these permissions to my code in the Main(string[] args)
function:
FileIOPermission f1 = new
FileIOPermission(PermissionState.None);
f1.AllLocalFiles = FileIOPermissionAccess.Read;
FileIOPermission f2 = new
FileIOPermission(FileIOPermissionAccess.Read,
@"C:\Projects\TdsInventory");
f2.AddPathList(FileIOPermissionAccess.Write |
FileIOPermissionAccess.Read,
@"C:\Projects\TdsInventory\PaperToner.xml");
I've also gone in the mscorcfg.msc .NET Configuration Tool under:
Runtime Security Policy->All_Code->LocalIntranet_Zone Code Group->Edit
Code Group Properties
And have made the following changes:
Membership Condition->Choose the condition type for this code group:
Zone
Membership Condition->Zone: Local Intranet
Permission Set->Permision set: FullTrust
Still, I compile the code and it runs fine on my computer, but will
load the .XML to the DataGridView on a Local Network computer. If
anyone knows what I need to do to make it work, I'd really appreciate
it!
TIA