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

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

xjtudll8年前 (2019-04-09)技术心得9130

现象:

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

Qt打包发布程序

Qt打包发布程序

Qt发布程序有两种方式,静态编译和动态编译。静态编译操作繁琐,东拉西扯要N长时间,所以我选择的是动态发布,动态发布有个缺点,就是要附加多个dll文件,传输极为不便,如果能搞成单文件就比较爽了。 本文就是讲述如何将多个文件打包成一个exe文件。 当然,你首先要将Qt编译设置成Release模式,将Re...

Altium Keepout层内覆铜

Altium Keepout层内覆铜

Altium绘制PCB时,PCB Keepout层难免是异形,各种乌七八糟的形状都有可能出现。很多时候,只想在Keepout层内覆铜,该咋办呢? 其实很简单,勾选“Remove Dead Copper”,覆铜时覆盖整个Keepout层,覆铜操作结束后,则只在Keepout...

Doxygen-利用graphviz生成及添加函数关系调用图

Doxygen-利用graphviz生成及添加函数关系调用图

准备工作:安装graphviz。 参考文献:http://hi.baidu.com/rdray/item/7b39b14830ba6c08c116131a 基本配置就不讲了,与生成Html文件类似。请参考:http://xjtudll.cn/Exp/243/ 1、Expert->Dot 要勾选...

BOM各层级计算真实用量

BOM各层级计算真实用量

SELECT * FROM ( select 级别='1',A='A1',B='B1',用量='1',B真实用量='' UNION ALL select 级别='2',A='B1',B='C1',用量='2',B真实用量='' UNION ALL select 级别='3',A='C1...

CRC除法

所有CRC原理介绍中,都会提到CRC除法。CRC除法与算术除法有什么区别呢?下面举个实例来说明。 以下是120 ÷ 9 来举例说明CRC除法: 120 = 1111000 B 9 = 1001 B  ...

SQL去掉小数点有效数字后的所有0

第一种方法 select cast(2.5000000000000   as  real) select cast(2   as  real) select cast(2.00000   as  r...

发表评论

访客

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