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

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

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

现象:

在某一台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://xjtudll.cn/Exp/541/

标签: C#
分享给朋友:

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

MSP430 fail to initialize device解决

MSP430 fail to initialize device解决

日前,在用MSP430 USB仿真器下载程序的时候,突然提示“fail to initialize device”,碰到这个问题,我的第一反应就是检查下载线与单片机是否连接正确,仔细检查了一遍连线,发现连接无误,但是就是每次都提示“fail to initialize device”,然后无法...

Proteus error:

Proteus error:"probe object xxx is ambigously placed"

Proteus仿真时,在添加电流探针以后,提示error "probe object xxx is ambigously placed" 如图所示: 原因: 电流探针仿真的时候那个电流的符号要和导线的方向一致 出现问题就是因为这个 解决办法: 改变电流探针方向,使之与导线方向...

ios宏: 判断是否是retina屏,是否iPad,设备判断(4,5,5s,6等)

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #def...

IIS HTTP 500错误解决

操作系统:Windows XP SP3 IIS:6.0 IIS安装完成,一运行出现“HTTP 500 - 内部服务器错误”,网上找了一圈,处理方法那个叫复杂,在研究完复杂方法之后,发现只要三步就可以解决问题了: 1. 运行:regsvr32 %windir%/syste...

ML610Q473 程序烧录

ML610Q473 程序烧录

仿真器能够仿真程序的运行,但毕竟是“仿”,与实际情况可能有些出入,因此最终还是要将程序烧录到实际的目标板中。 对于ML610Q473,大体要有这么几步: (1) uEase与目标板连接 (2) 生成Hex文件 (3)转换Hex文件供烧录 1、uEase与目标板连接 (1)...

Windows10 安装软件时提示 the error code is 2503/2502 错误解决办法

Windows10 安装软件时提示 the error code is 2503/2502 错误解决办法

问题内容:Windows10 安装软件时提示“ the error code is 2503/2502”错误代码分析原因:由于安装.msi格式的软件时,无法使用管理员身份运行,导致权限不够,从而引起2503/2502代码的错误解决方法:设置 C:\WINDOWS\TEMP的权限1、依次打开“ 我的电...

发表评论

访客

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