views:

92

answers:

3

I have a loop in a BackgroundWorker that saves some stuff via xml Serialization when needed but this seems to load a new assembly each time

'xxyyzz.Main.vshost.exe' (Managed): Loaded '9skkbvdl'

'xxyyzz.Main.vshost.exe' (Managed): Loaded 'd2k4bdda'

and so on. Why is this happening? Is there any thing i can do about it? Is this something I should be concerned about? This program will stay running for a long long time with no restart...

+1  A: 

The assemblies are generated on the fly when you create the XML Serializer - I wouldn't be too concerned about it, but if you are, you could hold a reference to the serialiser for your type, and use that in sucessive calls

Rowland Shaw
+1  A: 

Are you passing additional arguments into your XmlSerializer? i.e. using a non-default constructor? yup, it does this (as it builds a new serialization assembly each time)... consider creating the serializer in a type initializer and caching it:

static readonly XmlSerializer foo;
static MyType() {
    foo = new XmlSerializer(typeof(TypeToSerialize), additionalArgs);
}

then use the cached foo serializer instance repeatedly.

Marc Gravell
A: 

The "*.vshost.exe" files is part of visual studio debugger.

Avram