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

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

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

现象:

在某一台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无法创建文件或目录” 的相关文章

Android MultiSelectListPreference, java.lang.String cannot be cast to java.util.Set

问题及现象: 尝试添加一个 MultiSelectListPreference到设置界面,MultiSelectListPreference基本代码如下: <MultiSelectListPreference android:title="@string/title" an...

浅析电波表——德国DCF码

浅析电波表——德国DCF码

参考文献:   http://en.wikipedia.org/wiki/DCF77 http://www.ptb.de/en/publikationen/news/html/news032/artikel/03207.htm http://www.ptb.de/cms/index.php...

Sqlserver 查询所有存储过程、视图等的名称和具体代码

Sqlserver 查询所有存储过程、视图等的名称和具体代码

https://blog.csdn.net/qq_40205468/article/details/88415849 通过系统视图可以查看到所有模块对象下的单一实体的名称和具体的实现代码          &n...

程序加载水晶报表

重点就是doc.load ReportDocument doc = new ReportDocument();         TreeEntityList sources = new TreeEntityList (); &nb...

金蝶K3-销售价取价规则什么?按什么优先级?

【系统逻辑】销售价格取值规则如下:1、销售价格取值优先顺序:价格政策-基本价格政策-物料参考售价。2、不同价格政策下,同一物料的价格,按照销售价格政策优先级取值,优先级数字越小越优先;3、相同价格政策下,同一物料存在多个条目时,优先取符合条件最后审核的价格条目。...

WinRAR创建自解压程序

WinRAR创建自解压程序

前面提到了用FilePacker来打包文件夹(http://www.xjtudll.cn/Exp/63/),这次介绍的是用WinRAR来创建自解压程序,从而实现发布单文件程序的目的。当然,你也可以另作他用。WinRAR相当普及,几乎人人电脑上都有。如何用WinRAR创建自解压程序呢?且看下面分解。1...

发表评论

访客

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