<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
  <channel>
    <title>DotNetKicks.com : Stories kicked by snaits</title>
    <description>Stories kicked by snaits</description>
    <link>http://www.dotnetkicks.com/</link>
    <language>en-us</language>
    <copyright>Atweb Publishing Ltd.</copyright>
    <docs>http://backend.userland.com/rss</docs>
    <generator>DotNetKicks.com - .NET links, community driven</generator>
    <ttl>30</ttl>
    <item>
      <title>Dealing with apostrophe (') problem in asp.net, sql server, oracle dat</title>
      <description>The use of apostrophe (') character as an input text in an sql query troubles the query operation. Say, you have a textbox in which user can input her search text and she inputs &amp;quot;john's&amp;quot; as her search text. Now your employee query will look like: 

So I have explained the solution to this universal problem. This may occur anywhere in any database query: sql server , oracle of mysql. &amp;lt;a href=&amp;quot;http://dotnetspidor.blogspot.com/2008/11/dealing-with-apostrophe-problem-in_28.html&amp;quot;&amp;gt;So here goes the handy solution&amp;lt;/a&amp;gt;
 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnetspidor.blogspot.com%2f2008%2f11%2fdealing-with-apostrophe-problem-in_28.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnetspidor.blogspot.com%2f2008%2f11%2fdealing-with-apostrophe-problem-in_28.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/aspnet/Dealing_with_apostrophe_problem_in_asp_net_sql_server_oracle_dat</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/aspnet/Dealing_with_apostrophe_problem_in_asp_net_sql_server_oracle_dat</guid>
      <pubDate>Fri, 28 Nov 2008 13:41:55 GMT</pubDate>
    </item>
    <item>
      <title>Back to Basics: Delegates, Anonymous Methods and Lambda Expressions</title>
      <description>Great article on .NET basics &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fcodebetter.com%2fblogs%2fkarlseguin%2farchive%2f2008%2f11%2f27%2fback-to-basics-delegates-anonymous-methods-and-lambda-expressions.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fcodebetter.com%2fblogs%2fkarlseguin%2farchive%2f2008%2f11%2f27%2fback-to-basics-delegates-anonymous-methods-and-lambda-expressions.aspx" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/Back_to_Basics_Delegates_Anonymous_Methods_and_Lambda_Expressions</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/Back_to_Basics_Delegates_Anonymous_Methods_and_Lambda_Expressions</guid>
      <pubDate>Fri, 28 Nov 2008 18:46:10 GMT</pubDate>
    </item>
    <item>
      <title>Building a Web Part UI</title>
      <description>Recently I've been spending a lot of time working on various SharePoint projects, none more challenging than the Citro&amp;#235;n site launched earlier this year. I'm going to take the time to explain how we put together our web parts and server controls, particularly from the point of view of a WCM scenario where the complexity of our mark-up was significantly greater than that of a traditional &amp;quot;vanilla&amp;quot; intranet SharePoint due to the various accessibility guidelines we needed to adhere to as part of the project. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.dotnetsolutions.ltd.uk%2fblog%2fpost%2f2008%2f11%2f24%2fBuilding-Web-Part-UI.aspx"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.dotnetsolutions.ltd.uk%2fblog%2fpost%2f2008%2f11%2f24%2fBuilding-Web-Part-UI.aspx" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/aspnet/Building_a_Web_Part_UI</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/aspnet/Building_a_Web_Part_UI</guid>
      <pubDate>Fri, 28 Nov 2008 11:57:56 GMT</pubDate>
    </item>
    <item>
      <title>unit testing your events</title>
      <description>In this article I will show you how you can unit test your events. I will show you a simple technique that will enable you to test if your events fire exactly as often as you want them to and I will provide you with two implementations. One implementation works well with the .NET Framework 2.0 and the second one uses .NET 3.0 (anonymous methods) in order to minimize the code necessary. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.dotnettoad.com%2findex.php%3f%2farchives%2f12-unit-testing-events.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.dotnettoad.com%2findex.php%3f%2farchives%2f12-unit-testing-events.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/unit_testing_your_events</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/unit_testing_your_events</guid>
      <pubDate>Sun, 04 May 2008 11:01:02 GMT</pubDate>
    </item>
    <item>
      <title>How do you backup an unknown number of SQL server databases</title>
      <description>How do you backup an unknown number of SQL server databases &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f03%2fhow-do-you-backup-unknown-number-of-sql.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f03%2fhow-do-you-backup-unknown-number-of-sql.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/database/How_do_you_backup_an_unknown_number_of_SQL_server_databases</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/database/How_do_you_backup_an_unknown_number_of_SQL_server_databases</guid>
      <pubDate>Wed, 23 Apr 2008 09:29:32 GMT</pubDate>
    </item>
    <item>
      <title>Reflecting on reflection</title>
      <description>Some weeks ago I was working on a project where we receive some ten or twenty different message types from a server, and they all need to be handled when they arrive. Of course, we want to use event driven programming to make this happen on the fly, instead of polling all the time.

All of the messages have the header in common, so we already made a abstract parent class called Message, and when it came to handling all the different messages, we wanted to write as little code as possible. So we added an abstract method called HandleResponse to the code.

So the idea was to identify the incoming message type and invoke the HandleResponse using reflection on the object that we had identified this as. To do this, we made a little xml file that contains the message code (A-Z) along with the name and reference to the class linked to the message type. When the program starts, it reads the xml into a dictionary, so we can look up the key (message code) and get the class reference in return.

XDocument descriptorsXml = XDocument.Load( @&amp;quot;.\Data\MessageDescriptors.xml&amp;quot;);

var descQuery = from desc in descriptorsXml.Descendants(&amp;quot;Message&amp;quot;)
select new MessageDescriptor
{
Code = desc.Element(&amp;quot;Code&amp;quot;).Value,
Name = desc.Element(&amp;quot;Name&amp;quot;).Value,
ObjectType = desc.Element(&amp;quot;ObjectType&amp;quot;).Value.ToType() ,
IsServerMessage = Convert.ToBoolean( desc.Element(&amp;quot;IsServerMessage&amp;quot;).Value )
};
foreach (MessageDescriptor m in descQuery)
{
descriptors.Add(m.Code, m);
}

Then, we have a MessageHandlingFactory that simply gets objects in from a queue, identifies the type, and invokes the HandleResponse. If the object isn't recognized (could be a new message type, or could be that the programmer forgot to insert the description in the XML file), the MessageHandlingFactory can either throw an exception, or better yet, return a string with message that tells the user what went wrong. If everything goes as planned, it returns a string with the identified typename.


object theType = Activator.CreateInstance(t, SessionID);
EventInfo eInfo = t.GetEvent(&amp;quot;OnWriteEvent&amp;quot;);
Message.WriteEventHandler theHandler = new Message.WriteEventHandler(OnWriteEventHandler);

eInfo.AddEventHandler(theType, theHandler);
theType.GetType().GetMethod(&amp;quot;HandleResponse&amp;quot;).Invoke(theType, new object[] { message });

return &amp;quot;MessageHandler: &amp;quot; + messageType;


That's all, folks!


Update February 13, 2008: The code has now been tested in a very high throughput environment, and it performs  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f01%2freflecting-on-reflection.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f01%2freflecting-on-reflection.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/Reflecting_on_reflection</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/Reflecting_on_reflection</guid>
      <pubDate>Thu, 14 Feb 2008 13:00:30 GMT</pubDate>
    </item>
    <item>
      <title>Where are my Properties.Settings saved</title>
      <description>Have you ever wondered where your user settings are saved from an .NET application? You would probably think that it's saved in the [application].exe.config(located in your application folder) file, but this is only partially true. The default values you create in Visual Studio are saved in this file. But if you change these settings at runtime:

Properties.Settings.Default.myValue = &amp;quot;MyNewValue&amp;quot;;
Properties.Settings.Default.Save();

they are saved to a different location. Namely the User.config file:

C:\Documents and Settings\[USER]\Local Settings\Application Data\[company]\[applicationname]\[version]

Note that if you should change the company name or AssemblyVersion attribute in your AssemblyInfo.cs your Settings will be saved in a new location.

Since you do not override the default settings in the exe.config file, you can call the reset() method to restore the settings to its original state:

Properties.Settings.Default.Reset(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fwhere-is-my-propertiessettings-saved.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fwhere-is-my-propertiessettings-saved.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/Where_are_my_Properties_Settings_saved</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/Where_are_my_Properties_Settings_saved</guid>
      <pubDate>Thu, 14 Feb 2008 13:00:10 GMT</pubDate>
    </item>
    <item>
      <title>Managing Unmanaged Resources</title>
      <description>Unmanaged Resources are objects that are not garbage collected, which means that they are not reclaimed by the system when the garbage collector cleans up after you.

But are Unmanaged Resources resources outside .NET framework like DLL used through interop? No, unmanaged resources can also be database connection. It is a common mistake by programmers not to close the connection when finished working with it, in misconception that the garbage collection will close it.

So how do I identify if the object is an unmanaged resource? If the object implement the IDisposable interface it have an unmanaged resource and you need to call the IDisposable.Dispose() method to clean the objects unmanaged resource.
If you use the object in a single call you can wrap it in a using statement (http://softscenario.blogspot.com/2007/10/using-using.html), and it will call the Dispose() method for you. If you keep the object for a longer time you must support the IDisposable interface in your class, and in your implementation of the Idisposable.Dispose() call the member's IDisposable method.


Remember to look for the IDisposable interface in the classes you use in your development. You will be surprised how many classes that do. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fmanaging-unmanaged-resources.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fmanaging-unmanaged-resources.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/Managing_Unmanaged_Resources</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/Managing_Unmanaged_Resources</guid>
      <pubDate>Thu, 14 Feb 2008 12:59:56 GMT</pubDate>
    </item>
    <item>
      <title>Illegal Cross Thread Operation?</title>
      <description>I see many forumposts solving this problem by simply adding the CheckForIllegalCrossThreadOperations=false;

While this is a totally legit workaround, it is highly thread-unsafe, and should only be used for debugging purposes. To be able to update for instance form-components from another thread, you will need to use delegates and invoke. Sounds scary? Not really.

A delegate is simply a &amp;quot;blueprint&amp;quot; that describes how a particular function or method should look. In C++ world, delegates are similar to Function pointers, but since we don't work with pointers in C# this is the closest we get. Still, function pointer is not a correct definition, as the delegate won't point to a function unless you make it do so. Here's an example: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fillegal-cross-thread-operation.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fsoftscenario.blogspot.com%2f2008%2f02%2fillegal-cross-thread-operation.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;
</description>
      <link>http://www.dotnetkicks.com/csharp/Illegal_Cross_Thread_Operation</link>
      <guid isPermaLink="true">http://www.dotnetkicks.com/csharp/Illegal_Cross_Thread_Operation</guid>
      <pubDate>Thu, 14 Feb 2008 12:59:11 GMT</pubDate>
    </item>
  </channel>
</rss>