XML object reverse sequence is also dynamically compiled?

xiaoxiao2021-03-06  72

I have encountered a very strange problem today and I can't reproduce it. A object is deserved from an XML file when a class is constructed. Under normal circumstances, there will be a problem in a very small number of cases.

System.Runtime.InteropServices.ExternalException: Timed out waiting for a program to execute The command being executed was. "C: /windows/microsoft.net/framework/v1.1.4322/csc.exe" / noconfig @ "C: / DOCUME ~ 1 / montaq ~ 1 / LOCALS ~ 1 / Temp / prfmes01.cmdline ". at System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated (IntPtr userToken, String cmd, String currentDir, TempFileCollection tempFiles, String & outputName, String & errorName, String trueCmdLine) at System.CodeDom.Compiler.Executor.ExecWaitWithCapture (IntPtr userToken, String cmd, String currentDir, TempFileCollection tempFiles, String & outputName, String & errorName, String trueCmdLine) at System.CodeDom.Compiler.CodeCompiler.Compile (CompilerParameters options, String compilerDirectory, String CompileRexe, String Arguments, String & OutputFile, INT32 & OUTPUTFILE, INT32 & OUTPUTFILE

nativeReturnValue, String trueArgs) at System.CodeDom.Compiler.CodeCompiler.FromFileBatch (CompilerParameters options, String [] fileNames) at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch (CompilerParameters options, String [] sources) at System.CodeDom.Compiler. CodeCompiler.FromSource (CompilerParameters options, String source) at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSource (CompilerParameters options, String source) at System.Xml.Serialization.Compiler.Compile () at System. Xml.Serialization.TempAssembly..ctor (XmlMapping [] xmlMappings) at System.Xml.Serialization.XmlSerializer..ctor (Type type, String defaultNamespace) at System.Xml.Serialization.XmlSerializer..ctor (Type type) at XmlState. .ctor (String path) at AutoUpdateingAddin.Updater..ctor (String hostAppExeFullPath) at AutoUpdateingAddin.Form1.CheckUpdate () at AutoUpdateingAddin.Form1.Form1_Load (Object sender, EventArgs e) at System.Windows.Forms.For m.OnLoad (EventArgs e) at System.Windows.Forms.Form.OnCreateControl () at System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl () at System.Windows. Forms.Control.WmShowWindow (Message & m) at System.Windows.Forms.Control.WndProc (Message & m) at System.Windows.Forms.ScrollableControl.WndProc (Message & m) at System.Windows.Forms.ContainerControl.WndProc (Message & m ) at System.Windows.Forms.Form.WmShowWindow (Message & m) at System.Windows.Forms.Form.WndProc (Message & m) at System.Windows.Forms.ControlNativeWindow.OnMessage (Message & m) at System.Windows.Forms. ControlnativeWindow.WndProc (Message &

m) at system.windows.Forms.nativeWindow.callback (intptr hwnd, int32 msg, intptr wparam, intptr lparam) XML file is inconvenient, and the program will not change, and sometimes there is such an error. From this error, when the object is reverse selecinstened, the dynamic compilation will be called, first dynamically generate some code, and then compile execution. Hoho, the middle result is placed in the TEMP file. Delete him at the end of the execution. Verified it with Reflector, and it is. (y) In order to test, I wrote a simple anti-sequence program to create a new class.

Using

System;

Using

System.xml;

Using

System.xml.Serialization;

Namespace

XMLDemo

{[XMLROOT ("Person", Namespace = "")] public class person {[XMLELEMENT ("Personname")] public string name;}}}

Then I generate an instance of such a class and write it to the XML file. The contents of the file are as follows

XML Version = "1.0"

?>

-

<

Person

XMLns: XSD

= "http://www.w3.org/2001/xmlschema"

XMLns: XSI

= "http://www.w3.org/2001/xmlschema-instance"

>

<

Personname

>

MONTAQUE

Personname

>

<

AGE

>

30

AGE

>

Person

>

The next step is to remember this class, remember to reference system.runtime.serialization.dll

code show as below

System.xml.Serialization.xmlSerializer XR

=

New

System.xml.Serialization.xmlSerializer

Typeof

(Person); System.IO.FileStream FS

=

New

System.IO.FileStream

"

C: //test.xml

"

, System.IO.FileMode.Open, System.IO.FileAccess.read; Person P

=

(Person) Xr.Deserialize (fs); console.writeline (p.Name);

There is no problem in running results. During the operation, I used the file monitor to solidly csc.exe, and he gently became the middle CS, then compiled. . . As shown below

转载请注明原文地址:https://www.9cbs.com/read-92506.html

New Post(0)