当前位置:首页 > 技术心得 > 正文内容

C# XmlSerializer无法创建文件或目录

xjtudll7年前 (2019-04-09)技术心得6870

现象:

在某一台XP机器上,时而正常,时而弹出无法创建文件或目录

错误具体信息:

在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

在 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, Boolean useLongPath)

在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)

在 Microsoft.CSharp.CSharpCodeGenerator.GetResponseFileCmdArgs(CompilerParameters options, String cmdArgs)

在 Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)

在 Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)

在 Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)

在 System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)

在 System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)

在 System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)

在 System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)

在 System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)

在 System.Xml.Serialization.XmlSerializer..ctor(Type type)

在 XonixERP.Common.AppConfigSetting.get_Config()

在 DLL.ERP.WinFormUI.ClassUtil.CreateInstance(Type type)

在 XonixERP.View.LogonForm.btnLogin_Click(Object sender, EventArgs e)

在 System.Windows.Forms.Control.OnClick(EventArgs e)

在 System.Windows.Forms.Button.OnClick(EventArgs e)

在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

在 System.Windows.Forms.Control.WndProc(Message& m)

在 System.Windows.Forms.ButtonBase.WndProc(Message& m)

在 System.Windows.Forms.Button.WndProc(Message& m)

在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

原因分析:XmlSerializer 运行时所属的帐户或安全环境需要有访问temp 目录的权限

解决办法:

更改权限

1、若C盘是FAT格式,需要将TEMP目录,TMP目录迁移。若C盘是NTFS格式,可跳过此步。

470b234a-2ee7-48c8-8188-a34949ec08a2

2、迁移到NTFS目录后,修改目录权限,允许登录的账户读写

如果没有安全选项卡

点掉"使用简单文件共享",是取消掉它,而不是勾上,一定要注意这一点

a0512321-8320-4439-a893-26f9868cb65c

有没有发现,"安全"选项卡已经出来了

c5e14fa3-0b1c-41ec-a902-f8514576a952

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://www.xjtudll.cn/Exp/541/

标签: C#
分享给朋友:

“C# XmlSerializer无法创建文件或目录” 的相关文章

Multisim运放输出超过电源电压解决

Multisim运放输出超过电源电压解决

在使用Multisim自带库里的运放的时候,例如LM324M,发现一个问题,运放的输出电压能达到几百V甚至几千V,而电源明显只有几V而已。输出电压超过电源电压,理论上是不可能的,实际上也是不可能的,那么肯定就是仿真有误了,其实根本原因是Multisim里面运放是三脚模型,根本没考虑电源。我们查看LM...

Itunes搜索——找正版免费软件的利器

Itunes搜索——找正版免费软件的利器

一直以为ipad不越狱没啥游戏可玩的,其实不然,itunes store大把的免费正版软件   打开iTunes,选择菜单上的 Store ,再选择“搜索”:  然后,先选择“应用软件”,例如,想找所有免费的游戏,而且是IP...

c# toolstrip控件怎么把左边的几个小点去掉

c# toolstrip控件怎么把左边的几个小点去掉

c# toolstrip控件怎么把左边的几个小点去掉 小点如下图所示: 解决办法: 选中你的toolstrip 然后属性 属性中有个 GripStyle 设置Hidden...

HP Laserjet 1020 在Mac OSX下的安装

HP Laserjet 1020 在Mac OSX下的安装

这个教程是在Mac OSX 10.8操作系统下实现的,但是升级到10.9后,依旧能正常使用。 公司的打印机是HP Laserjet 1020,打印服务器和其他同事的电脑都是Windows系统,这个驱动还是很容易搞定的。 现在有一台Mac Mini,需要连打印机,但是官方不支持Mac OSX。在惠普网...

C#将图片白色背景设置为透明

红色部分是关键 Image image = System.Drawing.Image.FromFile(@"C:\A.JPG"); Bitmap pbitmap = new Bitmap(image); pbitmap.MakeTransparent(Color.White);...

Altium连续选择多个元件

Altium连续选择多个元件

以前在Protel99SE中,选中一个元件后,只要不取消选择(deselect),还可以接着选择元件,一直到足够为止。而Altium默认设置中,选择元件后,若你单击了PCB其他区域,之前的选择将失效,只能通过 Shift+鼠标单击来完成多个元件的选择。这种做法使得从Protel99SE转过来的用户极...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。