Posts Tagged ‘serializing’

Cannot serialize

August 19th, 2010

Or Can’t serialise – whatever you prefer.

When using Dotnet and the built in serialiser from Microsoft it sometimes doesn’t work.  Just so.  To make it more complex the error message sometimes doesn’t say anything either, just something like FileNotFoundException.  Sucks.

One solution might be to use the XmlSerializerPreCompiler tool from SellsBrothers available gratis and with source code.  It is downloadable here.  The download is dotnet2 but I updated it to 3.5 easily with Visual Studio 2010.

There is GUI called XmlPreCompiler for it too.

You might run into that the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion as to have a DWord called EnableLog set to 1.  The XmlPreCompiler has to be restarted to understand this key has changed.

If you are working with Dotnet > 2 you have to compile the GUI from source.  It is not difficult – the Visual Studio solution file is in the source code.

When running the GUI tool and your assembly is referring to another assembly (DLL has reference to other DLL) it is important that the GUI tool’s exe is in the same folder as the assemblies you are looking at.  Unless the other assemblies are in the GAC I suppose…

Note that you might have to restart Visual Studio 2010 when up/down grading dotnet version.  It seems like VS holds reference to files with the earlier version.  This has happened to me both when downgrading 4->3.5 and upgrading 2->3.5.

This was a lot of chatter about the apps and problem but I ran into them all right now.  And if You are here – so might you.  Happy hacking!

(My problem in this case was that I had set Visual studio to break on all thrown exceptions.  Took me six hours to figure out…)