J
Jonathan Gilbert
Hello,
I work for a company that sells .NET software and have recently been
tasked with handling support issues to do with our update system,
which I wrote. Since the updater is the first thing that runs when the
desktop icon is clicked, I also get unrelated issues, and one that has
been coming up repeatedly is the following exception while trying to
instantiate an XmlSerializer:
System.TypeInitializationException: The type initializer for
'IQ.Core.UpdateFoundation.Dispatcher.DispatchRequest' threw an
exception. ---> System.BadImageFormatException: Could not load file or
assembly '0 bytes loaded from System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
File name: '0 bytes loaded from System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' --->
System.BadImageFormatException: Bad IL format.
at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean
fIntrospection)
at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence securityEvidence)
at
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters
options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters
options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent,
String ns, XmlSerializerCompilerParameters xmlParameters, Evidence
evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, String location,
Evidence evidence)
at
System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace, String location,
Evidence evidence)
at System.Xml.Serialization.XmlSerializer..ctor(Type type,
XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute
root, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, Type[]
extraTypes)
at IQ.Core.UpdateFoundation.Dispatcher.DispatchRequest..cctor()
In attempting to debug this issue, I wrote, on the client's machine, a
tiny test application whose only statement was the creation of an
XmlSerializer, and when I attempted to compile it using the C#
compiler installed on the client machine as part of the .NET
Framework, I found that CSC.EXE produces no output at all:
C:\testxml>csc test.cs
C:\testxml>csc /?
C:\testxml>csc
C:\testxml>
I rooted around to try to find the cause, and one of the other things
I tried was running WCF's ServiceModelReg utility, and that produced
similar output, receiving an error from somewhere within the
framework:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication
Foundation>ServiceModelReg.exe /i
Microsoft(R) Windows Communication Foundation Installation Utility
[Microsoft (R) Windows (R) Communication Foundation, Version
3.0.4506.4037]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Could not load file or assembly '0 bytes loaded from System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. An attempt was made to load a program with an
incorrect format.
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication
Foundation>
I have tried uninstalling and reinstalling .NET, using both .NET's own
uninstaller and the removal tool that Aaron Stebner put on his blog,
but to no avail. The above symptoms persist with no change.
Has anybody seen this before or know what the problem is? So far, we
have only succeeded in solving the problem on a single client
workstation, and the "solution" was a complete reinstallation of
Windows.
Thanks,
Jonathan
I work for a company that sells .NET software and have recently been
tasked with handling support issues to do with our update system,
which I wrote. Since the updater is the first thing that runs when the
desktop icon is clicked, I also get unrelated issues, and one that has
been coming up repeatedly is the following exception while trying to
instantiate an XmlSerializer:
System.TypeInitializationException: The type initializer for
'IQ.Core.UpdateFoundation.Dispatcher.DispatchRequest' threw an
exception. ---> System.BadImageFormatException: Could not load file or
assembly '0 bytes loaded from System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. An attempt was made to load a program with an incorrect
format.
File name: '0 bytes loaded from System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' --->
System.BadImageFormatException: Bad IL format.
at System.Reflection.Assembly.nLoadImage(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean
fIntrospection)
at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[]
rawSymbolStore, Evidence securityEvidence)
at
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames)
at
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters
options, String[] sources)
at
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters
options, String[] sources)
at
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters
options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent,
String ns, XmlSerializerCompilerParameters xmlParameters, Evidence
evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, String location,
Evidence evidence)
at
System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping
xmlMapping, Type type, String defaultNamespace, String location,
Evidence evidence)
at System.Xml.Serialization.XmlSerializer..ctor(Type type,
XmlAttributeOverrides overrides, Type[] extraTypes, XmlRootAttribute
root, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, Type[]
extraTypes)
at IQ.Core.UpdateFoundation.Dispatcher.DispatchRequest..cctor()
In attempting to debug this issue, I wrote, on the client's machine, a
tiny test application whose only statement was the creation of an
XmlSerializer, and when I attempted to compile it using the C#
compiler installed on the client machine as part of the .NET
Framework, I found that CSC.EXE produces no output at all:
C:\testxml>csc test.cs
C:\testxml>csc /?
C:\testxml>csc
C:\testxml>
I rooted around to try to find the cause, and one of the other things
I tried was running WCF's ServiceModelReg utility, and that produced
similar output, receiving an error from somewhere within the
framework:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication
Foundation>ServiceModelReg.exe /i
Microsoft(R) Windows Communication Foundation Installation Utility
[Microsoft (R) Windows (R) Communication Foundation, Version
3.0.4506.4037]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Could not load file or assembly '0 bytes loaded from System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. An attempt was made to load a program with an
incorrect format.
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication
Foundation>
I have tried uninstalling and reinstalling .NET, using both .NET's own
uninstaller and the removal tool that Aaron Stebner put on his blog,
but to no avail. The above symptoms persist with no change.
Has anybody seen this before or know what the problem is? So far, we
have only succeeded in solving the problem on a single client
workstation, and the "solution" was a complete reinstallation of
Windows.
Thanks,
Jonathan