<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>microsoft.public.dotnet.languages.csharp Latest Posts</title><link>http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.csharp</link><description>This feed provides the latest posts to the C# newsgroup on news.microsoft.com</description><item><title>Re: Connection timeout set to 5 sec but takes longer to timeout</title><guid isPermaLink="false" /><description>http://www.connectionstrings.com/sql-server-2005&lt;br&gt;Connect via an IP address&lt;br&gt;&lt;br&gt;If you try it with the "most anal" connection string....&lt;br&gt;&lt;br&gt;where you specify the&lt;br&gt;IPAddress&lt;br&gt;Port&lt;br&gt;Protocol ("Network Library" in the above URL)&lt;br&gt;&lt;br&gt;(And don't forget to throw in the Connection Timeout as well (as you are &lt;br&gt;doing in your original sample).&lt;br&gt;Connection Timeout=30";&lt;br&gt;&lt;br&gt;Which behavior does it exhibit?&lt;br&gt;&lt;br&gt;&lt;br&gt;..................&lt;br&gt;&lt;br&gt;And have you verified the connection string value is being written?&lt;br&gt;(This is a long shot I realize......but better safe than sorry)&lt;br&gt;&lt;br&gt;&lt;br&gt;using (SqlConnection cn = new SqlConnection(connectionStr))&lt;br&gt;{&lt;br&gt;            Console.WriteLine("Just making super sure : " + &lt;br&gt;Convert.ToString(cn.ConnectionTimeout); // &lt;&lt; What are you getting here?&lt;br&gt;        //your other code&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;br&gt;"Avi" &lt;rememberoti@yahoo.com&gt; wrote in message &lt;br&gt;news:e%23BsbSFwKHA.5244@TK2MSFTNGP05.phx.gbl...&lt;br&gt;&gt; Thanks for the reply.&lt;br&gt;&gt;&lt;br&gt;&gt; I'm only talking to the connection timeout.  Event when I set the timeout &lt;br&gt;&gt; in the connection string to 5 seconds it will take much longer to get &lt;br&gt;&gt; timeout if the IP address in unreachable.&lt;br&gt;&gt;&lt;br&gt;&gt; Avi&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; "sloan" &lt;sloan@ipass.net&gt; wrote in message &lt;br&gt;&gt; news:utUIXo5vKHA.404@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; There is a Connection Timeout AND a separate Command Timeout.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Make sure you're dealing with the correct one.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; "Avi" &lt;rememberoti@yahoo.com&gt; wrote in message &lt;br&gt;&gt;&gt; news:uopXeI5vKHA.4908@TK2MSFTNGP06.phx.gbl...&lt;br&gt;&gt;&gt;&gt; Hi all,&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; My Connection string timeout was set to 5 sec but commands takes much &lt;br&gt;&gt;&gt;&gt; longer to timeout when there is no connection to the destination ip.  Is &lt;br&gt;&gt;&gt;&gt; the timeout value only helps when the ip is reachable but the sql server &lt;br&gt;&gt;&gt;&gt; is not, or it should work also if the ip address is unreachable.  If it &lt;br&gt;&gt;&gt;&gt; should work also when the ip is unreachable, why it does not work in my &lt;br&gt;&gt;&gt;&gt; case?&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Thanks a million,&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Avi&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; public static int ExecCommand(string command, string ip)&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; if (String.IsNullOrEmpty(ip))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; throw new ManualRedundancyException("IP address for database connection &lt;br&gt;&gt;&gt;&gt; cannot be null");&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; string connectionStr = "Data Source=" + ip + ";Initial &lt;br&gt;&gt;&gt;&gt; Catalog=master;Persist Security Info=True;User &lt;br&gt;&gt;&gt;&gt; ID=sa;Password=1210;Connection Timeout=5;";&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; using (SqlConnection cn = new SqlConnection(connectionStr))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; using (SqlCommand cm = new SqlCommand(command, cn))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; cn.Open();&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; int i = cm.ExecuteNonQuery();&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; return i;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 11:06:34 -0500</pubDate><category>C# newsgroup post</category><dc:creator>"sloan" &lt;sloan@ipass.net&gt;</dc:creator></item><item><title>Re: Connection timeout set to 5 sec but takes longer to timeout</title><guid isPermaLink="false" /><description>If I remember a similar thread you have a limit anyway under which you can't &lt;br&gt;go.&lt;br&gt;&lt;br&gt;How much time does it take now ? If I remember you can't go between 10/15 s. &lt;br&gt;If still higher it could be perhaps another problem (name resolution being &lt;br&gt;slow ?)&lt;br&gt;&lt;br&gt;--&lt;br&gt;Patrice&lt;br&gt;&lt;br&gt;"Avi" &lt;rememberoti@yahoo.com&gt; a icrit dans le message de groupe de &lt;br&gt;discussion : e#BsbSFwKHA.5244@TK2MSFTNGP05.phx.gbl...&lt;br&gt;&gt; Thanks for the reply.&lt;br&gt;&gt;&lt;br&gt;&gt; I'm only talking to the connection timeout.  Event when I set the timeout &lt;br&gt;&gt; in the connection string to 5 seconds it will take much longer to get &lt;br&gt;&gt; timeout if the IP address in unreachable.&lt;br&gt;&gt;&lt;br&gt;&gt; Avi&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; "sloan" &lt;sloan@ipass.net&gt; wrote in message &lt;br&gt;&gt; news:utUIXo5vKHA.404@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; There is a Connection Timeout AND a separate Command Timeout.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Make sure you're dealing with the correct one.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; "Avi" &lt;rememberoti@yahoo.com&gt; wrote in message &lt;br&gt;&gt;&gt; news:uopXeI5vKHA.4908@TK2MSFTNGP06.phx.gbl...&lt;br&gt;&gt;&gt;&gt; Hi all,&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; My Connection string timeout was set to 5 sec but commands takes much &lt;br&gt;&gt;&gt;&gt; longer to timeout when there is no connection to the destination ip.  Is &lt;br&gt;&gt;&gt;&gt; the timeout value only helps when the ip is reachable but the sql server &lt;br&gt;&gt;&gt;&gt; is not, or it should work also if the ip address is unreachable.  If it &lt;br&gt;&gt;&gt;&gt; should work also when the ip is unreachable, why it does not work in my &lt;br&gt;&gt;&gt;&gt; case?&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Thanks a million,&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; Avi&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; public static int ExecCommand(string command, string ip)&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; if (String.IsNullOrEmpty(ip))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; throw new ManualRedundancyException("IP address for database connection &lt;br&gt;&gt;&gt;&gt; cannot be null");&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; string connectionStr = "Data Source=" + ip + ";Initial &lt;br&gt;&gt;&gt;&gt; Catalog=master;Persist Security Info=True;User &lt;br&gt;&gt;&gt;&gt; ID=sa;Password=1210;Connection Timeout=5;";&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; using (SqlConnection cn = new SqlConnection(connectionStr))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; using (SqlCommand cm = new SqlCommand(command, cn))&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; cn.Open();&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; int i = cm.ExecuteNonQuery();&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; return i;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; &lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 16:58:00 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Patrice" &lt;http://scribe-en.blogspot.com/&gt;</dc:creator></item><item><title>Re: Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>Ok, that's perfectly clear. Thanks to both of you !&lt;br&gt;I guess that it's the same to write into a Sql database via SqlClient ? I &lt;br&gt;have to lock the function that writes into the table (in fact that calls a &lt;br&gt;stored proc to write) ?&lt;br&gt;&lt;br&gt;Thanks again.&lt;br&gt;&lt;br&gt;Melina.&lt;br&gt;&lt;br&gt;&lt;br&gt;"Mike Lovell" &lt;dont.reply@gotinker.com&gt; a icrit dans le message de news: &lt;br&gt;eZUR3UGwKHA.1796@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt; "Melina" &lt;nospam@nospam.com&gt; wrote in message &lt;br&gt;&gt; news:u#xVRGGwKHA.1796@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt;&gt; Thanks for answering !&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Let me explain the way I see the problem. I may be wrong about the &lt;br&gt;&gt;&gt; locks...&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Well, let's say I have for example 4 threads running simultaneously.&lt;br&gt;&gt;&gt; When one of these 4 threads locks the writeLog function, the 3 others &lt;br&gt;&gt;&gt; have to wait. In my opinion it's a waste of time !&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; And I thought that if I use delegates, each thread will be able to call &lt;br&gt;&gt;&gt; simultaneously the writeLog function.&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Am I wrong ?&lt;br&gt;&gt;&lt;br&gt;&gt; Well you're right that they would be waiting.  But we're talking about &lt;br&gt;&gt; fractions of a second here.&lt;br&gt;&gt;&lt;br&gt;&gt; As far as I know, you don't really have a choice but to waste that time. &lt;br&gt;&gt; The object you're trying to use is a single object, so you cannot use this &lt;br&gt;&gt; object (and remain thread safe) without locking it.  If you make multiple &lt;br&gt;&gt; objects of the same type (for logging) in say a delegate, then they would &lt;br&gt;&gt; indeed be independent from each other (from the objects point of view) and &lt;br&gt;&gt; this would work for certain types of object - But seeing as you can only &lt;br&gt;&gt; write to a file from a single thread (because they file would be locked), &lt;br&gt;&gt; you can't really do this when working with files.  If you're using the &lt;br&gt;&gt; debug and trace, they are going to take care of all that for you (as they &lt;br&gt;&gt; are internally designed to be thread safe).&lt;br&gt;&gt;&lt;br&gt;&gt; If you were say working with SQL, then yes, you could fire off lots of &lt;br&gt;&gt; connections at once if you though it necessary (of course you'd have to &lt;br&gt;&gt; setup your code and/or SQL to handle possible collisions but it would work &lt;br&gt;&gt; better).&lt;br&gt;&gt;&lt;br&gt;&gt; Seeing as it's a file, that you have locked open for writing by your &lt;br&gt;&gt; object, using "lock" on the object is going to be necessary I'm afraid. &lt;br&gt;&gt; But like I say, the time loss for this would be tiny.&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; -- &lt;br&gt;&gt; Mike&lt;br&gt;&gt; GoTinker, C# Blog&lt;br&gt;&gt; http://www.gotinker.com &lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 16:31:34 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Melina" &lt;nospam@nospam.com&gt;</dc:creator></item><item><title>Re: Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>"Melina" &lt;nospam@nospam.com&gt; wrote in message &lt;br&gt;news:u%23xVRGGwKHA.1796@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt; Let me explain the way I see the problem. I may be wrong about the &lt;br&gt;&gt; locks...&lt;br&gt;&gt;&lt;br&gt;&gt; Well, let's say I have for example 4 threads running simultaneously.&lt;br&gt;&gt; When one of these 4 threads locks the writeLog function, the 3 others have &lt;br&gt;&gt; to wait. In my opinion it's a waste of time !&lt;br&gt;&gt;&lt;br&gt;&gt; And I thought that if I use delegates, each thread will be able to call &lt;br&gt;&gt; simultaneously the writeLog function.&lt;br&gt;&lt;br&gt;   No, the delegates are still running in a thread and still have the same &lt;br&gt;problem. When you use Invoke on a UI control, you are only using the &lt;br&gt;delegate to enqueue the call to the function, until *another* thread (the &lt;br&gt;one that created the UI) becomes available for running your method.&lt;br&gt;   If you want to do a similar operation for your writeLog function, you can &lt;br&gt;create the queue yourself. Use a Queue class to keep track of all the &lt;br&gt;pending invocations to writeLog. Then use an additional thread to read from &lt;br&gt;the queue and invoke writeLog. Of course you will still need a little bit of &lt;br&gt;locking (during the extremely brief time that is needed to write an item &lt;br&gt;into the queue or read an item from the queue), but this should be so short &lt;br&gt;that it would hardly slow down your worker threads.&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 16:23:31 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Alberto Poblacion" &lt;earthling-quitaestoparacontestar@poblacion.org&gt;</dc:creator></item><item><title>Re: Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>"Melina" &lt;nospam@nospam.com&gt; wrote in message &lt;br&gt;news:u#xVRGGwKHA.1796@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt; Thanks for answering !&lt;br&gt;&gt;&lt;br&gt;&gt; Let me explain the way I see the problem. I may be wrong about the &lt;br&gt;&gt; locks...&lt;br&gt;&gt;&lt;br&gt;&gt; Well, let's say I have for example 4 threads running simultaneously.&lt;br&gt;&gt; When one of these 4 threads locks the writeLog function, the 3 others have &lt;br&gt;&gt; to wait. In my opinion it's a waste of time !&lt;br&gt;&gt;&lt;br&gt;&gt; And I thought that if I use delegates, each thread will be able to call &lt;br&gt;&gt; simultaneously the writeLog function.&lt;br&gt;&gt;&lt;br&gt;&gt; Am I wrong ?&lt;br&gt;&lt;br&gt;Well you're right that they would be waiting.  But we're talking about &lt;br&gt;fractions of a second here.&lt;br&gt;&lt;br&gt;As far as I know, you don't really have a choice but to waste that time. &lt;br&gt;The object you're trying to use is a single object, so you cannot use this &lt;br&gt;object (and remain thread safe) without locking it.  If you make multiple &lt;br&gt;objects of the same type (for logging) in say a delegate, then they would &lt;br&gt;indeed be independent from each other (from the objects point of view) and &lt;br&gt;this would work for certain types of object - But seeing as you can only &lt;br&gt;write to a file from a single thread (because they file would be locked), &lt;br&gt;you can't really do this when working with files.  If you're using the debug &lt;br&gt;and trace, they are going to take care of all that for you (as they are &lt;br&gt;internally designed to be thread safe).&lt;br&gt;&lt;br&gt;If you were say working with SQL, then yes, you could fire off lots of &lt;br&gt;connections at once if you though it necessary (of course you'd have to &lt;br&gt;setup your code and/or SQL to handle possible collisions but it would work &lt;br&gt;better).&lt;br&gt;&lt;br&gt;Seeing as it's a file, that you have locked open for writing by your object, &lt;br&gt;using "lock" on the object is going to be necessary I'm afraid.  But like I &lt;br&gt;say, the time loss for this would be tiny.&lt;br&gt;&lt;br&gt;&lt;br&gt;-- &lt;br&gt;Mike&lt;br&gt;GoTinker, C# Blog&lt;br&gt;http://www.gotinker.com &lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 09:20:23 -0600</pubDate><category>C# newsgroup post</category><dc:creator>"Mike Lovell" &lt;dont.reply@gotinker.com&gt;</dc:creator></item><item><title>Re: Sqlcommand causing memory leak</title><guid isPermaLink="false" /><description>"Pedron" &lt;u58665@uwe&gt; wrote in message news:a4cd4e55fc33e@uwe...&lt;br&gt;&gt; Alberto, that's exactly what is happening. I was worried since &lt;br&gt;&gt; sqlservr.exe&lt;br&gt;&gt; memory usage increases by 140Kb/sec and didn't slow down this pace during &lt;br&gt;&gt; the&lt;br&gt;&gt; 1 hour I've allowed my app to run.&lt;br&gt;&lt;br&gt;    That's a very fast rate of increase, unless your application is really &lt;br&gt;reading lots of different data pages from a database. If you aren't doing &lt;br&gt;that many accesses, there may be something else happening, which can't be &lt;br&gt;determined from the information that you have provided. A good tool to &lt;br&gt;"catch" the accesses to your server is Sql Server Profiler, but it's not &lt;br&gt;provided with the Express version.&lt;br&gt;&lt;br&gt;&gt;What will eventually happen if I allow it to continue?&lt;br&gt;&lt;br&gt;    SQL Server will continue to use more memory until it has cached all of &lt;br&gt;the pages of the .mdf file that you have accessed (so a maximum value would &lt;br&gt;be the total size of all the databases that you open). If it exhausts all &lt;br&gt;the memory in your computer, *in theory* it should automatically free memory &lt;br&gt;as needed (by dropping parts of the cache) when other applications require &lt;br&gt;it. Note the stress on "in theory". I have found that sometimes I can't &lt;br&gt;start other applications such as Virtual PC when SQL Server is using a lot &lt;br&gt;of memory. In those cases, I stop SQL Server, then start Virtual PC, and &lt;br&gt;then restart SQL Server. Both applications then run happily together. Of &lt;br&gt;course you will not want to do this on a production machine. That's why I &lt;br&gt;suggested setting the "Maximum Server Memory" in the configuration of SQL &lt;br&gt;Server, so it doesn't allocate any more than the figure that you set.&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 16:14:19 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Alberto Poblacion" &lt;earthling-quitaestoparacontestar@poblacion.org&gt;</dc:creator></item><item><title>Re: Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>Thanks for answering !&lt;br&gt;&lt;br&gt;Let me explain the way I see the problem. I may be wrong about the locks...&lt;br&gt;&lt;br&gt;Well, let's say I have for example 4 threads running simultaneously.&lt;br&gt;When one of these 4 threads locks the writeLog function, the 3 others have &lt;br&gt;to wait. In my opinion it's a waste of time !&lt;br&gt;&lt;br&gt;And I thought that if I use delegates, each thread will be able to call &lt;br&gt;simultaneously the writeLog function.&lt;br&gt;&lt;br&gt;Am I wrong ?&lt;br&gt;&lt;br&gt;&lt;br&gt;"Mike Lovell" &lt;dont.reply@gotinker.com&gt; a icrit dans le message de news: &lt;br&gt;euBst5FwKHA.2436@TK2MSFTNGP04.phx.gbl...&lt;br&gt;&gt;&gt; How can i invoke a function in a mutli-threading environment with .NET &lt;br&gt;&gt;&gt; 2.0 ?&lt;br&gt;&gt;&gt; For example, assuming each thread (in a thread polling application...) &lt;br&gt;&gt;&gt; needs to invoke the writeLog function from his createDocument function:&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; private void createDocument() {&lt;br&gt;&gt;&gt;  writeLog("Test");&lt;br&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; private void writeLog(string data) {&lt;br&gt;&gt;&gt;  StreamWriter sw = new StreamWriter(@"c:\temp\test.txt", true);&lt;br&gt;&gt;&gt;  sw.WriteLine(data);&lt;br&gt;&gt;&gt;  sw.Flush();&lt;br&gt;&gt;&gt;  sw.Close();&lt;br&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; This code won't run properly because of simultaneous access to writeLog &lt;br&gt;&gt;&gt; from the different threads.&lt;br&gt;&gt;&gt; I know i can add a Lock into the writeLog function, but i would prefer &lt;br&gt;&gt;&gt; invoke delegates.&lt;br&gt;&gt;&gt; On a UI control like a TextBox, i can call the Invoke function with the &lt;br&gt;&gt;&gt; delegate. But how to do this with a function ?&lt;br&gt;&gt;&lt;br&gt;&gt; Why would you prefer not to use locks?  I mean that's really what locks &lt;br&gt;&gt; are for&lt;br&gt;&gt;&lt;br&gt;&gt; If the purpose of this is really logging (as the name suggests) you should &lt;br&gt;&gt; really be using the inbuilt Trace and Debug function for this, then you &lt;br&gt;&gt; can just add a listening and write the debug to a text file.&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; -- &lt;br&gt;&gt; Mike&lt;br&gt;&gt; GoTinker, C# Blog&lt;br&gt;&gt; http://www.gotinker.com &lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 15:54:21 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Melina" &lt;nospam@nospam.com&gt;</dc:creator></item><item><title>Re: Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>&gt; How can i invoke a function in a mutli-threading environment with .NET 2.0 &lt;br&gt;&gt; ?&lt;br&gt;&gt; For example, assuming each thread (in a thread polling application...) &lt;br&gt;&gt; needs to invoke the writeLog function from his createDocument function:&lt;br&gt;&gt;&lt;br&gt;&gt; private void createDocument() {&lt;br&gt;&gt;  writeLog("Test");&lt;br&gt;&gt; }&lt;br&gt;&gt;&lt;br&gt;&gt; private void writeLog(string data) {&lt;br&gt;&gt;  StreamWriter sw = new StreamWriter(@"c:\temp\test.txt", true);&lt;br&gt;&gt;  sw.WriteLine(data);&lt;br&gt;&gt;  sw.Flush();&lt;br&gt;&gt;  sw.Close();&lt;br&gt;&gt; }&lt;br&gt;&gt;&lt;br&gt;&gt; This code won't run properly because of simultaneous access to writeLog &lt;br&gt;&gt; from the different threads.&lt;br&gt;&gt; I know i can add a Lock into the writeLog function, but i would prefer &lt;br&gt;&gt; invoke delegates.&lt;br&gt;&gt; On a UI control like a TextBox, i can call the Invoke function with the &lt;br&gt;&gt; delegate. But how to do this with a function ?&lt;br&gt;&lt;br&gt;Why would you prefer not to use locks?  I mean that's really what locks are &lt;br&gt;for&lt;br&gt;&lt;br&gt;If the purpose of this is really logging (as the name suggests) you should &lt;br&gt;really be using the inbuilt Trace and Debug function for this, then you can &lt;br&gt;just add a listening and write the debug to a text file.&lt;br&gt;&lt;br&gt;&lt;br&gt;-- &lt;br&gt;Mike&lt;br&gt;GoTinker, C# Blog&lt;br&gt;http://www.gotinker.com &lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 08:31:46 -0600</pubDate><category>C# newsgroup post</category><dc:creator>"Mike Lovell" &lt;dont.reply@gotinker.com&gt;</dc:creator></item><item><title>Re: Sqlcommand causing memory leak</title><guid isPermaLink="false" /><description>Alberto, that's exactly what is happening. I was worried since sqlservr.exe&lt;br&gt;memory usage increases by 140Kb/sec and didn't slow down this pace during the&lt;br&gt;1 hour I've allowed my app to run. What will eventually happen if I allow it&lt;br&gt;to continue?&lt;br&gt;&lt;br&gt;// Pedron&lt;br&gt;&lt;br&gt;&lt;br&gt;Alberto Poblacion wrote:&lt;br&gt;&gt;&gt; I'm struggling to find why this piece of code results in memory leak in&lt;br&gt;&gt;&gt; sqlservr.exe. Could someone please help me in explaining what I'm doing &lt;br&gt;&gt;&gt; wrong?&lt;br&gt;&gt;&lt;br&gt;&gt;    When you say "memory leak in sqlservr.exe", do you mean that the &lt;br&gt;&gt;sqlservr.exe process uses more and more memory as time passes? If so, this &lt;br&gt;&gt;is to be expected. SQL Server uses memory to cache pages from disk. As it &lt;br&gt;&gt;operates, more and more pages get cached, so it uses more and more memory.&lt;br&gt;&gt;    Note that this behavior is inherent to SQL Server, ant it would do the &lt;br&gt;&gt;same thing if you connected to the server from any other client tool. It's &lt;br&gt;&gt;not the fault of your C# code.&lt;br&gt;&gt;    If you wish to set a limit to how much memory you want to let it use, &lt;br&gt;&gt;open the Server Properties from Sql Server Management Studio, and enter a &lt;br&gt;&gt;value for the "Maximum Server Memory" in the Memory page.&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 14:05:11 GMT</pubDate><category>C# newsgroup post</category><dc:creator>"Pedron" &lt;u58665@uwe&gt;</dc:creator></item><item><title>Threads, delegates and invoke function with 2.0</title><guid isPermaLink="false" /><description>Hi,&lt;br&gt;&lt;br&gt;How can i invoke a function in a mutli-threading environment with .NET 2.0 ?&lt;br&gt;For example, assuming each thread (in a thread polling application...) needs &lt;br&gt;to invoke the writeLog function from his createDocument function:&lt;br&gt;&lt;br&gt;private void createDocument() {&lt;br&gt;  writeLog("Test");&lt;br&gt;}&lt;br&gt;&lt;br&gt;private void writeLog(string data) {&lt;br&gt;  StreamWriter sw = new StreamWriter(@"c:\temp\test.txt", true);&lt;br&gt;  sw.WriteLine(data);&lt;br&gt;  sw.Flush();&lt;br&gt;  sw.Close();&lt;br&gt;}&lt;br&gt;&lt;br&gt;This code won't run properly because of simultaneous access to writeLog from &lt;br&gt;the different threads.&lt;br&gt;I know i can add a Lock into the writeLog function, but i would prefer &lt;br&gt;invoke delegates.&lt;br&gt;On a UI control like a TextBox, i can call the Invoke function with the &lt;br&gt;delegate. But how to do this with a function ?&lt;br&gt;&lt;br&gt;Many thanks for helping.&lt;br&gt;&lt;br&gt;Melina. &lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 14:54:26 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Melina" &lt;nospam@nospam.com&gt;</dc:creator></item><item><title>Re: Save changes for a custom configuration section</title><guid isPermaLink="false" /><description>Hi there,&lt;br&gt;&lt;br&gt;Giulio Petrucci wrote:&lt;br&gt;&gt; FooConfigSection fcs = &lt;br&gt;&gt; (FooConfigSection)ConfigurationManager.GetSection("Foo");&lt;br&gt;&gt; fcs.Label = "*";&lt;br&gt;&gt; Configuration c = &lt;br&gt;&gt; ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);&lt;br&gt;&gt; c.Save(ConfigurationSaveMode.Full);&lt;br&gt;&lt;br&gt;Solved:&lt;br&gt;&lt;br&gt;FooConfigSection fcs =&lt;br&gt;(FooConfigSection)ConfigurationManager.GetSection("Foo");&lt;br&gt;fcs.SectionInformation.ForceSave = true; //missing line. :-)&lt;br&gt;fcs.Label = "*";&lt;br&gt;Configuration c =&lt;br&gt;ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);&lt;br&gt;c.Save(ConfigurationSaveMode.Full);&lt;br&gt;&lt;br&gt;HTH,&lt;br&gt;Giulio&lt;br&gt;-- </description><pubDate>Wed, 10 Mar 2010 14:49:58 +0100</pubDate><category>C# newsgroup post</category><dc:creator>Giulio Petrucci &lt;fakename@fakedomain.com&gt;</dc:creator></item><item><title>Re: Sqlcommand causing memory leak</title><guid isPermaLink="false" /><description>"Pedron" &lt;u58665@uwe&gt; wrote in message news:a4cb7db5a1319@uwe...&lt;br&gt;&gt; I'm struggling to find why this piece of code results in memory leak in&lt;br&gt;&gt; sqlservr.exe. Could someone please help me in explaining what I'm doing &lt;br&gt;&gt; wrong?&lt;br&gt;&lt;br&gt;    When you say "memory leak in sqlservr.exe", do you mean that the &lt;br&gt;sqlservr.exe process uses more and more memory as time passes? If so, this &lt;br&gt;is to be expected. SQL Server uses memory to cache pages from disk. As it &lt;br&gt;operates, more and more pages get cached, so it uses more and more memory.&lt;br&gt;    Note that this behavior is inherent to SQL Server, ant it would do the &lt;br&gt;same thing if you connected to the server from any other client tool. It's &lt;br&gt;not the fault of your C# code.&lt;br&gt;    If you wish to set a limit to how much memory you want to let it use, &lt;br&gt;open the Server Properties from Sql Server Management Studio, and enter a &lt;br&gt;value for the "Maximum Server Memory" in the Memory page.&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 14:37:50 +0100</pubDate><category>C# newsgroup post</category><dc:creator>"Alberto Poblacion" &lt;earthling-quitaestoparacontestar@poblacion.org&gt;</dc:creator></item><item><title>Re: Connection timeout set to 5 sec but takes longer to timeout</title><guid isPermaLink="false" /><description>Thanks for the reply.&lt;br&gt;&lt;br&gt;I'm only talking to the connection timeout.  Event when I set the timeout in &lt;br&gt;the connection string to 5 seconds it will take much longer to get timeout &lt;br&gt;if the IP address in unreachable.&lt;br&gt;&lt;br&gt;Avi&lt;br&gt;&lt;br&gt;&lt;br&gt;"sloan" &lt;sloan@ipass.net&gt; wrote in message &lt;br&gt;news:utUIXo5vKHA.404@TK2MSFTNGP02.phx.gbl...&lt;br&gt;&gt;&lt;br&gt;&gt; There is a Connection Timeout AND a separate Command Timeout.&lt;br&gt;&gt;&lt;br&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx&lt;br&gt;&gt;&lt;br&gt;&gt; http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx&lt;br&gt;&gt;&lt;br&gt;&gt; Make sure you're dealing with the correct one.&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; "Avi" &lt;rememberoti@yahoo.com&gt; wrote in message &lt;br&gt;&gt; news:uopXeI5vKHA.4908@TK2MSFTNGP06.phx.gbl...&lt;br&gt;&gt;&gt; Hi all,&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; My Connection string timeout was set to 5 sec but commands takes much &lt;br&gt;&gt;&gt; longer to timeout when there is no connection to the destination ip.  Is &lt;br&gt;&gt;&gt; the timeout value only helps when the ip is reachable but the sql server &lt;br&gt;&gt;&gt; is not, or it should work also if the ip address is unreachable.  If it &lt;br&gt;&gt;&gt; should work also when the ip is unreachable, why it does not work in my &lt;br&gt;&gt;&gt; case?&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Thanks a million,&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; Avi&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; public static int ExecCommand(string command, string ip)&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; if (String.IsNullOrEmpty(ip))&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; throw new ManualRedundancyException("IP address for database connection &lt;br&gt;&gt;&gt; cannot be null");&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; string connectionStr = "Data Source=" + ip + ";Initial &lt;br&gt;&gt;&gt; Catalog=master;Persist Security Info=True;User &lt;br&gt;&gt;&gt; ID=sa;Password=1210;Connection Timeout=5;";&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; using (SqlConnection cn = new SqlConnection(connectionStr))&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; using (SqlCommand cm = new SqlCommand(command, cn))&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; {&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; cn.Open();&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; int i = cm.ExecuteNonQuery();&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; return i;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt; }&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&gt;&lt;br&gt;&gt;&lt;br&gt;&gt; &lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 15:24:47 +0200</pubDate><category>C# newsgroup post</category><dc:creator>"Avi" &lt;rememberoti@yahoo.com&gt;</dc:creator></item><item><title>Found a solution so far?</title><guid isPermaLink="false" /><description>Hi!&lt;br&gt;&lt;br&gt;Great article! Since RichtextBox.DrawToBitmap() seems not to be working correctly I wonder if there is a proper implementation for displaying/drawing richtext by something like Graphics.DrawStringRTF().&lt;br&gt;I have done quite a little bit of research - there are many solutions out there but they all have major shortcomings.&lt;br&gt;&lt;br&gt;1. copy richtextBox content to a bitmap works - but without scaling/zooming which is essential for me! Scaling this bitmap results in bad resolution/quality&lt;br&gt;Example: http://www.andrewvos.com/?p=392[^]&lt;br&gt;-&gt; no option.&lt;br&gt;&lt;br&gt;2. RichtextBox.DrawToBitmap() seems not to work -&gt; i am compiling to .net framework 2.0, does anyone know if its better on 3.0 or 3.5? -&gt; no option with 2.0!&lt;br&gt;&lt;br&gt;3. commercial / open source 3rd party rendering? I found something on ComponentOne but it was only for PDF-printing -&gt; no option!&lt;br&gt;&lt;br&gt;If nothing helps i have to write a renderer by myself -&gt; not a good perspective since MS could fix this error by correcting RichttextBox.DrawToBitmap() with a few keystrokes..&lt;br&gt;&lt;br&gt;Any ideas?&lt;br&gt;&lt;br&gt;Thx martin&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;AliR \(VC++ MVP\) wrote:&lt;br&gt;&lt;br&gt;I setup another machine with Vista 64 and it is happening there too.&lt;br&gt;28-Oct-08&lt;br&gt;&lt;br&gt;I setup another machine with Vista 64 and it is happening there too.  So it
looks like Vista 64 is the problem!

AliR.&lt;br&gt;&lt;br&gt;Previous Posts In This Thread:&lt;br&gt;&lt;br&gt;On Monday, October 27, 2008 5:30 PM&lt;br&gt;AliR \(VC++ MVP\) wrote:&lt;br&gt;&lt;br&gt;RTF Render with Scale&lt;br&gt;I'm trying to write a RTF render code in C#.  I have the code in C++/MFC and 
it works fine, but I have run into a problem with the C# code.  I think the 
C# code is from Microsoft, and I added scaling to it.  The C# code is 
working fine on my desktop PC but it cuts off some of the text when I run it 
on my laptop.  The MFC code works fine both on the laptop and the PC.  I 
have looked at all the numbers used in the MFC and the C# code and they are 
identical.    Both PC and Laptop are at 1440x900 96dpi font size.

I have been looking at the code for 3 or 4 days now without any improvment. 
Was wondering if anyone here wants to take a stab at it.

You can download both sample projects:
http://www.learnstar.com/AliR/RTFScaler.zip
http://www.learnstar.com/AliR/RTFScalerMFC.zip


Thanks
AliR.


Here is the MFC code
// *** copying/scaling/rotating and shearing the text is done here
void CRTFScalerDlg::RenderText(int nScalePercent,int nRotationDegrees,int 
nHorzShearPercent,int nVertShearPercent)
{
// validate the arguments
 if (nScalePercent &lt; 1)
  nScalePercent = 1;
 if (nScalePercent &gt; 10000)
  nScalePercent = 10000;
 if (nRotationDegrees &lt; 0)
  nRotationDegrees = 0;
 if (nRotationDegrees &gt; 360)
  nRotationDegrees = 360;
 if (nHorzShearPercent &lt; 0)
  nHorzShearPercent = 0;
 if (nHorzShearPercent &gt; 100)
  nHorzShearPercent = 100;
 if (nVertShearPercent &lt; 0)
  nVertShearPercent = 0;
 if (nVertShearPercent &gt; 100)
  nVertShearPercent = 100;

    // setup target window, rect and DC
 CWnd* pTargetWin = GetDlgItem(IDC_EDIT1);
 CRect crTarget;
 pTargetWin-&gt;GetClientRect(&amp;crTarget);
 crTarget.OffsetRect(0,20);
 CDC* pTargetDC = pTargetWin-&gt;GetDC();
 pTargetDC-&gt;IntersectClipRect(&amp;crTarget); // so we don't clobber the parent 
dialog
 pTargetDC-&gt;SetBkMode(TRANSPARENT);   // so the legend doesn't erase too 
much

    // also need advanced graphics mode for the world transform stuff
 if (!SetGraphicsMode(pTargetDC-&gt;m_hDC,GM_ADVANCED))
 {
  pTargetDC-&gt;DrawText("Nice try but I need Windows NT, 2000, XP or 2003 for 
this.",crTarget,DT_SINGLELINE | DT_VCENTER | DT_CENTER);
  return;
 }

// erase previous contents
 FillRect(pTargetDC-&gt;m_hDC,crTarget,(HBRUSH)(COLOR_WINDOW + 1));
 CString Temp;
 Temp.Format("crTarget %d,%d 
%d,%d\n",crTarget.left,crTarget.top,crTarget.Width(),crTarget.Height());
 TRACE(Temp);

// setup rectangles for metafile fiddling
 CSize cTargetSize = crTarget.Size();
 pTargetDC-&gt;DPtoHIMETRIC(&amp;cTargetSize);  // from MM_Text to MM_HIMETRIC
 CSize TopLeft;
 TopLeft.cx = crTarget.left;
 TopLeft.cy = crTarget.top;
 pTargetDC-&gt;DPtoHIMETRIC(&amp;TopLeft);  // from MM_Text to MM_HIMETRIC

 CRect cHiMetricRect(0,0,cTargetSize.cx,cTargetSize.cy);
 CRect cTwipsRect(0,0,(TWIPS_INCH * cTargetSize.cx + HIMETRIC_INCH / 2) / 
HIMETRIC_INCH,
       (TWIPS_INCH * cTargetSize.cy + HIMETRIC_INCH / 2) / HIMETRIC_INCH);

 Temp.Format("MetaSize 
%d,%d\n",cHiMetricRect.Width(),cHiMetricRect.Height());
 TRACE(Temp);
 Temp.Format("cTwipsRect %d,%d\n",cTwipsRect.Width(),cTwipsRect.Height());
 TRACE(Temp);
// create the enhanced metafile
 HDC hDCEMF = CreateEnhMetaFile(pTargetDC-&gt;m_hDC,NULL,cHiMetricRect,NULL);

// setup the format struct and do the RTF range formatting call
 FORMATRANGE stFR;
 stFR.hdcTarget = stFR.hdc = hDCEMF;  // render to the memory helper EMF
 stFR.rcPage    = stFR.rc  = cTwipsRect; // using this rectangle (in twips)
 stFR.chrg.cpMin = 0;     // and render all of the text
 stFR.chrg.cpMax = -1;
 GetDlgItem(IDC_RICHEDIT1)-&gt;SendMessage(EM_FORMATRANGE,TRUE,(LPARAM) &amp;stFR);
 GetDlgItem(IDC_RICHEDIT1)-&gt;SendMessage(EM_FORMATRANGE,TRUE,NULL); // this 
call clears the cache

// drawing into the metafile is done, get ourselves an handle to it (used 
for the replay)
 HENHMETAFILE hEMF = CloseEnhMetaFile(hDCEMF);

// calculate the automagic fudge factors by getting the device metrics
 int nHorzSize   = pTargetDC-&gt;GetDeviceCaps(HORZSIZE  );  // width in 
millimeters
 int nVertSize   = pTargetDC-&gt;GetDeviceCaps(VERTSIZE  );  // height in 
millimeters
 int nHorzRes    = pTargetDC-&gt;GetDeviceCaps(HORZRES   );  // width in pixels
 int nVertRes    = pTargetDC-&gt;GetDeviceCaps(VERTRES   );  // height in 
pixels
 int nLogPixelsX = pTargetDC-&gt;GetDeviceCaps(LOGPIXELSX);  // # of pixels per 
inch horizontally
 int nLogPixelsY = pTargetDC-&gt;GetDeviceCaps(LOGPIXELSY);  // # of pixels per 
inch vertically

 float fHorzSizeInches  = nHorzSize / 25.4f;
 float fVertSizeInches  = nVertSize / 25.4f;
 float fHorzFudgeFactor = (nHorzRes / fHorzSizeInches) / nLogPixelsX; // 
divide expected DPI with actual DPI
 float fVertFudgeFactor = (nVertRes / fVertSizeInches) / nLogPixelsY; //

 Temp.Format("Fudgfactor %.2f %.2f\n",fHorzFudgeFactor,fVertFudgeFactor);
 TRACE(Temp);

// change from degrees to radians
// (also need to change sign since page space is upside down)
 float fRotationInRadians = (PI * (0 - nRotationDegrees)) / 180.0F;

// do the world transforms, first apply the scale and fudge factors
 XFORM stX;
 ZeroMemory(&amp;stX,sizeof(stX));
 stX.eM11 = fHorzFudgeFactor * (nScalePercent / 100.0f);
 stX.eM22 = fVertFudgeFactor * (nScalePercent / 100.0f);
 SetWorldTransform(pTargetDC-&gt;m_hDC,&amp;stX);

// then apply the rotation
 ZeroMemory(&amp;stX,sizeof(stX));
 stX.eM11 =    (float) cos(fRotationInRadians);
 stX.eM12 =    (float) sin(fRotationInRadians);
 stX.eM21 = 0 - (float) sin(fRotationInRadians);
 stX.eM22 =    (float) cos(fRotationInRadians);
 ModifyWorldTransform(pTargetDC-&gt;m_hDC,&amp;stX,MWT_LEFTMULTIPLY);

// finally apply the horizontal and vertical shearing
 ZeroMemory(&amp;stX,sizeof(stX));
 stX.eM11 = 1.0f;
 stX.eM12 = nHorzShearPercent / 100.0f;
 stX.eM21 = nVertShearPercent / 100.0f;
 stX.eM22 = 1.0f;
 ModifyWorldTransform(pTargetDC-&gt;m_hDC,&amp;stX,MWT_LEFTMULTIPLY);

 crTarget.OffsetRect(0,-20);
 crTarget.OffsetRect(0,20 / (nScalePercent / 100.0f) * fVertFudgeFactor);
// play the metafile
 pTargetDC-&gt;PlayMetaFile(hEMF,&amp;crTarget);

// that's it, kiss the metafile goodbye
 DeleteEnhMetaFile(hEMF);

// also show a legend
 ModifyWorldTransform(pTargetDC-&gt;m_hDC,NULL,MWT_IDENTITY);
 CString sLegend;
 sLegend.Format("Scale: %d%%  rotation: %d?  horizontal shear: %d%% 
vertical shear: %d%%.",
     nScalePercent,nRotationDegrees,nHorzShearPercent,nVertShearPercent);
 pTargetDC-&gt;SetTextColor(RGB(55,111,111));
 pTargetDC-&gt;DrawText(sLegend,crTarget,DT_SINGLELINE | DT_VCENTER | 
DT_CENTER);
}


Here is the C# code:

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Text;

public static class Graphics_DrawRtfText
{
    private static RichTextBoxDrawer rtfDrawer;
    public static void DrawRtfText(this Graphics graphics, string rtf, 
RectangleF layoutArea,float xFactor)
    {
        if (Graphics_DrawRtfText.rtfDrawer == null)
        {
            Graphics_DrawRtfText.rtfDrawer = new RichTextBoxDrawer();
        }
        Graphics_DrawRtfText.rtfDrawer.Rtf = rtf;
        Graphics_DrawRtfText.rtfDrawer.Draw(graphics, layoutArea,xFactor);
    }

    private class RichTextBoxDrawer : RichTextBox
    {
        //Code converted from code found here: 
http://support.microsoft.com/kb/812425/en-us

        //Convert the unit used by the .NET framework (1/100 inch)
        //and the unit used by Win32 API calls (twips 1/1440 inch)
        private const double anInch = 14.4;

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams createParams = base.CreateParams;
                if (SafeNativeMethods.LoadLibrary("msftedit.dll") != 
IntPtr.Zero)
                {
                    createParams.ExStyle |= 
SafeNativeMethods.WS_EX_TRANSPARENT; // transparent
                    createParams.ClassName = "RICHEDIT50W";
                }
                return createParams;
            }
        }

        private void DPToHIMETRIC(Graphics graphics,ref SizeF size)
        {
            size.Width = (size.Width * 2540.0f) / graphics.DpiX;
            size.Height = (size.Height * 2540.0f) / graphics.DpiY;
        }

        public void Draw(Graphics graphics, RectangleF layoutArea, float 
xFactor)
        {
            System.Diagnostics.Debug.WriteLine("LayoutArea " + layoutArea);

            SizeF metaSize = layoutArea.Size;
            DPToHIMETRIC(graphics, ref metaSize);

            System.Diagnostics.Debug.WriteLine("MetaSize " + metaSize);

            IntPtr hdc = graphics.GetHdc();

            //create a metafile, convert the size to himetrics
            Metafile metafile = new Metafile(hdc, new 
RectangleF(0,0,metaSize.Width,metaSize.Height));

            graphics.ReleaseHdc(hdc);

            Graphics g = Graphics.FromImage(metafile);
            IntPtr hDCEMF = g.GetHdc();

            //Calculate the area to render.
            SafeNativeMethods.RECT rectLayoutArea;
            rectLayoutArea.Left = 0;
            rectLayoutArea.Top = 0;
            rectLayoutArea.Right = (int)((1440 * metaSize.Width + 2540 / 2) 
/ 2540);
            rectLayoutArea.Bottom = (int)((1440 * metaSize.Height + 2540 / 
2) / 2540);

            System.Diagnostics.Debug.WriteLine(String.Format("RectLayoutArea 
({0},{1})",rectLayoutArea.Right,rectLayoutArea.Bottom));

            SafeNativeMethods.FORMATRANGE fmtRange;
            fmtRange.chrg.cpMax = -1;            //Indicate character from 
to character to
            fmtRange.chrg.cpMin = 0;
            fmtRange.hdc = hDCEMF;                  //Use the same DC for 
measuring and rendering
            fmtRange.hdcTarget = hDCEMF;         //Point at printer hDC
            fmtRange.rc = rectLayoutArea;        //Indicate the area on page 
to print
            fmtRange.rcPage = rectLayoutArea;    //Indicate size of page

            IntPtr wParam = IntPtr.Zero;
            wParam = new IntPtr(1);

            //Get the pointer to the FORMATRANGE structure in memory
            IntPtr lParam = IntPtr.Zero;
            lParam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmtRange));
            Marshal.StructureToPtr(fmtRange, lParam, false);

            SafeNativeMethods.SendMessage(this.Handle, 
SafeNativeMethods.EM_FORMATRANGE, wParam, lParam);
            SafeNativeMethods.SendMessage(this.Handle, 
SafeNativeMethods.EM_FORMATRANGE, wParam, IntPtr.Zero);

            //Free the block of memory allocated
            Marshal.FreeCoTaskMem(lParam);

            //Release the device context handle obtained by a previous call
            g.ReleaseHdc(hDCEMF);
            g.Dispose();

            hdc = graphics.GetHdc();
            int nHorzSize = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.HORZSIZE);
            int nVertSize = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.VERTSIZE);
            int nHorzRes = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.HORZRES);
            int nVertRes = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.VERTRES);
            int nLogPixelsX = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.LOGPIXELSX);
            int nLogPixelsY = SafeNativeMethods.GetDeviceCaps(hdc, 
SafeNativeMethods.DeviceCap.LOGPIXELSY);
            graphics.ReleaseHdc(hdc);

            float fHorzSizeInches = nHorzSize / 25.4f;
            float fVertSizeInches = nVertSize / 25.4f;
            float fHorzFudgeFactor = (nHorzRes / fHorzSizeInches) / 
nLogPixelsX;
            float fVertFudgeFactor = (nVertRes / fVertSizeInches) / 
nLogPixelsY;

            System.Diagnostics.Debug.WriteLine("Fudge Factor " + 
fHorzFudgeFactor.ToString() + " " + fVertFudgeFactor.ToString() + " XFactor 
" + xFactor.ToString());

            Pen RedPen = new Pen(Color.Red);
            graphics.DrawRectangle(RedPen, layoutArea.X * xFactor, 
layoutArea.Y * xFactor, layoutArea.Width * xFactor, layoutArea.Height * 
xFactor);

            float Left = layoutArea.Left;
            float Top = layoutArea.Top;
            //layoutArea.X = layoutArea.Y = 0;
            layoutArea.Offset(-Left, -Top);
            layoutArea.Offset(Left / fHorzFudgeFactor, Top / 
fVertFudgeFactor);

            System.Drawing.Drawing2D.GraphicsState state = graphics.Save();
            graphics.ScaleTransform(fHorzFudgeFactor * xFactor, 
fVertFudgeFactor * xFactor);
            graphics.DrawImage(metafile, layoutArea);
            graphics.Restore(state);


            System.Diagnostics.Debug.WriteLine("Layout Aread : 
"+layoutArea);
       }

        #region SafeNativeMethods
        private static class SafeNativeMethods
        {
            [DllImport("USER32.dll")]
            public static extern IntPtr SendMessage(IntPtr hWnd, int msg, 
IntPtr wp, IntPtr lp);

            [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            public static extern IntPtr LoadLibrary(string lpFileName);

            [DllImport("gdi32.dll")]
            public static extern int GetDeviceCaps(IntPtr hdc, DeviceCap 
nIndex);

            [StructLayout(LayoutKind.Sequential)]
            public struct RECT
            {
                public int Left;
                public int Top;
                public int Right;
                public int Bottom;
            }

            [StructLayout(LayoutKind.Sequential)]
            public struct CHARRANGE
            {
                public int cpMin;        //First character of range (0 for 
start of doc)
                public int cpMax;        //Last character of range (-1 for 
end of doc)
            }

            [StructLayout(LayoutKind.Sequential)]
            public struct FORMATRANGE
            {
                public IntPtr hdc;                //Actual DC to draw on
                public IntPtr hdcTarget;    //Target DC for determining text 
formatting
                public RECT rc;                        //Region of the DC to 
draw to (in twips)
                public RECT rcPage;                //Region of the whole DC 
(page size) (in twips)
                public CHARRANGE chrg;        //Range of text to draw (see 
earlier declaration)
            }

            public enum DeviceCap : int
            {
                /// &lt;summary&gt;
                /// Device driver version
                /// &lt;/summary&gt;
                DRIVERVERSION = 0,
                /// &lt;summary&gt;
                /// Device classification
                /// &lt;/summary&gt;
                TECHNOLOGY = 2,
                /// &lt;summary&gt;
                /// Horizontal size in millimeters
                /// &lt;/summary&gt;
                HORZSIZE = 4,
                /// &lt;summary&gt;
                /// Vertical size in millimeters
                /// &lt;/summary&gt;
                VERTSIZE = 6,
                /// &lt;summary&gt;
                /// Horizontal width in pixels
                /// &lt;/summary&gt;
                HORZRES = 8,
                /// &lt;summary&gt;
                /// Vertical height in pixels
                /// &lt;/summary&gt;
                VERTRES = 10,
                /// &lt;summary&gt;
                /// Number of bits per pixel
                /// &lt;/summary&gt;
                BITSPIXEL = 12,
                /// &lt;summary&gt;
                /// Number of planes
                /// &lt;/summary&gt;
                PLANES = 14,
                /// &lt;summary&gt;
                /// Number of brushes the device has
                /// &lt;/summary&gt;
                NUMBRUSHES = 16,
                /// &lt;summary&gt;
                /// Number of pens the device has
                /// &lt;/summary&gt;
                NUMPENS = 18,
                /// &lt;summary&gt;
                /// Number of markers the device has
                /// &lt;/summary&gt;
                NUMMARKERS = 20,
                /// &lt;summary&gt;
                /// Number of fonts the device has
                /// &lt;/summary&gt;
                NUMFONTS = 22,
                /// &lt;summary&gt;
                /// Number of colors the device supports
                /// &lt;/summary&gt;
                NUMCOLORS = 24,
                /// &lt;summary&gt;
                /// Size required for device descriptor
                /// &lt;/summary&gt;
                PDEVICESIZE = 26,
                /// &lt;summary&gt;
                /// Curve capabilities
                /// &lt;/summary&gt;
                CURVECAPS = 28,
                /// &lt;summary&gt;
                /// Line capabilities
                /// &lt;/summary&gt;
                LINECAPS = 30,
                /// &lt;summary&gt;
                /// Polygonal capabilities
                /// &lt;/summary&gt;
                POLYGONALCAPS = 32,
                /// &lt;summary&gt;
                /// Text capabilities
                /// &lt;/summary&gt;
                TEXTCAPS = 34,
                /// &lt;summary&gt;
                /// Clipping capabilities
                /// &lt;/summary&gt;
                CLIPCAPS = 36,
                /// &lt;summary&gt;
                /// Bitblt capabilities
                /// &lt;/summary&gt;
                RASTERCAPS = 38,
                /// &lt;summary&gt;
                /// Length of the X leg
                /// &lt;/summary&gt;
                ASPECTX = 40,
                /// &lt;summary&gt;
                /// Length of the Y leg
                /// &lt;/summary&gt;
                ASPECTY = 42,
                /// &lt;summary&gt;
                /// Length of the hypotenuse
                /// &lt;/summary&gt;
                ASPECTXY = 44,
                /// &lt;summary&gt;
                /// Shading and Blending caps
                /// &lt;/summary&gt;
                SHADEBLENDCAPS = 45,

                /// &lt;summary&gt;
                /// Logical pixels inch in X
                /// &lt;/summary&gt;
                LOGPIXELSX = 88,
                /// &lt;summary&gt;
                /// Logical pixels inch in Y
                /// &lt;/summary&gt;
                LOGPIXELSY = 90,

                /// &lt;summary&gt;
                /// Number of entries in physical palette
                /// &lt;/summary&gt;
                SIZEPALETTE = 104,
                /// &lt;summary&gt;
                /// Number of reserved entries in palette
                /// &lt;/summary&gt;
                NUMRESERVED = 106,
                /// &lt;summary&gt;
                /// Actual color resolution
                /// &lt;/summary&gt;
                COLORRES = 108,

                // Printing related DeviceCaps. These replace the 
appropriate Escapes
                /// &lt;summary&gt;
                /// Physical Width in device units
                /// &lt;/summary&gt;
                PHYSICALWIDTH = 110,
                /// &lt;summary&gt;
                /// Physical Height in device units
                /// &lt;/summary&gt;
                PHYSICALHEIGHT = 111,
                /// &lt;summary&gt;
                /// Physical Printable Area x margin
                /// &lt;/summary&gt;
                PHYSICALOFFSETX = 112,
                /// &lt;summary&gt;
                /// Physical Printable Area y margin
                /// &lt;/summary&gt;
                PHYSICALOFFSETY = 113,
                /// &lt;summary&gt;
                /// Scaling factor x
                /// &lt;/summary&gt;
                SCALINGFACTORX = 114,
                /// &lt;summary&gt;
                /// Scaling factor y
                /// &lt;/summary&gt;
                SCALINGFACTORY = 115,

                /// &lt;summary&gt;
                /// Current vertical refresh rate of the display device (for 
displays only) in Hz
                /// &lt;/summary&gt;
                VREFRESH = 116,
                /// &lt;summary&gt;
                /// Horizontal width of entire desktop in pixels
                /// &lt;/summary&gt;
                DESKTOPVERTRES = 117,
                /// &lt;summary&gt;
                /// Vertical height of entire desktop in pixels
                /// &lt;/summary&gt;
                DESKTOPHORZRES = 118,
                /// &lt;summary&gt;
                /// Preferred blt alignment
                /// &lt;/summary&gt;
                BLTALIGNMENT = 119
            }


            public const int WM_USER = 0x0400;
            public const int EM_FORMATRANGE = WM_USER + 57;
            public const int WS_EX_TRANSPARENT = 0x20;

        }
        #endregion
    }
}&lt;br&gt;&lt;br&gt;On Tuesday, October 28, 2008 11:27 AM&lt;br&gt;AliR \(VC++ MVP\) wrote:&lt;br&gt;&lt;br&gt;Let me also mention that the laptop that is having the funny results is&lt;br&gt;Let me also mention that the laptop that is having the funny results is
running Vista 64, the other machines which everything works fine on is
running Vista 32 or XP.

AliR.&lt;br&gt;&lt;br&gt;On Tuesday, October 28, 2008 12:49 PM&lt;br&gt;AliR \(VC++ MVP\) wrote:&lt;br&gt;&lt;br&gt;I setup another machine with Vista 64 and it is happening there too.&lt;br&gt;I setup another machine with Vista 64 and it is happening there too.  So it
looks like Vista 64 is the problem!

AliR.&lt;br&gt;&lt;br&gt;&lt;br&gt;Submitted via EggHeadCafe - Software Developer Portal of Choice &lt;br&gt;DataContractSerializer Basics&lt;br&gt;http://www.eggheadcafe.com/tutorials/aspnet/ad947ce6-cd3e-4647-b69c-94d2f3b1b265/datacontractserializer-ba.aspx</description><pubDate>Wed, 10 Mar 2010 04:34:19 -0800</pubDate><category>C# newsgroup post</category><dc:creator>Martin Wel</dc:creator></item><item><title>Re: Binary Serialized file much larger than expected</title><guid isPermaLink="false" /><description>Stewart wrote:&lt;br&gt;&gt; Hi,&lt;br&gt;&gt; &lt;br&gt;&gt; I have a class which has 6 automatic properties (6 x 8 bytes).  This&lt;br&gt;&gt; means the total size of the class is 48 bytes.  I have 15000 of these&lt;br&gt;&gt; in a generic List.  When I serialize these to disc using the&lt;br&gt;&gt; BinaryFormatter I get a file which is 970kb.  I would have expected&lt;br&gt;&gt; closer to 48 * 15000 / 1000 = 720kb.&lt;br&gt;&gt; &lt;br&gt;&gt; Thoughts?&lt;br&gt;&gt; &lt;br&gt;&gt; Stewart&lt;br&gt;&lt;br&gt;"This means the total size of the class is 48 bytes."  I think I would view it &lt;br&gt;as:  "The minimum required storage for the fields of the class is 48 bytes." &lt;br&gt;They are not the same thing.&lt;br&gt;&lt;br&gt;Did you expect it (binary serialization) to be completetely free of overhead? &lt;br&gt;Your numbers work out to only about 16 bytes of overhead per object.  That seems &lt;br&gt;very modest to me, but of course your example is very simple.&lt;br&gt;&lt;br&gt;-rick-</description><pubDate>Wed, 10 Mar 2010 06:32:31 -0500</pubDate><category>C# newsgroup post</category><dc:creator>Rick Lones &lt;WrlonesX@YcharterZ.net&gt;</dc:creator></item><item><title>Sqlcommand causing memory leak</title><guid isPermaLink="false" /><description>Hi,&lt;br&gt;&lt;br&gt;I'm struggling to find why this piece of code results in memory leak in&lt;br&gt;sqlservr.exe. Could someone please help me in explaining what I'm doing wrong?&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;using (SqlConnection con = new SqlConnection())&lt;br&gt;{&lt;br&gt;  con.ConnectionString = "integrated security=SSPI;data source=127.0.0.1\\&lt;br&gt;SQLEXPRESS;persist security info=False;initial catalog=XLS";&lt;br&gt;  con.Open();&lt;br&gt;&lt;br&gt;  using (SqlCommand myCommand = new SqlCommand("UPDATE dbo.MonitorReaders SET&lt;br&gt;latestRead='" + tinfo.datetime.ToString() + "' WHERE readerIp='" + ip + "'",&lt;br&gt;con))&lt;br&gt;  {&lt;br&gt;    myCommand.ExecuteNonQuery();&lt;br&gt;  }&lt;br&gt;&lt;br&gt;  con.Close();&lt;br&gt;}&lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 10:37:16 GMT</pubDate><category>C# newsgroup post</category><dc:creator>"Pedron" &lt;u58665@uwe&gt;</dc:creator></item><item><title>Re: Writing to existing XML file</title><guid isPermaLink="false" /><description>&lt;br&gt;"Arne Vajhxj" &lt;arne@vajhoej.dk&gt; wrote in message &lt;br&gt;news:4b970b3f$0$279$14726298@news.sunsite.dk...&lt;br&gt;&lt;&lt;&gt;&gt;&lt;br&gt;&gt; Best advice: don't use XML for this but use a database&lt;br&gt;&gt; instead.&lt;br&gt;&gt;&lt;br&gt;&gt; Second best advice: read the entire XML file into memory,&lt;br&gt;&gt; modify it and write it back.&lt;br&gt;&lt;br&gt;Arne gives good advice.&lt;br&gt;&lt;br&gt;I would suggest another option if you want to stick with xml.&lt;br&gt;If you have the option to change the format of your xml.&lt;br&gt;Work in a dataset and save this as xml.&lt;br&gt;Your linq will be a lot easier to understand if you flatten the data out and &lt;br&gt;use a datatable instead. &lt;br&gt;</description><pubDate>Wed, 10 Mar 2010 09:09:19 -0000</pubDate><category>C# newsgroup post</category><dc:creator>"Andy O'Neill" &lt;aon14nocannedmeat@lycos.co.uk&gt;</dc:creator></item><item><title>Re: comboBox from enum?</title><guid isPermaLink="false" /><description>DanB &lt;abc@some.net&gt; wrote:&lt;br&gt;&gt;&lt;br&gt;&gt;This morning I've tried an experiment by copying the exe to my wife's &lt;br&gt;&gt;computer. She has a year old Vista with .NET 3.5 installed.&lt;br&gt;&lt;br&gt;Are you sure?  HOW are you sure?&lt;br&gt;&lt;br&gt;&gt;But it fails &lt;br&gt;&gt;to run on her machine. I have put a MessageBox right at the start so I &lt;br&gt;&gt;don't have to worry about other why's further in the program.&lt;br&gt;&lt;br&gt;Release build?  Debug build?&lt;br&gt;&lt;br&gt;&gt;I can drop a c++ exe on her machine and it runs fine.&lt;br&gt;&lt;br&gt;Not always.  Try to do that with a DEBUG build, for example.  Unless you&lt;br&gt;were foresighted enough to statically link the CRT, you'd be screwed.&lt;br&gt;-- &lt;br&gt;Tim Roberts, timr@probo.com&lt;br&gt;Providenza &amp; Boekelheide, Inc.</description><pubDate>Tue, 09 Mar 2010 22:49:42 -0800</pubDate><category>C# newsgroup post</category><dc:creator>Tim Roberts &lt;timr@probo.com&gt;</dc:creator></item><item><title>Re: MessageSecurityException problem in WCF</title><guid isPermaLink="false" /><description>&gt; Logging is about taking the excpetion message and other exception&lt;br&gt;&gt; information  and using a 3rd party tool to log the excption or taking the&lt;br&gt;&gt; excption message and inserting records into a SQL server Table called tblLog&lt;br&gt;&gt; for rewv.&lt;br&gt;&gt;&lt;br&gt;&gt; This should be done after the try/catch Abort throw\finally close on the&lt;br&gt;&gt; call to the WCF service by the client. You write the exception message at the&lt;br&gt;&gt; client to a log on exception message that has be thrown across the WCF&lt;br&gt;&gt; service to the client.&lt;br&gt;&lt;br&gt;Thanks!</description><pubDate>Wed, 10 Mar 2010 09:51:35 +0500</pubDate><category>C# newsgroup post</category><dc:creator>Aimslife &lt;momer114@gmail.com&gt;</dc:creator></item><item><title>Re: XML Serialization with nullable values</title><guid isPermaLink="false" /><description>Daniel Ulfe wrote:&lt;br&gt;&gt; [...]&lt;br&gt;&gt; I know that I can do it by using the IXmlSerializable interface... that &lt;br&gt;&gt; I have multiple classes that require that behavior... so I prefer not to &lt;br&gt;&gt; "manually" serialize all those classes.&lt;br&gt;&lt;br&gt;In general, if you don't want to write custom serialization, you need to &lt;br&gt;accept the data format imposed on you.  If you can't accept the data &lt;br&gt;format imposed on you, you need to write some kind of custom serialization.&lt;br&gt;&lt;br&gt;&gt; I thought about creating my own XML Serializer... but that will not use &lt;br&gt;&gt; any optimizations the "regular" XMLSerializer does... and it will &lt;br&gt;&gt; require a lot of code too :)&lt;br&gt;&lt;br&gt;It may be worthwhile if you expect to have to have a large number of &lt;br&gt;types that comply with your specific format.  The System.Xml.Linq &lt;br&gt;namespace provides a very nice DOM paradigm for dealing with the XML &lt;br&gt;itself, and the reflection side of things is probably not too bad as &lt;br&gt;compared to having to implement IXmlSerializable in every single type.&lt;br&gt;&lt;br&gt;Pete</description><pubDate>Tue, 09 Mar 2010 20:02:23 -0800</pubDate><category>C# newsgroup post</category><dc:creator>Peter Duniho &lt;no.peted.spam@no.nwlink.spam.com&gt;</dc:creator></item></channel></rss>