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

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

xjtudll6年前 (2019-04-09)技术心得3550

现象:

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

找回丢失的“显示桌面”图标

Windows快速启动栏里面有个“显示桌面”的图标,点击图标就能快速切换到桌面,这个用起来很方便,当然用Windows+D快捷键也能实现该功能,不过对于我这种习惯用鼠标点击的人来说,还是“显示桌面”这个用起来爽。今天,一不小心,将“显示桌面...

金蝶K3 销售订单关闭逻辑

关闭标志:当销售订单关联数量大于等于销售订单的时候,自动打上关闭标志。行业务关闭标志:当销售订单该分录的出库数量大于等于销售订单该分录数量时,该分录行自动打上行业务关闭标志。在启用发货通知单功能后,如发货通知单的数量等于销售订单数量,此时销售订单就会是关闭状态,但行业务未关闭当发货通知单的关联数量大...

ListView.setOnItemClickListener 点击无效

如果ListView中的单个Item的view中存在checkbox,button等view,会导致ListView.setOnItemClickListener无效, 事件会被子View捕获到,ListView无法捕获处理该事件. 解决方法: 在checkbox、button对应的view处加...

XCode 模拟器完整分辨率截屏

XCode 模拟器完整分辨率截屏

选中模拟器 window-->去掉Show Device Bezels的勾选 -->Zoom 然后cmd + s 保存...

iOS:TabBar的图片不显示,只显示灰色的正方形

问题: tabbar上的图片变成一块正方形的灰色块块,原先的图片没有了。 原因: tabbar上的图片本质上不是一个图片,而是一个形状图片。系统对我们使用的图片也只是把其中的形状"抠"出来,其余的背景什么的都不要。因为我们可能给背景加了颜色,所以系统"抠"的时...

NodeMCU无限打印:wifi_event_monitor_handle_event_cb is called

NodeMCU一直输出: wifi event monitor handle event cb is called wifi event monitor handle event cb is called wifi event monitor handle event cb is ca...

发表评论

访客

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