stringwriter

C# Compact Framework - OutOfMemoryException with XmlSerializer.Serialize

Hi everyone, I'm trying to serialize a large collection of objects (20,000) objects within the collection. I'm doing this using the following code: XmlSerializer xs = new XmlSerializer(deserialized.GetType()); StringWriter sw; using (sw = new StringWriter()) { xs.Serialize(sw, deserialized); // OutOfMemoryException here } string ...

Please tell me how to find and replace particular word in a file using vb.net

i have created a template xml file witch contain some words like {contentname}. i need to replace such a tags with my values. please tell me how to search such a words and replace using filehandling in vb.net my xml templatefile is like this: <!-- BEGIN: main --> <?xml version="1.0" encoding="UTF-8"?> <OTA_HotelSearchRQ xmlns="http://ww...

How do i return a StringWriter When I cant Clone it?

My code looks like the below. Obviously i cant write 'ok' because the object has been disposed. I cant do return sw.Clone() bc clone doesnt exist. If i dont use a using then at any point between = new and return (like iterating and writing to the object as my example doesnt do) can have an exception and thus not disposing the object. Am...

Is there a TextWriter child class that fires event if text is written?

I have written a method that accepts a TextWriter as an argument (Usually Console.Out, but not necessarily). When I call this method, some progress info is written to the TextWriter. However, since this method can run a long time, I want to update my UI with some status information. Currently, I am using a StringWriter but it does not ...

StringWriter is not disposed along all exception paths.

I am working with a StringWriter which I am passing to a method to write values in a foreach loop. I believe this is causing the generation of two warnings: CA2000 : Microsoft.Reliability : In method 'ToCsvService.ToCsv()', object 'sw' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'sw' before al...