XML serialization exception with .NET 1.0 and 1.1 environment

H

HakonB

Sorry for the repost but I ddn't use my MSDN "handle" when I posted earlier....

Hi all

I get an exception when trying to deserialize a simple configuration file
using XML Serialization. The stacktrace can be seen at the bottom of this
message. I've see other messages related a similar error but none of the
solutions suggested are valid in case :/

I have tracked the problem down to the compilation of the temporary DLL that
handles the actual serialization. The following commandline (all on a single
line) is executed by the framework when trying to deserialize my configuration:

"c:\windows\microsoft.net\framework\v1.1.4322\csc.exe" /t:library /utf8output
/R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll"
/R:"c:\program files\MyApp\MyConfig.dll" /R:"c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll"
/out:"C:\DOCUME~1\User\LOCALS~1\Temp\i2_6axn4.dll" /debug- /optimize+ /w:1
"C:\DOCUME~1\User\LOCALS~1\Temp\i2_6axn4.0.cs"

Note that it uses the .NET 1.1 compiler and core lib but references the .NET
1.0 XML assembly. The result is that the assembly isn't created and hence
cannot be loaded.

I've specifeid the required runtime version in the .config file to be .NET
1.1 without any improvements.

The problems occur on a Windows XP test machine with both .NET 1.0 and 1.1.
The application is built using VS.NET 2003 on a machine with only .NET 1.1.
The user running the code on the test machine has administrative rights.

I've have tried the XmlSerialization precompiler and it works without problems...

Anyone have any ideas why this happens?

Kind regards,
HakonB

Exception:

System.Configuration.ConfigurationException: Unable to load
configuration from the XML configuration file: 'C:\Program Files\MyApp\MyApp.exe.config'.
This can be caused by a number of problems, but the most common problem
is an incorrectly configured Updater configuration file.
The most probable sources of error are: missing nodes, incorrect
attribute names, white space within attributes or within elements,
white space between elements in the same sub-node, badly formed xml,
or xml that does not conform to the ConfigSchema.XSD. ---> System.Configuration.ConfigurationException:
Exception in configuration section handler (C:\Program Files\MyApp\MyApp.exe.config
line 16) ---> System.IO.FileNotFoundException: File or assembly name _zdvwu31.dll,
or one of its dependencies, was not found. File name: "_zdvwu31.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase,
Boolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound,
Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Boolean
stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity)
at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
at System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly()
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 DSUpdater.UpdaterSectionHandler.System.Configuration.IConfigurationSectionHandler.Create(Object
parent, Object configContext, XmlNode section) in
C:\Projects\MyApp\MyApp\ConfigSectionHandler.cs:line 55
at System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
factory, Object config, String[] keys, Int32 iKey, XmlTextReader reader)

=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\DOCUME~1\User\LOCALS~1\Temp\_zdvwu31.dll
LOG: Appbase = C:\Program Files\MyApp\
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===

LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL
file:///C:/DOCUME~1/User/LOCALS~1/Temp/_zdvwu31.dll.

--- End of inner exception stack trace ---
at System.Configuration.ConfigurationRecord.EvaluateRecursive(IConfigurationSectionHandler
factory, Object config, String[] keys, Int32 iKey, XmlTextReader reader)
at System.Configuration.ConfigurationRecord.Evaluate(String configKey)
at System.Configuration.ConfigurationRecord.ResolveConfig(String configKey)
at System.Configuration.ConfigurationRecord.GetConfig(String configKey)
at System.Configuration.DefaultConfigurationSystem.System.Configuration.IConfigurationSystem.GetConfig(String
configKey)
at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)
at DSUpdater.UpdaterConfiguration.Init() in C:\Projects\MyApp\MyApp\UpdaterConfiguration.cs:line
133
--- End of inner exception stack trace ---
at DSUpdater.ApplicationUpdateManager..ctor() in C:\Projects\MyApp\DSUpdater\ApplicationUpdater.cs:line
98
at MyApp.Client.Services.SmartUpdateService.Initialize(Form form) in C:\Projects\MyApp\MyApp\Services\SmartUpdateService.cs:line
32
at MyApp.Client.MainForm.Handler_CheckForUpdates(Object sender, EventArgs
e) in C:\Projects\MyApp\MyApp\MainForm.cs:line 570
at MyApp.Common.ActionHandler.ExecuteHandler(Object sender, EventArgs args)
in C:\Projects\MyApp\MyCommon\General\ActionDispatcher.cs:line 252
at MyApp.Common.General.ActionDispatcher.Fire(String handlerName, Object
sender, EventArgs args) in C:\Projects\MyApp\MyCommon\General\ActionDispatcher.cs:line
195
at MyApp.Client.MainForm.MainForm_Load(Object sender, EventArgs e) in C:\Projects\MyApp\MyApp\MainForm.cs:line
423
at System.Windows.Forms.Form.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)
 
P

Peter Huang [MSFT]

Hi

I think the file below
c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.d
ll
is identity to the XML dll shipped with .net framework
1.1(<WINDOWS>\Microsoft.NET\Framework\v1.1.4322\System.XML.dll), you may
verify by copy the
c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.d
ll to a temporary folder, e.g. C:\temp and then right click on the file and
click properties to check the version compared with the
<WINDOWS>\Microsoft.NET\Framework\v1.1.4322\System.XML.dll.

From the Exception, it seems that there is something invalid in the
C:\Program Files\MyApp\MyApp.exe.config file.
To isolate the problem, I think we may try to use a most simple config file
and then add the feature you wants to add one by one to see if what is the
problem.

e.g.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>


If this still doesnot work even if use a most simple config file, I think
we may try to create a new test project and use a config file to see if
that works.

You may have a try and let me know the result.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
H

HakonB

Hello again,

You are right about the versions - it is not related to .NET 1.0 at all.
It just looked like that (to me at least).

I have tried to create a couple of sample projects to display the same behaviour
but I haven't been able to reproduce the problem. The application displaying
the problems is using a customized Application Updater Block (customized
to be able to run on Windows 98 among other things). It is the configuration
section handler from the updater block that is causing this problem.

The application has been successfully tested on Windows 98, Windows ME, Windows
2000, Windows XP Home and Windows XP Professional. The virtual machine having
the error is running Windows XP Home. A tested and fully working application
from another machine copied to the faulty machine displays the same haviour
so I guess it has something to do with the configuration in some way. Btw,
the haviour doesn't changed when .NET 1.1 service pack 1 is applied.

A few more symptoms are:

1. An error message box is displayed when the serialization is taking place:
---------------------------
cvtres.exe - Application Error
---------------------------
The application failed to initialize properly (0xc0000005). Click on OK to
terminate the application.
---------------------------
OK
---------------------------

2. I've seen blogs describing that it is possible to switch between generating
the serializer assembly in memory or on disk. The .NET installation is "clean"
and no changes to the default settings have been applied. There is some files
in my temp directory when the above error message box is displayed - that
is where the I found the commandline. The source code for the serializer
DLL is also there. Do you have any ideas why the temporary files are created
instead of in-memory compilation (which I've read is the default).

I get a DLL file when executing the commandline that I included in my original
post and doesn't see any problems or error messages. I do get some warnings,
e.g.
3mtz_i43.0.cs(515,39): warning CS1595: 'System.Xml.XmlNodeType' is defined
in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll'
3mtz_i43.0.cs(516,40): warning CS1595: 'System.Xml.XmlNodeType' is defined
in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll'

But assume that that isn't the source of the problem as I get a DLL from
the compilation whereas the size of the DLL from the automatic compilation
is 0. However, I have no clue why it complains about the multiple definitions...

Can you make any sense of that?

Thanks,
HakonB
 
P

Peter Huang [MSFT]

Hi

Thanks for your detailed reply.

Do you mean the switch in the link below?
How fast is XmlSerializer?
http://weblogs.asp.net/cazzu/archive/2003/10/21/32822.aspx

Or the GenerateInMemory property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemcodedomcompilercompilerparametersclassgenerateinmemorytopic.asp

Based on my research so far it seems that there is no such config section
in the machine.config or app.config to indicate the XmlSerializer.
Also I think this is not the main cause of the program. The procedure about
how .NET framework handled the XmlSerializer is controled by the .net
runtime. So I think we do not need to manually compiled the temporary file.
And the cvtres.exe is the program that used to convert the resource file in
use. From your description, it seems that the problem is machine specific,
becaused the code will run on another same OS.

Because the problem is hard to reproduce, it is hard to guess what is the
problem. I think you may try to re-install the .NET framework even we may
also need to reinstall the windows.

How to troubleshoot Microsoft .NET Framework 1.1 installation issues
http://support.microsoft.com/?id=824643

If you really wants to know the root cause, which may need live debugging
or dump analysis I think you may try to contact MSPSS via the link below.
If this is confirmed to be a problem in our product the incident will be
refund.
http://support.microsoft.com

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top