2011-07-20 21 views
2

私のコンピュータで正常に動作するプログラムを作成しました。通常は他のコンピュータでも動作します。CSC.EXEでバグを逆シリアル化するXmlSerializer

System.Runtime.InteropServices.ExternalException(0x80004005が): Impossibile eseguireの国連programma は、しかし、それを実行すると、スタックトレースは、なぜ私は本当に理解していない時に問題が発生している一人があります。 "C:¥Windows¥Microsoft.NET¥Framework64¥v4.0.30319¥c sc.exe"/noconfig /fullpaths @ "C:¥Users¥Andry¥AppData¥Local¥Temp¥dot0eqxi.cmdli ne "。 ---> System.ComponentModel.Win32Exception(0x80004005が):System.CodeDom.Compiler.Executor.ExecWaitWithCaptu reUnimpersonated(SafeUserTokenHandleはUserToken、文字列CMD、列 currentDir、TempFileCollectionの一時ファイル、文字列& outputName、不明なエラー (0x36b1) マイクロソフトで System.CodeDom.Compiler.Executor.ExecWaitWithCaptu 再(SafeUserTokenHandleはUserToken、文字列のCMD、文字列currentDir、 TempFileCollectionの一時ファイル、文字列& outputName、文字列& ERRORNAME、 文字列trueCmdLine)のString & ERRORNAME、文字列のtrueCmdLine) .CSharp.CSharpCodeGenerator.Com マイクロソフトで杭(コンピlerParameters オプション、& OUTPUTFILE、のInt32 & nativeReturnValue、文字列 trueArgs文字compilerDirectory、文字compilerExe、文字列 引数、String)をMicrosoft.CSharp.CSharpCodeGenerator.FromFileBatch 中(CompilerParametersオプション、String []型のファイル名) システムにおけるMicrosoft.CSharp.CSharpCodeGenerator.System.CodeDo m.Compiler.ICodeCompiler.CompileAssemblyFromSourceバッチ(CompilerParametersオプション、文字列[]源)で.CSharp.CSharpCodeGenerator.FromSourceBat CH(CompilerParametersオプション、文字列[]源) .Xml.Serialization.Compiler.Compile(アセンブリ親、String ns、) mbly System.Xml.Serialization.TempAssembly.GenerateAsseでXmlSerializerCompilerParametersのxmlParameters、証拠の証拠)([] xmlMappingsをXmlMappingは、 で[]種類、文字列defaultNamespace、証拠の証拠、 XmlSerializerCompilerParametersパラメータ、アセンブリアセンブリ、 ハッシュテーブルアセンブリ)を入力しますSystem.Xml.Serialization.TempAssembly..ctor(XmlMap ping [] xmlMappings、 タイプ[]型、String defaultNamespace、String location、Evidence evidence)in System.Xml.Serialization.XmlSerializer..ctor(タイプタイプ、 String defaultNamespace)を のSpellCaster3.Program.Main()

()内のSpellCaster3.Program.LoadBaseRange

問題がわかるように、デシリアライゼーション(そのオブジェクトは逆シリアル化のみ)に接続され、XmlSerializerコンストラクタで発生します。私はobviuslyバグを複製することはできませんWhy is my windows service launching instances of csc.exe?Why is my windows service launching instances of csc.exe?

問題はこの質問にいくつかの方法で接続することができます。 ここにコードが含まれています:

プログラム。CS

private static void LoadBaseRange() 
    { 
     string fileIconImageIndices = Application.StartupPath + Path.DirectorySeparatorChar + "ValidIconImageIndices.xml"; 
     if (!File.Exists(fileIconImageIndices)) throw new FileNotFoundException("Attenzione, il file degli indici delle immagini non è stato trovato"); 

     using (StreamReader reader = new StreamReader(fileIconImageIndices, Encoding.UTF8)) 
     { 
      XmlSerializer serializer = new XmlSerializer(typeof(RangeCollection)); 
      Forms.GumpPicker.BaseRange = serializer.Deserialize(reader) as RangeCollection; 
     } 
    } 

    /// <summary> 
    /// Punto di ingresso principale dell'applicazione. 
    /// </summary> 
    [STAThread] 
    static void Main() 
    { 
     Application.EnableVisualStyles(); 
     Application.SetCompatibleTextRenderingDefault(false); 
     Application.ApplicationExit += new EventHandler(Application_ApplicationExit); 
     try 
     { 
      LoadBaseRange(); 
     } 
     catch (FileNotFoundException fileException) 
     { 
      ErrorForm.Show(fileException.Message + "\nL'applicazione verrà terminata", fileException); 
      return; 
     } 
     catch (Exception exception) 
     { 
      ErrorForm.Show("L'applicazione verrà terminata", exception); 
      return; 
     } 

RangeCollection.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Xml; 
using System.Xml.Serialization; 

namespace Expand.Linq 
{ 
    public class RangeCollection : IXmlSerializable 
    { 
     public static readonly Version Version = new Version(1, 0, 0, 0); 

     internal static Version FoundVersion { get; private set; } 

     /// <summary> 
     /// Used for xml deserialization 
     /// </summary> 
     public RangeCollection() { } 

     public RangeCollection(IEnumerable<IEnumerable<int>> ranges) 
     { 
      Range = ConvertToListInt(ranges); 
     } 

     private List<int> ConvertToListInt(IEnumerable<IEnumerable<int>> ranges) 
     { 
      IEnumerable<int> tmpRange; 
      tmpRange = Enumerable.Empty<int>(); 

      foreach (IEnumerable<int> range in ranges) 
       tmpRange = tmpRange.Union(range); 

      tmpRange = tmpRange.OrderBy(number => number); 
      return new List<int>(tmpRange); 
     } 


     public static implicit operator RangeCollection(List<IEnumerable<int>> ranges) 
     { 
      return new RangeCollection(ranges); 
     } 

     public List<int> Range { get; private set; } 

     public int Maximum 
     { 
      get 
      { 
       return Range.Max(); 
      } 
     } 

     public int Minimum 
     { 
      get 
      { 
       return Range.Min(); 
      } 
     } 

     public System.Xml.Schema.XmlSchema GetSchema() 
     { 
      return null; 
     } 

     public void ReadXml(System.Xml.XmlReader reader) 
     { 
      List<IEnumerable<int>> ranges = new List<IEnumerable<int>>(100); 
      string elementName = "Range"; 
      Version version; 

      version = Version.Parse(reader.GetAttribute("Version")); 
      FoundVersion = version; 

      if (reader.IsEmptyElement) return; 

      reader.ReadStartElement(GetType().Name); 
      while (true) 
      { 
       if (reader.NodeType == XmlNodeType.Element && reader.LocalName == elementName) 
       { 
        reader.ReadStartElement(elementName); 
        int start = reader.ReadElementContentAsInt(); 
        int end = reader.ReadElementContentAsInt(); 
        reader.ReadEndElement(); 
        if (start == end) 
         ranges.Add(ExEnumerable.Range(start)); 
        else 
         ranges.Add(ExEnumerable.RangeBetween(start, end)); 
       } 
       else 
        break; 
      } 
      reader.ReadEndElement(); 
      Range = ConvertToListInt(ranges); 
     } 

     public void WriteXml(System.Xml.XmlWriter writer) 
     { 
      throw new NotSupportedException(); 
     } 
    } 
} 

ValidIconImageIndices.xml(関与XMLファイル)

<?xml version="1.0" encoding="utf-8" ?> 
<RangeCollection Version="1.0.0.0"> 
    <Range> 
    <Start>1236</Start> 
    <End>1246</End> 
    </Range> 
    <Range> 
    <Start>1260</Start> 
    <End>1260</End> 
    </Range> 
    <Range> 
    <Start>1263</Start> 
    <End>1287</End> 
    </Range> 
    <Range> 
    <Start>1300</Start> 
    <End>1309</End> 
    </Range> 
    <Range> 
    <Start>1311</Start> 
    <End>1312</End> 
    </Range> 
    <Range> 
    <Start>1401</Start> 
    <End>1415</End> 
    </Range> 
    <Range> 
    <Start>1782</Start> 
    <End>1782</End> 
    </Range> 
    <Range> 
    <Start>1789</Start> 
    <End>1795</End> 
    </Range> 
    <Range> 
    <Start>2240</Start> 
    <End>2303</End> 
    </Range> 
    <Range> 
    <Start>2406</Start> 
    <End>2408</End> 
    </Range> 
    <Range> 
    <Start>2410</Start> 
    <End>2419</End> 
    </Range> 
    <Range> 
    <Start>20480</Start> 
    <End>20496</End> 
    </Range> 
    <Range> 
    <Start>20736</Start> 
    <End>20745</End> 
    </Range> 
    <Range> 
    <Start>20992</Start> 
    <End>21020</End> 
    </Range> 
    <Range> 
    <Start>21248</Start> 
    <End>21248</End> 
    </Range> 
    <Range> 
    <Start>21251</Start> 
    <End>21257</End> 
    </Range> 
    <Range> 
    <Start>21280</Start> 
    <End>21287</End> 
    </Range> 
    <Range> 
    <Start>21504</Start> 
    <End>21507</End> 
    </Range> 
    <Range> 
    <Start>21536</Start> 
    <End>21542</End> 
    </Range> 
    <Range> 
    <Start>21632</Start> 
    <End>21632</End> 
    </Range> 
    <Range> 
    <Start>23000</Start> 
    <End>23015</End> 
    </Range> 
</RangeCollection> 

私はO.S.を知りません私はそれがWindows 7のホーム64ビットだと思う。 彼は.NET 4.0を持っており、あなたはそれをテストしたい場合は、アプリケーションは、アプリケーションへの.NET 4.0

リンクのためのWinFormsアプリケーションです:インストーラで http://dl.dropbox.com/u/762638/Files/Documents/My%20Programs/SpellCaster3/SpellCaster3.zip

リンク: http://dl.dropbox.com/u/762638/Files/Documents/My%20Programs/SpellCaster3/setup.zip

+0

自分のマシンでリモートデバッグを設定できますか? –

+0

私はどのように行うべきかはわかりませんが、私は試してみることができますが、 "今日"ではなく、まずスカイプが必要です –

+0

リモートデバッグにはLAN接続のようなものが必要ですか?私は彼の窓口のアカウントを見る方法を知らないので –

答えて

6

C#コンパイラ(csc.exe)をそのコンピュータで起動できません。エラーコードは悲惨で、E_FAILは "それがうまくいかなかった理由を知らない"以上のことを意味しません。ここでは、C#コンパイラがXMLシリアル化アセンブリを生成するために必要です。

これは環境問題です。あなたのコードとは関係ありません。致命的なエラーコードがあれば、それは何でもかまいません。マルウェアスキャナは、通常、そのようなトラブルの原因でパックをリードします。これは、ユーザーのITチームが解決する必要がある問題です。それについてはほとんどできません。 sgen.exeを使用してシリアル化アセンブリを前もって生成しておくことができますが、ユーザーのマシン上で行う必要はありません。

+1

これはエラーの公平な評価のようです。 +1 sgen.exeソリューションの場合。また、アプリケーション(起動)のパフォーマンスが向上します –

+0

+1 sgen.exe –

+0

私はsgenの作品を作る方法を理解していれば、私はそれを試してみましょう:Pところで、提案のおかげで。私は彼に.NET 4を再インストールするよう頼みました。おそらく動作します –

関連する問題