<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Bruce Jackson's WebLog</title><subtitle type="html" /><id>http://blogs.msdn.com/bruce_jackson/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bruce_jackson/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/bruce_jackson/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2004-08-20T18:16:00Z</updated><entry><title>Sample application and code showing how to connect and synchronize with Exchange Server over HTTP using WebDAV</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bruce_jackson/archive/2005/02/02/366095.aspx" /><id>http://blogs.msdn.com/bruce_jackson/archive/2005/02/02/366095.aspx</id><published>2005-02-03T06:55:00Z</published><updated>2005-02-03T06:55:00Z</updated><content type="html">&lt;p style="MARGIN: 0in 0in 0pt; mso-outline-level: 1"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;Recently, one my ISV partners told me that they wanted to create a bi-directional Exchange Server connector to keep calendars synchronized between their Exchange Mail Server and their application.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;To make this more challenging, they wanted to be able to deploy this in environments where RPC connectivity was turned off.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN: 0in 0in 0pt; mso-outline-level: 1"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN: 0in 0in 0pt; mso-outline-level: 1"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;There were a couple of approaches we could take to solve the problem.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The first was to enable &lt;a href="http://msdn.microsoft.com/library/en-us/rpc/rpc/remote_procedure_calls_using_rpc_over_http.asp"&gt;RPC over HTTP in Windows 2003&lt;/a&gt;.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The second was to use the &lt;a href="http://msdn.microsoft.com/library/en-us/e2k3/e2k3/wss_references_webdav.asp"&gt;WebDav interfaces into Exchange&lt;/a&gt; as OWA does.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Once I verified that we didn’t require additional functionality than that provided by OWA, I decided to use the Dav interfaces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN: 0in 0in 0pt; mso-outline-level: 1"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;I thought I’d also share the code (C#) and so feel free to download the documentation, code, &lt;a href="http://brucejackson.info/Code/ExchangeDavClasses.zip"&gt;and sample application from here&lt;/a&gt;.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You can also view a short &lt;a href="http://brucejackson.info/Media/DavDemoTutorial/Default.html"&gt;BlogCast here&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 11pt; FONT-FAMILY: 'Gill Sans MT'"&gt;Here is a quick list of what is included:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt 45.35pt; TEXT-INDENT: -17pt; mso-list: l1 level1 lfo2; tab-stops: list 45.35pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Wingdings 2'; mso-fareast-font-family: 'Wingdings 2'; mso-bidi-font-family: 'Wingdings 2'"&gt;&lt;span style="mso-list: Ignore"&gt;¾&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;Remote Exchange Authentication over HTTP or HTTPS by way of either Basic Authentication or Forms-Based Authentication.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt 45.35pt; TEXT-INDENT: -17pt; mso-list: l1 level1 lfo2; tab-stops: list 45.35pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Wingdings 2'; mso-fareast-font-family: 'Wingdings 2'; mso-bidi-font-family: 'Wingdings 2'"&gt;&lt;span style="mso-list: Ignore"&gt;¾&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;Illustrates “Subscribe and Poll” for &lt;b style="mso-bidi-font-weight: normal"&gt;asynchronous&lt;/b&gt; notification of new or changed objects such as new or changed mail, appointments, tasks, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt 45.35pt; TEXT-INDENT: -17pt; mso-list: l1 level1 lfo2; tab-stops: list 45.35pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Wingdings 2'; mso-fareast-font-family: 'Wingdings 2'; mso-bidi-font-family: 'Wingdings 2'"&gt;&lt;span style="mso-list: Ignore"&gt;¾&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;Illustrates “Subscribe and Notify” for &lt;b style="mso-bidi-font-weight: normal"&gt;synchronous&lt;/b&gt; notifications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt 45.35pt; TEXT-INDENT: -17pt; mso-list: l1 level1 lfo2; tab-stops: list 45.35pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Wingdings 2'; mso-fareast-font-family: 'Wingdings 2'; mso-bidi-font-family: 'Wingdings 2'"&gt;&lt;span style="mso-list: Ignore"&gt;¾&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;How to Read and Send Exchange Mail using DAV.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt 45.35pt; TEXT-INDENT: -17pt; mso-list: l1 level1 lfo2; tab-stops: list 45.35pt"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: gray; FONT-FAMILY: 'Wingdings 2'; mso-fareast-font-family: 'Wingdings 2'; mso-bidi-font-family: 'Wingdings 2'"&gt;&lt;span style="mso-list: Ignore"&gt;¾&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;How to read, create, or modify appointments in Exchange using DAV.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 6pt 0in 3pt"&gt;&lt;span style="FONT-FAMILY: 'Gill Sans MT'"&gt;In order to exercise these server-based classes, I have also included a sample client application that will send cell phone SMS messages alerting you of appointment reminders at the times specified in the Exchange based appointment.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=366095" width="1" height="1"&gt;</content><author><name>Bruce Jackson</name><uri>http://blogs.msdn.com/members/Bruce+Jackson.aspx</uri></author></entry><entry><title>Sample Code for IPSec Block Application</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bruce_jackson/archive/2004/08/23/218680.aspx" /><id>http://blogs.msdn.com/bruce_jackson/archive/2004/08/23/218680.aspx</id><published>2004-08-23T22:47:00Z</published><updated>2004-08-23T22:47:00Z</updated><content type="html">&lt;font face="Verdana" size="2"&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;As I pointed out in my previous post, I have written a couple of applications for my Exchange Server at home and I would post the code if anyone was interested.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I’ve had a couple of requests and so I’ve created &lt;a href="http://brucejackson.info/" target="_blank"&gt;a web site&lt;/a&gt; where I’ll post links to the sample code.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Disclaimer: I know the UI is terrible, but the more I try to make my web UI attractive, the worse it gets.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;So my motto is: “simple is better”.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;The first is an SMTP Event Sink that handles my spam protection and I call &lt;i style="mso-bidi-font-style: normal"&gt;SpamSinker&lt;/i&gt;.&amp;nbsp; I need to clean up the code some and will post up the source when I get that done. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;The other was a small application I wrote that I had planned to incorporate into &lt;i style="mso-bidi-font-style: normal"&gt;SpamSinker&lt;/i&gt;, but is currently a small stand-alone application I call &lt;i style="mso-bidi-font-style: normal"&gt;&lt;a href="http://brucejackson.info/Code/BlockIp.zip"&gt;BlockIp&lt;/a&gt;&lt;/i&gt;.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It uses the &lt;a href="http://www.microsoft.com/resources/documentation/WindowsServ/2003/standard/proddocs/en-us/netsh_ipsec.asp" target="_blank"&gt;Dynamic Block of IPSec&lt;/a&gt; to prevent remote computers from connecting to my machine.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;I wrote this because my analysis of the spam log files showed that spammers tend to use a range of IP addresses for a few days and then they move on. Instead of depending on the &lt;i style="mso-bidi-font-style: normal"&gt;SpamSinker&lt;/i&gt; tool to catch them, I decided that once the number of inbound spam messages exceeded a certain threshold from an IP, then IPSec&lt;i style="mso-bidi-font-style: normal"&gt; &lt;/i&gt;would block all future traffic from the IP. &lt;i style="mso-bidi-font-style: normal"&gt;BlockIP&lt;/i&gt; was the first step in writing that code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;The following is a rough description of what the app does:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;BlockIp&lt;/span&gt;&lt;/i&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt; checks for a list of IP Addresses to block when it first starts up.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;If the list doesn’t exist, it creates one.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Although this file is in a .txt format, it actually is stored as xml so that the code can use the data classes generated by the MsDatasetGenerator I mentioned in my last post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Next, it reads and lists in the UI all the IP Addresses you want to block.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It also allows you to remove one or more from the existing list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;When you press the “Save” button, it will invoke the IPSec filter (using the NetSh command) which will remain in effect until you reboot the box; or until you press the “Disable Filters” in the UI.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;It would be very easy to change these from dynamic to static.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;However, I chose dynamic filters since the objective was very specific: to only block IP Addresses temporarily when Spammers were using them and to release the blocks after a few days.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Feel free to download and modify the code for your use.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It is a bit rough and was not written to be sample code but merely as a placeholder until I could move it into &lt;i style="mso-bidi-font-style: normal"&gt;SpamSinker&lt;/i&gt; and so I apologize in advance for the bogus variable names and the lack of comments.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Hopefully, when I have time to move it into &lt;i style="mso-bidi-font-style: normal"&gt;SpamSinker&lt;/i&gt;, I’ll have time to polish it up and add a few comments.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=218680" width="1" height="1"&gt;</content><author><name>Bruce Jackson</name><uri>http://blogs.msdn.com/members/Bruce+Jackson.aspx</uri></author></entry><entry><title>Using XML Files as a Portable Application Database using MsDatasetGenerator </title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/bruce_jackson/archive/2004/08/20/217999.aspx" /><id>http://blogs.msdn.com/bruce_jackson/archive/2004/08/20/217999.aspx</id><published>2004-08-21T01:16:00Z</published><updated>2004-08-21T01:16:00Z</updated><content type="html">&lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Almost every application can benefit from persisting data into a local and portable data repository.&amp;nbsp; For example, I worked for the tools group in Microsoft's IT department writing internal software tools when Microsoft first released Access.&amp;nbsp; I would use Access to store user and error information for my applications while they were in beta.&amp;nbsp; I remember one specific application that would "crash" the same time each day and by looking at the Access db, I found what the error was and more importantly, who had been using it when it crashed.&amp;nbsp; It was a simple matter to call that individual and get a better understanding of what they had been doing and why so I could code around the mistake.&amp;nbsp; I've also used this approach with external customers and simply asked them to email me the Access .mdb file so I could determine what the problems were.&lt;/span&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Visual Studio contains a lightly documented tool called the MsDatasetGenerator (there is a similar but less robust tool in the .NET SDK called xsd.exe) that allows you to do similar things with xml files.&amp;nbsp; Much like Access, these xml files are portable and can be used across several applications.&amp;nbsp; Let me describe some of the ways I've used these and then provide a step-by-step to show you how to get started.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;I run Exchange 2003 on my home network and since my daughters are in college, they use OWA to access their mail and so the cool Outlook 2003 Junk Email filter doesn't catch their spam.&amp;nbsp; So, I decided to write my own Spam filter using .NET and the new SCL in Exchange.&amp;nbsp; I won't go into details here of that application, but suffice it to say that I use rather resource-intensive&amp;nbsp;Reverse DNS to determine if a message is from a spammer.&amp;nbsp; If so, I add their IP to the xml "database".&amp;nbsp; In that way, the application knows that the IP&amp;nbsp;Address&amp;nbsp;is from a probable spammer and in future requests (until the TTL expires), we don't do the DNS lookup again - just check the xml database.&amp;nbsp; I have shared this application with Exchange hosting orgs and they found as I did, that the performance impact was negligible.&amp;nbsp; This attests to the power and speed of these XML "databases" even when there are thousands of entries as I have in my spam xml database.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;I later enhanced the application to tell me the reason (I have several methods I use to mark the SCL) for the detection as well as to increment the hit count from that IP.&amp;nbsp; This allowed me to write another application that used the same xml file to evaluate the spam hits on the server.&amp;nbsp; I found that over a short period of time, spammers will flood my server from several bogus domains but using the same rather small set of IP Addresses.&amp;nbsp; So, I wrote a third application that would use IPSec to block the IPs at the network stack.&amp;nbsp; This application would read the Exchange Spam XML file and organize the hits and display them.&amp;nbsp; This third app would then let me mark which ones I wanted to block and it would store them in another xml database file for the IPSec filter.&amp;nbsp; That way, the block list would load each time I ran the app or rebooted the server.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;The point is, that these files are quick, easy, portable, and an easy way to share data between applications.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Oh, and if any of these apps sound useful, reply with a comment and I’ll write another Blog with a pointer to the code which you can download and use.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;OK, so let’s look at some code.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;span style="mso-list: Ignore"&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Open Visual Studio and create a C# Console application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;span style="mso-list: Ignore"&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Next, using the Solution Explorer, create a New Xml file and call it:&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;i style="mso-bidi-font-style: normal"&gt;testXml.xml&lt;/i&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;span style="mso-list: Ignore"&gt;3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;Put in the following content and save the file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;font size="2"&gt;&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;root&lt;/span&gt;&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;myData&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;myDataStuff1&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=""&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;myDataStuff2&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=""&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in"&gt;&lt;font size="2"&gt;&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;root&lt;/span&gt;&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&amp;gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;span style="mso-list: Ignore"&gt;4.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;Next, in VS create the schema for the xml file (right-click over the .xml file and select Create Schema).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;You should now have a “&lt;i style="mso-bidi-font-style: normal"&gt;testXml.xml&lt;/i&gt;” file and a “&lt;i style="mso-bidi-font-style: normal"&gt;testXml.xsd&lt;/i&gt;” file.&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1" start="5"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial"&gt;&lt;font face="Verdana"&gt;Open the Properties dialog for the &lt;i style="mso-bidi-font-style: normal"&gt;testXml.xsd&lt;/i&gt; file.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In the Custom Tool box, key in:&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;b&gt;MSDatasetGenerator.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/b&gt;Enable the “Show all Files” so you can see the newly generated &lt;i style="mso-bidi-font-style: normal"&gt;testXml.cs&lt;/i&gt; file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-FAMILY: Verdana; mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana"&gt;&lt;span style="mso-list: Ignore"&gt;6.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana; mso-bidi-font-family: Arial"&gt;Open the &lt;i style="mso-bidi-font-style: normal"&gt;testXml.cs&lt;/i&gt; file and notice that over 300 lines of C# code has been generated for this three line xml file.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Review the code and you will see that this tool has created code to support collections, events, etc.&lt;/span&gt;&lt;span style="FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1" start="7"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;span style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial"&gt;&lt;font face="Verdana"&gt;In the &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Main&lt;/st1:place&gt; function (assuming a Console C# app), paste the following code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;// create an instance of the testxml dataset&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;testXml mytest = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; testXml();&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;// you can load data from an existing xml file, this shows how easy it is to move data from &lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;// one location or application to another.&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;// mytest.ReadXml(@"c:\myxmlfile.xml");&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;//or, you can simply populate the dataset and save it to disk&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;mytest.myData.AddmyDataRow("my first row data1", "my first row data 2");&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;mytest.myData.AddmyDataRow("my second row data1", "my second row data 2");&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;// can use the collections to interate through&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (testXml.myDataRow row &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; mytest.myData.Rows)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;System.Diagnostics.Debug.WriteLine("Stuff 1: " + row.myDataStuff1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;System.Diagnostics.Debug.WriteLine("Stuff 2: " + row.myDataStuff2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;font size="2"&gt;mytest.WriteXml(@"C:\myoutput.xml");&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; mso-bidi-font-size: 10.0pt"&gt;&lt;o:p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.25in"&gt;&lt;span style="FONT-SIZE: 12pt; mso-bidi-font-family: Arial"&gt;&lt;font face="Verdana"&gt;You’re done.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;With the tool generated code, you can easily add items, browse through collections, and move the dataset from one application to another, and you never have to use XPath or open the XML in your code!&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=217999" width="1" height="1"&gt;</content><author><name>Bruce Jackson</name><uri>http://blogs.msdn.com/members/Bruce+Jackson.aspx</uri></author></entry></feed>