XmlSerializer实例化期间超时 [英] Timeout during XmlSerializer instantiation

查看:48
本文介绍了XmlSerializer实例化期间超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用XmlSerializer(Type)

构造函数实例化XmlSerializer。这在大多数情况下有效,但有时我会在此过程中获得超时

。我在所有情况下都使用相同的类型,并且在500 MHz到2.6 GHz的多台计算机上发生了
。有没有人知道为什么在这种情况下csc.exe进程会超时?
看起来超时

设置为10分钟,这似乎等待很长时间。


这里是详细的堆栈跟踪如果它有帮助:


等待程序执行超时。正在执行的命令是

" c:\ winnt \microsoft.net \ framework \v1.1.4322 \csc.ex e" / noconfig

@" C:\ TEMP \ qwjndcv1.cmdline"。

at

System.CodeDom.Compiler.Executor。 ExecWaitWithCaptu reUnimpersonated(IntPtr

userToken,String cmd,String currentDir,TempFileCollection tempFiles,

在System.CodeDom.Compiler.Executor.ExecWaitWithCaptu re(IntPtr userToken,

String cmd,String currentDir,TempFileCollection tempFiles,String&

outputName,String& errorName,String trueCmdLine )

在System.CodeDom.Compiler.CodeCompiler.Compile(Compi lerParameters

options,String compilerDirectory,String compilerExe,String arguments,

String& ; outputFile,Int32& nativeReturnValue,String trueArgs)

在System.CodeDom.Compiler.CodeCompiler.FromFileBatch(CompilerParameters

options,String [] fileNames)

at

System.CodeDom.Compiler.CodeCompil er.FromSourceBat ch(CompilerParameters

options,String [] sources)

at System.CodeDom.Compiler.CodeCompiler.FromSource(Co mpilerParameters

选项,字符串来源)

at

System.CodeDom.Compiler.CodeCompiler.System.CodeDo m.Compiler.ICodeCompiler.C

ompileAssemblyFromSource( CompilerParameters选项,字符串源)

在System.Xml.Serialization.Compiler.Compile()

在System.Xml.Serialization.TempAssembly..ctor(XmlMap ping [] xmlMappings)

在System.Xml.Serialization.XmlSerializer..ctor(类型类型,字符串

defaultNamespace)

在System.Xml.Serialization .XmlSerializer..ctor(类型类型)


谢谢,

Rangi

解决方案

您好Rangi,


首先,我想确认一下我对您的问题的理解。来自

您的描述,我知道您在XmlSerialization期间偶尔会遇到异常

。如果有任何误解,请随意告诉我。


根据我的研究,这可能与防病毒有关
你机器上的
软件。我认为反病毒软件在非共享模式下锁定了文件,而c#编译器无法访问它。

从反病毒中排除C#文件可能会修复问题。


HTH。


Kevin Yu

=======

此帖子已提供按原样没有保证,也没有赋予

权利。


您的理解是正确的。暂停只是偶尔发生(少于1%的时间)。当用户关闭主要的

应用程序窗口而不是使用文件 - >时,似乎会发生这种情况。退出命令。在这种情况下,

XmlSerializer是在主窗体

窗口的OnClosing方法中创建的。我还没有看到过这个错误,虽然我知道它是从代码中的其他三个地方调用的,大致相同的频率

这将是。我不知道用户如何关闭主应用程序

窗口(使用X按钮,退出Windows,右键单击

任务栏,等等。)。这些方法中的一种是否会比其他任何方法更经常导致超时?


我们在同一个XmlSerializer期间也看到了另一个问题

初始化。这是一个WinIOError,我也只是在调用OnClosing时看到了这个

(不是任何其他地方叫做

)。这个似乎比超时

(可能大约1-2%的时间)更频繁地发生。这可能是一个相关问题吗?


这里是完整的错误和堆栈跟踪:


无法找到文件C: System.IO上的\ Temp\\\
slcxwiy.dll"。

.__。Error.WinIOError(Int32 errorCode,String str)
System.IO.FileStream..ctor上的
(字符串路径,FileMode模式,FileAccess

访问,FileShare共享,Int32 bufferSize,布尔useAsync,字符串msgPath,

布尔bFromProxy)

at System.IO.FileStream..ctor(String path,FileMode mode,FileAccess

access,FileShare share)

at System.CodeDom.Compiler.CodeCompiler.FromFileBatch(CompilerParameters

options,String [] fileNames)

at

System.CodeDom.Compiler.CodeCompiler.FromSourceBat ch(CompilerParameters
$ b $ System.CodeDom.Compiler.CodeCompiler.FromSource上的b选项,字符串[]来源)

(Co mpilerParameters

选项,字符串来源)



System.CodeDom.Compiler.Code Compiler.System.CodeDo m.Compiler.ICodeCompiler.C

ompileAssemblyFromSource(CompilerParameters options,String source)

at System.Xml.Serialization.Compiler.Compile()
(XmlMap ping [] xmlMappings)
System.Xml.Serialization.XmlSerializer..ctor上的
(Type type,String

defaultNamespace)

在System.Xml.Serialization.XmlSerializer..ctor(类型类型)

...

at< Application> .MainForm.OnClosing(CancelEventArgs e)

...


我们在所有计算机上都安装了Symantec AntiVirus软件br />
确实进行实时文件检查。在ExecWaitWithCaptureUnimpersonated方法中,这会导致C#编译器超时10分钟吗?我会

认为锁定或无法访问的文件会立即导致错误。


谢谢,

Rangi


" Kevin Yu [MSFT]" <,V - **** @ online.microsoft.com>在消息中写道

news:s


*************** @ cpmsftngxa10.phx.gbl ... < blockquote class =post_quotes>嗨Rangi,

首先,我想确认一下我对你的问题的理解。从您的描述中,我了解到您在XmlSerialization期间偶尔会遇到异常。如果有任何误解,请随时告诉我。

根据我的研究,这可能与您机器上的防病毒软件有关。我认为反病毒软件是以非共享模式锁定文件而c#编译器无法访问它。
从反病毒中排除C#文件可能会解决问题。
< HTH。

Kevin Yu
=======
这个帖子是按原样提供的没有保证,也没有赋予
权利。



I am instantiating an XmlSerializer using the XmlSerializer(Type)
constructor. This works most of the time, but sometimes I get a timeout
during the process. I''m using the same type in all cases and it has happened
on multiple computers ranging from 500 MHz to 2.6 GHz. Does anyone know why
the csc.exe process would time out in this case? It looks like the timeout
is set to 10 minutes which seems like a long time to wait for something.

Here''s the detailed stack trace if it helps:

Timed out waiting for a program to execute. The command being executed was
"c:\winnt\microsoft.net\framework\v1.1.4322\csc.ex e" /noconfig
@"C:\TEMP\qwjndcv1.cmdline".
at
System.CodeDom.Compiler.Executor.ExecWaitWithCaptu reUnimpersonated(IntPtr
userToken, String cmd, String currentDir, TempFileCollection tempFiles,
String& outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.Executor.ExecWaitWithCaptu re(IntPtr userToken,
String cmd, String currentDir, TempFileCollection tempFiles, String&
outputName, String& errorName, String trueCmdLine)
at System.CodeDom.Compiler.CodeCompiler.Compile(Compi lerParameters
options, String compilerDirectory, String compilerExe, String arguments,
String& outputFile, Int32& nativeReturnValue, String trueArgs)
at System.CodeDom.Compiler.CodeCompiler.FromFileBatch (CompilerParameters
options, String[] fileNames)
at
System.CodeDom.Compiler.CodeCompiler.FromSourceBat ch(CompilerParameters
options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(Co mpilerParameters
options, String source)
at
System.CodeDom.Compiler.CodeCompiler.System.CodeDo m.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)

Thanks,
Rangi

解决方案

Hi Rangi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you got an exception occasionally
during an XmlSerialization. If there is any misunderstanding, please feel
free to let me know.

Based on my research, this might have something to do with the anti-virus
software on your machine. I think that the anti-virus software is locking
the file in non shared mode and c# compiler not able to access it.
Excluding C# files from the anti virus might fix the problem.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Your understanding is correct. The timeout happens only occasionally (less
than 1% of the time). It seems to be happening when the user closes the main
application window rather than using the File -> Exit command. In this case,
the XmlSerializer is created during the OnClosing method of the main form
window. I have not seen this error any other time, although I know it is
called from three other places in the code with roughly the same frequency
this would be. I don''t know how the users are closing the main application
window (using the X button, logging out of Windows, right clicking it in the
task bar, etc.). Could one of these methods cause this timeout more often
than any of the other methods?

We have also been seeing another issue during the same XmlSerializer
initialization. This one is a WinIOError and I have also only seen this
during the call to OnClosing (not any of the other places it is called
from). This one appears to happen somewhat more frequently than the timeout
(probably around 1-2% of the time). Could this be a related issue?

Here''s the complete error and stack trace:

Could not find file "C:\Temp\nslcxwiy.dll".
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share)
at System.CodeDom.Compiler.CodeCompiler.FromFileBatch (CompilerParameters
options, String[] fileNames)
at
System.CodeDom.Compiler.CodeCompiler.FromSourceBat ch(CompilerParameters
options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(Co mpilerParameters
options, String source)
at
System.CodeDom.Compiler.CodeCompiler.System.CodeDo m.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMap ping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
...
at <Application>.MainForm.OnClosing(CancelEventArgs e)
...

We do have Symantec AntiVirus software installed on all our computers and it
does do realtime file checking. Could this be causing a 10 minute timeout of
the C# compiler during the ExecWaitWithCaptureUnimpersonated method? I would
think a locked or inaccessible file would cause an immediate error.

Thanks,
Rangi

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:s


***************@cpmsftngxa10.phx.gbl...

Hi Rangi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you got an exception occasionally
during an XmlSerialization. If there is any misunderstanding, please feel
free to let me know.

Based on my research, this might have something to do with the anti-virus
software on your machine. I think that the anti-virus software is locking
the file in non shared mode and c# compiler not able to access it.
Excluding C# files from the anti virus might fix the problem.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."



这篇关于XmlSerializer实例化期间超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆