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

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

xjtudll5年前 (2019-04-09)技术心得2720

现象:

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

DSDT常见的Warning

DSDT常见的Warning

黑苹果要想搞的好,少不了DSDT。DSDT在编译的时候,最常见的Warning有以下几种 1、Use of complier reserved name 如图。这种Warning的解决办法是:将“_T_2”改成“T_2” 2、Not all con...

双击打开exe程序和Process.Start区别

问题:使用Process.Start打开.exe程序的时候发现在使用时无法加载启动路径的配置文件。启动代码:Process process = new Process();          &nbs...

金蝶K3系统单据对应ICTemplate表单ID信息

SELECT FID,FCaption FROM ICTemplate where FFieldName = 'FBillCaption' FID    FCaption A01    外购入库单 A02  &n...

Proteus 7.6破解后依旧无法使用解决办法

Proteus7.6 SP4使用完美破解补丁1.1后(详情见http://www.xjtudll.cn/Exp/44/),以前能正常使用,近期发现无法使用,一点空白处,元件就消失了。 网上有人说破解是到2010.3.7就失效了。 我下载了sexywp大牛的“解决pwi退出问题.rar&r...

C# textBox框实现输入下拉列表

C# textBox框实现输入下拉列表

textBox框像百度搜索出现下拉列表的样式,如图: 重点就是要关注:AutoCompleteMode和AutoCompleteSource两种属性。 具体实现代码如下: 将此方法在frmLogin_Load事件里加载, private void bindTxt() {   ...

Keil C51某些汉字不显示bug解决

Keil C51某些汉字不显示bug解决

这个问题是在用ST7920 LCD 12864时发现的,“星期三”中的“三”字显示不出来。经查,发现是Keil编译器的问题,编译器在编译汉字时会将汉字内码0xFD给过滤掉,导致汉字显示不正常。 一、直接用汉字编码 如果直接用编码则不会有这个问题。例如,...

发表评论

访客

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