By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,309 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,309 IT Pros & Developers. It's quick & easy.

Timeout during XmlSerializer instantiation

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
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."

Nov 12 '05 #2

P: n/a
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."

Nov 12 '05 #3

P: n/a
Hi Rangi,

I think it might have something to do with the AntiVirus software. Because
there were precedents with similar stack trace that make timeout happen.

Could you try to run this on a machine without the Antivirus software to
see if it occurs again?

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

Nov 12 '05 #4

P: n/a
I don't think this is caused by anti-virus software. As I mentioned in my
previous post, we call this same code from multiple places in the
application and the only time it fails is when the application is being
closed by closing the main (MDI) window. This may be initiated by the user
clicking the X button or by logging out of Windows (among other
possibilities).

Since it happens so infrequently, we'd have to turn off the anti-virus
software for all our computers to verify that it is not happening. This
course of action will not be acceptable to the company without a clear a
verified reason to do so. I'm sure they wouldn't do it just to test a
theory.

Please let me know if you have any other thoughts on the matter.

Thank you,
Rangi Keen

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:G2**************@cpmsftngxa10.phx.gbl...
Hi Rangi,

I think it might have something to do with the AntiVirus software. Because
there were precedents with similar stack trace that make timeout happen.

Could you try to run this on a machine without the Antivirus software to
see if it occurs again?

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

Nov 12 '05 #5

P: n/a
Hi Rangi,

Some anti-virus software are still monitoring, even you have turned off
from user interface, and the monitoring process is still running. The best
way to test it is to uninstall the anti-virus software and test it on a
clean machine. If you are having concern to uninstall, you can also try it
in Safe Mode. However, I'm not quite sure if some specific anti-virus
software will not loaded in safe mode. HTH.

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

Nov 12 '05 #6

P: n/a
I should have mentioned that I did test the sample I sent on a clean machine
with no Anti-Virus software installed (it has never been installed on this
test computer) and was still able to reproduce the same problem. I think
this points to an issue other than Anit-Virus software.

Rangi

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:%2****************@cpmsftngxa10.phx.gbl...
Hi Rangi,

Some anti-virus software are still monitoring, even you have turned off
from user interface, and the monitoring process is still running. The best
way to test it is to uninstall the anti-virus software and test it on a
clean machine. If you are having concern to uninstall, you can also try it
in Safe Mode. However, I'm not quite sure if some specific anti-virus
software will not loaded in safe mode. HTH.

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

Nov 12 '05 #7

P: n/a
Hi Rangi,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

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

Nov 12 '05 #8

P: n/a
Hi Rangi,

Thanks for your repro code and steps. I have successfully reproduced it on
my machine. I have forwarded it to our developer team. They are currently
working on this issue and trying to find a workaround for you. I will
update you as soon as I get any response from them. Thanks for your
patience!

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

Nov 12 '05 #9

P: n/a
Hi Rangi,

This is expected behavior. Since the system was shutting down, new
processes (csc.exe) could not be created because some DLLs would fail to
initialize at this time.

From the callstack the csc.exe was created when you instantiate the
XmlSerializer object, so a workaround is to instantiate it prior to
Form_closing, as below:

Dim oSerializer As New Serialization.XmlSerializer(GetType(DateTime))

Private Sub Form1_Closing(*)
oSerializer.Serialize(System.IO.File.Create("C:\Te st.xml"),
DateTime.Now)
End Sub

HTH.

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

Nov 12 '05 #10

P: n/a
Thanks. I did end up doing this and I believe it will fix the problem. I
didn't find any mention of this as a potential issue in the MSDN library
documentation. It might be worth adding a note in the remarks of the
constructor documentation to this effect so other people don't run into this
issue.

Thanks again for you help on this issue.

Rangi

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:UF**************@cpmsftngxa10.phx.gbl...
Hi Rangi,

This is expected behavior. Since the system was shutting down, new
processes (csc.exe) could not be created because some DLLs would fail to
initialize at this time.

From the callstack the csc.exe was created when you instantiate the
XmlSerializer object, so a workaround is to instantiate it prior to
Form_closing, as below:

Dim oSerializer As New Serialization.XmlSerializer(GetType(DateTime))

Private Sub Form1_Closing(*)
oSerializer.Serialize(System.IO.File.Create("C:\Te st.xml"),
DateTime.Now)
End Sub

HTH.

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

Nov 12 '05 #11

P: n/a
Hi Rangi,

Thanks for your feedback. I will forward this to the corresponding team.

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

Nov 12 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.