<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Geek Freeq&#187; Desktop Development Archives  | Geek Freeq</title>
	<atom:link href="http://www.geekfreeq.com/category/desktop-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekfreeq.com</link>
	<description></description>
	<lastBuildDate>Thu, 10 Jun 2010 17:46:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SVN, the Way of the Tortoise</title>
		<link>http://www.geekfreeq.com/svn-tortoise/</link>
		<comments>http://www.geekfreeq.com/svn-tortoise/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 19:29:16 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Desktop Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.geekfreeq.com/?p=455</guid>
		<description><![CDATA[Although, Subversion (SVN) is not new, it is still one of the most widely used version control systems (VCS) available. SVN is a tool that allows users to track the changes of files. Yes, it&#8217;s that simple.
Interfacing Your Demons
Like many version control systems, SVN utilizes a command-line interface (CLI) to interact with users. Some users [...]]]></description>
			<content:encoded><![CDATA[<p>Although, <a href="http://subversion.tigris.org/" target="_blank">Subversion</a> (SVN) is not new, it is still one of the most widely used <a href="http://en.wikipedia.org/wiki/Revision_control" target="_blank">version control systems</a> (VCS) available. SVN is a tool that allows users to track the changes of files. Yes, it&#8217;s that simple.</p>
<h3>Interfacing Your Demons</h3>
<p>Like many version control systems, SVN utilizes a <a href="http://en.wikipedia.org/wiki/Command_line" target="_blank">command-line interface</a> (CLI) to interact with users. Some users frown upon the command-line; especially, Windows users. However, I want to point out how necessary it is that these tools use the command-line.</p>
<p>After you use a version control system for a good length of time, you should notice that there are routines you follow over and over again. Perhaps you lock certain files before editing them to prevent conflicts with other potential editors on your team. Maybe you always commit your changes when you build a project for release, or when you shut down your computer for the evening. The point is, these are things that can be automated with small scripts through build events or even Windows Task Scheduler. Having a command-line tool is essential to such automation.</p>
<p>On the other hand, there are many times you will want to issue commands to SVN on-demand. A nice <a href="http://en.wikipedia.org/wiki/Graphical_user_interface" target="_blank">graphical user interface</a> can make things much easier and faster for those tasks. Enter <a href="http://tortoisesvn.net/" target="_blank">TortoiseSVN</a>.</p>
<p><span id="more-455"></span></p>
<h3>TortoiseSVN and the Shell</h3>
<p>I like to think that the tortoise stands for something meaningful. Granted SVN was created as an alternative to CVS, which had TortoiseCVS. For me, it&#8217;s all about the shell!</p>
<div class="wp-caption alignleft" style="width: 172px"><img title="TortoiseSVN Context Menu" src="http://farm3.static.flickr.com/2548/4011600230_8596853849_o.gif" alt="TortoiseSVN Shell Context Menu" width="162" height="64" /><p class="wp-caption-text">TortoiseSVN Context Menu</p></div>
<p>TortoiseSVN integrates with the <a href="http://en.wikipedia.org/wiki/Windows_shell" target="_blank">Windows shell</a>. That means a <strong>lot </strong>in the way of usability. When you right-click a file from <em>anywhere </em>in Windows, you will see contextual items on the menu for TortoiseSVN commands. Personally, I think this gives much more value to the program than those that just mingle with <a href="http://en.wikipedia.org/wiki/Integrated_development_environment" target="_blank">integrated development environments</a> (IDEs). I use SVN to control more than just source code. In fact, I consider my other project assets to be just as important (i.e. original design images, documentation, research, etc.). Integration with the shell means I can open Windows Explorer and start managing my files with TortoiseSVN.</p>
<h3>Repositories</h3>
<p>Repositories are where your files, and their many versions, are stored. There are many theories on how to organize your repositories, from creating one for each project to creating one for everything. I prefer creating a repository for each solution I am working on. That is, I create a repository for every application, website, or stand-alone library that I work on. My reasoning stems from the fact that I may need to invite new team members into the development process for a given application or website, and I want to be able to ensure they only have access to what they need. It also makes it very easy to move a repository to a remote, shared location in the future.</p>
<p>I do, however, store <strong>all</strong> of my repositories in a single directory on the computer chosen to host them. This makes for a very clean and trivial backup structure. I can easily backup all of my repositories by simply pointing to this root directory. I name mine, &#8220;SVNRepositories&#8221;. Aren&#8217;t I clever?</p>
<h4>Use Templates</h4>
<p>As a programmer and architect, I am a <strong>huge </strong>fan of templates. They make things so much easier. Creating stuff from templates is quicker and less riddled with mistakes. The idea of using templates to create your repositories may seem too trivial to bother with, but it does speed things up and ensures that you stick to a naming convention. Many recommend the following directory structure for repositories.</p>
<ul class="Folders">
<li>SVN Structure
<ul>
<li>branches</li>
<li>tags</li>
<li>trunk</li>
</ul>
</li>
</ul>
<p>The <strong>trunk </strong>is where your primary development line will be maintained. You will commit most of your changes to the trunk. You will most often update your working directory from the trunk (more on this soon). The trunk is the latest official version of your solution. There are conflicting views on exactly how to use the trunk, but this is the most widely accepted usage of it.</p>
<p><strong>Branches </strong>are there for you to try new things and to experiment with the solution/project. Create a branch when you do not want to mess up the trunk with possible breaking changes. Branching is most common when a new feature is being developed that will take some time to implement. You would create a branch from the trunk and begin working on the branch; committing and updating to and from the branch instead of the trunk. Once the feature is complete, the branch should be merged back into the trunk and become part of the overall solution.</p>
<p><em>Note: It is good practice to merge the trunk into a developing branch every so often, so the branch can benefit from any changes made on the trunk.</em></p>
<p><strong>Tags </strong>are ideal for marking milestones for the solution/project. It&#8217;s a good idea to &#8220;tag&#8221; each release of the software, documentation, or the like. This allows you to time travel back to a release at a future point if you need to troubleshoot an issue with that old release, or to revert back to a release if things go awry later. For example, a diet-tracking website I am constantly improving upon will soon be sent to a buddy of mine for his personal use. Each time I send him an update, I will tag that release so I can instruct SVN to find the difference between then and now in order to send him a patch.</p>
<p>Create a directory on your computer that has the 3 sub-directories above in it. The sub-directories should be empty. Name the parent directory as your template structure so that you can find it later. I named mine, &#8220;SVN Structure&#8221;, and have it in a folder named, &#8220;Templates&#8221;.</p>
<h4>New Repositories</h4>
<p>Follow these steps to create a new repository that is consistent with the best practices discussed above.</p>
<div class="wp-caption alignright" style="width: 168px"><img title="New Repositories" src="http://farm3.static.flickr.com/2503/4011737526_2ec93ce208_o.gif" alt="TortoiseSVN - New Repositories" width="158" height="159" /><p class="wp-caption-text">New Repositories</p></div>
<ol>
<li>Create a new sub-directory in your SVNRepositories directory. Make sure you give it a meaningful name for the project/solution it will manage.</li>
<li>Right-click the new sub-directory, hover your mouse over the TortoiseSVN context menu, and click &#8220;Create repository here&#8221;.</li>
<li>You should see a confirmation message that the repository was successfully created.</li>
<li>Navigate to your &#8220;SVN Structure&#8221; directory template, right-click it, hover your mouse over the TortoiseSVN context menu, and click &#8220;Import&#8230;&#8221;.</li>
<li>Enter/select the URL of the new repository you just created. If the repository is on your network, you will use a URL in the form of <a class="linkification-ext" title="Linkification: file:///X:/SVNRepositories/RepositoryName" href="file:///X:/SVNRepositories/RepositoryName">file:///X:/SVNRepositories/RepositoryName</a>. Otherwise, use a valid Web URL for the remote location.</li>
<li>Supply a nice message for the import. I recommend, &#8220;Structure import.&#8221;</li>
<li>Click OK.</li>
<li>Enjoy the log displayed that informs you of the successful addition of the 3 directories and click OK.</li>
</ol>
<p>Feel free to right-click on any folder and choose the &#8220;Repo-browser&#8221; item from the TortoiseSVN context menu. After entering/selecting the URL to your repository, you should see the new structure eagerly awaiting files to manage.</p>
<h3>Working Directories</h3>
<p>A working directory is where you make the changes to your files. These are standard directories that have hidden SVN sub-directories tucked away for change tracking and property management. The presence of these hidden directories is what enables the icon overlays and most commands on the TortoiseSVN context menu.</p>
<p>You can have multiple working directories; even for the same repository. In fact, if you are working on the trunk <strong>and</strong> a branch of your project/solution, you will likely want to have separate working directories, as opposed to switching back and forth between each. Simply, create another directory separate from your current working directory, and checkout the other branch or tag to the new location. Then, you can work in both directories and update/commit to the appropriate trunk/branch/tag for each.</p>
<h4>Setting Up in a Clean Working Directory</h4>
<p>Consider setting up version control <em>before </em>you begin working on a new project. It will make setup easier, and it will ensure that you can start committing changes immediately.</p>
<p>Setting up in a clean working directory is a cinch! After you have created your repository from the structure template provided earlier, follow these steps.</p>
<div class="wp-caption alignright" style="width: 163px"><img title="Checkout" src="http://farm4.static.flickr.com/3522/4011647984_f83956c6f8_o.gif" alt="TortoiseSVN - Checkout" width="153" height="46" /><p class="wp-caption-text">Checkout</p></div>
<ol>
<li>Create a new directory where you would like to start working on your project/solution (e.g. C:\My Documents\My Projects\New Project).</li>
<li>Right-click the new directory and click &#8220;SVN Checkout&#8230;&#8221;.</li>
<li>Enter/select the URL of your new repository.</li>
<li>Append &#8220;/trunk&#8221; to the end of your repository URL (i.e. <a class="linkification-ext" title="Linkification: file:///X:/SVNRepositories/RepositoryName/trunk" href="file:///X:/SVNRepositories/RepositoryName/trunk">file:///X:/SVNRepositories/RepositoryName/trunk</a>).</li>
<li>Ensure that the checkout directory is set to the one you just right-clicked.</li>
<li>Keep the checkout depth set to &#8220;Fully recursive&#8221;.</li>
<li>Make sure the &#8220;HEAD revision&#8221; is selected.</li>
<li>Click OK.</li>
<li>Enjoy the success log and click OK.</li>
</ol>
<p>You now have a working directory all ready to be filled with files. You may notice that the folder icon for your new working directory has a green check overlaying it <img class="Inline" title="TortoiseSVN - Check Overlay" src="http://farm3.static.flickr.com/2493/4010883017_e2783ea58a_o.gif" alt="Check Overlay" width="16" height="14" /> (if you do not see it, refresh Windows Explorer until it appears). This indicates that no changes have been made to files in that directory. Considering there <em>are </em>no files, this makes sense.</p>
<h4>Setting Up in an Existing Working Directory</h4>
<p>If you already began your project and have files inside your working directory, don&#8217;t worry. It isn&#8217;t too much of a pain to get your working directory synchronized with your new repository.</p>
<p>After you have created your repository from the structure template provided earlier, follow these steps.</p>
<div class="wp-caption alignright" style="width: 221px"><img title="Commit" src="http://farm3.static.flickr.com/2600/4014369306_d657f62a3d_m.jpg" alt="TortoiseSVN - Commit" width="211" height="240" /><p class="wp-caption-text">Commit</p></div>
<ol>
<li>Create a new directory, anywhere you&#8217;d like, to hold all of your existing project files temporarily. I often just create a temporary folder on my desktop.</li>
<li>Move (<strong>not </strong>copy, move) all the files and folders that are in your existing working directory to the new temporary directory you created in step 1.</li>
<li>Your existing working directory should be completely empty now.</li>
<li>Right-click the, now empty, working directory and click &#8220;SVN Checkout&#8230;&#8221;.</li>
<li>Enter/select the URL of your new repository.</li>
<li>Append &#8220;/trunk&#8221; to the end of your repository URL (i.e. <a class="linkification-ext" title="Linkification: file:///X:/SVNRepositories/RepositoryName/trunk" href="file:///X:/SVNRepositories/RepositoryName/trunk">file:///X:/SVNRepositories/RepositoryName/trunk</a>).</li>
<li>Ensure that the checkout directory is set to the one you just right-clicked.</li>
<li>Keep the checkout depth set to &#8220;Fully recursive&#8221;.</li>
<li>Make sure the &#8220;HEAD revision&#8221; is selected.</li>
<li>Click OK.</li>
<li>Enjoy the success log and click OK.</li>
<li>Move all of your files and folders back to the working directory from the temporary folder you moved them to in step 2.</li>
<li>Feel free to delete the temporary folder after you verify all the files/folders moved over.</li>
<li>If you peek inside your working directory now, you should see a blue question mark image overlaying your file and folder icons <img class="Inline" title="TortoiseSVN - Question Overlay" src="http://farm3.static.flickr.com/2542/4010882951_0a7297b46a_o.gif" alt="Question Overlay" width="16" height="14" />. This icon indicates that the files/folders are unknown to your repository at this time. In other words, they are not versioned yet. It&#8217;s time to fix that!</li>
<li>Navigate to the parent directory of your working directory, so you can see the working directory in the list of folders. It should have the green check overlay.</li>
<li>Right-click the working directory and click &#8220;SVN Commit&#8230;&#8221;.</li>
<li>Enter a nice message for the initial commit. I recommend, &#8220;Initial commit&#8221;, or similar.</li>
<li>Select all the files and folders you want to add to the repository (drag a rectangle around them with your mouse, or Shift/Ctrl click them), right-click one of them, and click &#8220;Add&#8221;.</li>
<li>If there are any files you want to ignore from now on, select them, right-click one, and click &#8220;Ignore x items by name&#8221;. You may also select a single file and choose to ignore it or all files with the same extension.</li>
<li>Finally, click OK to commit the files to your repository.</li>
<li>Enjoy the success log and click OK.</li>
</ol>
<p>Your existing working directory is now under version control!</p>
<h3>What Next?</h3>
<p>After you have a repository setup and a working directory linked to it, there&#8217;s not much more to do except&#8230;get to work. Just update your working directory, make changes to your files, and commit the changes back to the repository at the end of the day (or sooner if you feel the need). Of course, there are some minor caveats to keep in mind in your daily use.</p>
<h4>Special Actions</h4>
<div class="wp-caption alignright" style="width: 193px"><img title="Rename" src="http://farm4.static.flickr.com/3503/4011648006_4fd48de588_o.gif" alt="TortoiseSVN - Rename" width="183" height="384" /><p class="wp-caption-text">Rename</p></div>
<p>Adding and editing files under version control is a no-brainer. However, there are special considerations for file renaming and moving. If a file is already under version control and you want to rename/move it or delete it, you must use TortoiseSVN to accomplish this in order for it to properly account for the action. Truthfully, you can just delete files and TortoiseSVN will let you mark those files as deleted the next time you issue a commit. The renames/moves are the real trouble-makers if you just make those changes outside of TortoiseSVN.</p>
<p>If you need to rename or move a file, right-click it, and select &#8220;Rename&#8230;&#8221; from the TortoiseSVN context menu. Enter the new name of the file to rename it, or enter the relative path and file name if you want to move it (i.e. SomeSubDirectory\MyFile.txt). Alternatively, you can right-click-drag (drag with the right mouse button) the file to another folder and select &#8220;SVN Move versioned item(s) here&#8221;.</p>
<p>This will instruct SVN to delete the original file and add a new one with the new name/location. If you rename/move an entire folder, you <strong>must</strong> commit the changes before editing any files inside that folder. In addition, make <em>absolutely certain</em> that you <strong>do not</strong> rename, move, or delete a <em>directory </em>that is under version control <strong>except via SVN or TortoiseSVN</strong>. Doing so, will change those hidden SVN sub-directories and that would be very bad. For all the details on these actions, read the <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-rename.html" target="_blank">Deleting, Moving and Renaming section</a> of the <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug.html" target="_blank">Daily Use Guide</a>.</p>
<h3>Further Reading</h3>
<p>I highly recommend that you learn all the capabilities of both SVN and TortoiseSVN. These are great products aimed at helping us stay organized and track revised files. Below is a list of resources I believe are helpful to beginners and seasoned users alike.</p>
<ul>
<li><a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug.html" target="_blank">TortoiseSVN &#8211; Daily Use Guide</a> &#8211; this is a must-read
<ul>
<li><a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-branchtag.html" target="_blank">Branching / Tagging</a></li>
<li><a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-merge.html" target="_blank">Merging</a></li>
<li><a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-patch.html" target="_blank">Creating and Applying Patches</a></li>
</ul>
</li>
<li><a href="http://tortoisesvn.net/most-forgotten-feature" target="_blank">TortoiseSVN &#8211; Most Forgotten Feature</a></li>
<li><a href="http://tortoisesvn.tigris.org/faq.html" target="_blank">TortoiseSVN FAQ</a></li>
<li><a href="http://svnbook.red-bean.com/" target="_blank">Version Control with Subversion (free online version)</a> &#8211; the official Subversion book</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.geekfreeq.com/svn-tortoise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prince of Persia “Combo Specialist” Achievement/Trophy</title>
		<link>http://www.geekfreeq.com/prince-persia-combo-specialist-achievement-trophy/</link>
		<comments>http://www.geekfreeq.com/prince-persia-combo-specialist-achievement-trophy/#comments</comments>
		<pubDate>Mon, 11 May 2009 14:43:34 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Desktop Development]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.geekfreeq.com/?p=449</guid>
		<description><![CDATA[If you are like many Prince of Persia gamers out there, you  have tried tons of different combinations of attack combos in the hopes of  finding the right set that will award you that special achievement/trophy; the  “Combo Specialist”. The good news is, you do not have to perform all 1,602  [...]]]></description>
			<content:encoded><![CDATA[<p>If you are like many Prince of Persia gamers out there, you  have tried tons of different combinations of attack combos in the hopes of  finding the right set that will award you that special achievement/trophy; the  “Combo Specialist”. The good news is, you do <strong>not</strong> have to perform all 1,602  possible combos, like the task hint may lead you to believe. You only need to pull off <strong>60</strong> of them. Other guides will tell you 62, 63, or even more, but 60 is the  magic number (remember, a combo is actually two or more attacks). I have tested  this list at least 10 times with a new user profile each time. There are a few rules to keep in mind when trying to achieve this goal.</p>
<ol>
<li>A combo cannot kill the enemy. Even the last hit cannot kill your enemy.</li>
<li>A combo cannot be blocked by the enemy. No part of the combo can be blocked for you to succeed.</li>
<li>A combo cannot knock an enemy into a wall or off a ledge. If your combo chain is interrupted by an edge animation, it will not count.</li>
<li>After you successfully complete all 60 combos, you must kill the enemy you are currently fighting before the achievement/trophy is awarded.</li>
</ol>
<table border="0" cellspacing="3" cellpadding="5">
<tbody>
<tr>
<td colspan="4"><strong>A</strong> = Acrobatic; <strong>G</strong> = Gauntlet; <strong>M</strong> = Magic; <strong>S</strong> = Sword</td>
</tr>
<tr>
<td>
<ul>
<li>A,G</li>
<li>A,G,A,G</li>
<li>A,G,A,M,G</li>
<li>A,G,A,M,M</li>
<li>A,G,A,M,S</li>
<li>A,G,A,S</li>
<li>A,M,G</li>
<li>A,M,M,G</li>
<li>A,M,M,M</li>
<li>A,M,M,S</li>
<li>A,M,S,G</li>
<li>A,M,S,M,G</li>
<li>A,M,S,M,M</li>
<li>A,M,S,M,S</li>
<li>A,M,S,S</li>
</ul>
</td>
<td>
<ul>
<li>A,S,S,S</li>
<li>G,A</li>
<li>G,A,G</li>
<li>G,A,M,G</li>
<li>G,A,M,M</li>
<li>G,A,M,S</li>
<li>G,A,S</li>
<li>G,G</li>
<li>G,M,A</li>
<li>G,M,G</li>
<li>G,M,M,A</li>
<li>G,M,M,G</li>
<li>G,M,M,M</li>
<li>G,M,M,S</li>
<li>G,M,S,A</li>
</ul>
</td>
<td>
<ul>
<li>G,M,S,G</li>
<li>G,M,S,M,A</li>
<li>G,M,S,M,G</li>
<li>G,M,S,M,M</li>
<li>G,M,S,M,S</li>
<li>G,M,S,S</li>
<li>G,S</li>
<li>M,A</li>
<li>M,G</li>
<li>M,M,A</li>
<li>M,M,G</li>
<li>M,M,M</li>
<li>M,M,S</li>
<li>M,S,A</li>
<li>M,S,G</li>
</ul>
</td>
<td>
<ul>
<li>M,S,M,A</li>
<li>M,S,M,G</li>
<li>M,S,M,M</li>
<li>M,S,M,S</li>
<li>M,S,S</li>
<li>S,A</li>
<li>S,G</li>
<li>S,M</li>
<li>S,S,A</li>
<li>S,S,G</li>
<li>S,S,M</li>
<li>S,S,S,A</li>
<li>S,S,S,G</li>
<li>S,S,S,M</li>
<li>S,S,S,S</li>
</ul>
</td>
</tr>
</tbody>
</table>
<h3>Want to Know How I Figured It Out?</h3>
<p>How do I know that there are 1,602 total combos? How do I know that 60 of them are required for the &#8220;Combo Specialist&#8221; achievement/trophy? I wrote a software program to figure it out for me!</p>
<p>That&#8217;s right. I could <strong>not </strong>find a definitive list anywhere on the Net. The official game guide does not even list the exact combos necessary to get the award.</p>
<p>You can <a title="Game Attack Combos Article" href="http://www.codeproject.com/KB/smart/GameAttackCombos.aspx" target="_blank">read about the program that I wrote on CodeProject.com</a>. If you&#8217;re just interested in the code that calculates this award, look near the end of the Contents at the beginning of the article. You can see some very cool screenshots of the application too. Hey, while you&#8217;re there, vote me a 5 if you like it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekfreeq.com/prince-persia-combo-specialist-achievement-trophy/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>LINQ with SQL Server CE 3.5</title>
		<link>http://www.geekfreeq.com/linq-sql-server-ce-35/</link>
		<comments>http://www.geekfreeq.com/linq-sql-server-ce-35/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 03:00:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Data Practice]]></category>
		<category><![CDATA[Desktop Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://blog.ventaur.com/index.php/archives/linq-with-sql-server-ce-35</guid>
		<description><![CDATA[LINQ is an extremely useful new language feature for the .NET Framework 3.5. It allows querying all sorts of data structures via the actual programming language (thus the Language INtegrated in LINQ). In addition, the specific variant, LINQ to SQL, includes a full O/RM (Object/Relational Mapper). Since many developers spend a ton of time mapping [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx" target="_blank">LINQ</a> is an extremely useful new language feature for the .NET Framework 3.5. It allows querying all sorts of data structures via the actual programming language (thus the Language INtegrated in LINQ). In addition, the specific variant, <a href="http://msdn2.microsoft.com/en-us/library/bb386976.aspx" target="_blank">LINQ to SQL</a>, includes a full <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">O/RM</a> (Object/Relational Mapper). Since many developers spend a ton of time mapping their relational data to objects, this included tool is a phenomenal time-saver. Of course, this is not a new concept, nor is it the first of its kind for .NET. It&#8217;s just free and included!</p>
<p>LINQ to SQL currently only works with <a href="http://www.microsoft.com/sql/2005/" target="_blank">SQL Server 2005</a>. It&#8217;s not likely that Microsoft will bother with any other providers with the <a href="http://msdn2.microsoft.com/en-us/library/bb399572.aspx" target="_blank">Entity Framework</a> and <a href="http://msdn2.microsoft.com/en-us/library/bb386964.aspx" target="_blank">LINQ to Entities</a> on the horizon. There is a way to get standard LINQ to SQL to work with the SQL Server Compact Edition (SSCE) however. You have to use the <a href="http://msdn2.microsoft.com/en-us/library/bb386987.aspx" target="_blank">SqlMetal</a> command-line tool to generate the appropriate file(s). Once you generate the .dbml file, you can even open it in the <a href="http://msdn2.microsoft.com/vstudio/products/" target="_blank">Visual Studio 2008</a> designer.</p>
<p><span id="more-25"></span></p>
<h3>Deploying SSCE when Using LINQ</h3>
<p>Deploying SSCE with your desktop application is pretty easy. You can quickly publish your application via <a href="http://msdn2.microsoft.com/en-us/library/t71a733d.aspx" target="_blank">ClickOnce</a>, but I&#8217;m not a big fan of that technology. Instead, I prefer an installer program. You can use any one that you prefer and still easily deploy SSCE with a couple of options.</p>
<h4>Windows Installer</h4>
<p>First, you can choose to create a pre-requisite or dependency tests for the system installation of SSCE for the version you require (3.5 or later to work with LINQ). If the engine is not installed, you can send the user to the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=7849B34F-67AB-481F-A5A5-4990597B0297" target="_blank">Microsoft website</a> for installation or you can launch the redistributable <a href="http://msdn2.microsoft.com/en-us/library/aa367449.aspx" target="_blank">Windows Installer</a> file for it. This method requires that the user have <em>Administrator </em>privileges in order to perform the system install.</p>
<p>Please note that if you launch the .msi file to install SSCE and your installer is a Windows Installer program, you will have to close your installer first; two instances of Windows Installer cannot be run simultaneously.</p>
<h4>X-Copy</h4>
<p>Second, you can just copy the necessary redistributable library files for the SSCE engine into your application&#8217;s install directory. This method does <strong>not</strong> require <em>Administrator</em> privileges! There are 7 files that need to be copied with your application and they should be copied to the same directory as your primary executable.</p>
<ul>
<li>sqlceca35.dll</li>
<li>sqlcecompact35.dll</li>
<li>sqlceer35EN.dll</li>
<li>sqlceme35.dll</li>
<li>sqlceoledb35.dll</li>
<li>sqlceqp35.dll</li>
<li>sqlcese35.dll</li>
</ul>
<p>Make sure your application references the System.Data.SqlServerCe.dll assembly and it is set to copy the assembly locally as well. This is especially important when you use LINQ to SQL with SSCE because that assembly is implied at runtime and therefore not explicitly required as a reference in your application until it&#8217;s time to deploy on a system that does not have SSCE installed.</p>
<p>Please, be aware that if you choose to redistribute SSCE in either form (Windows Installer or individual libraries), you must <a href="http://www.microsoft.com/sql/editions/compact/redistribute.mspx" target="_blank">register for redistribution rights</a> with Microsoft.</p>
<h4>The Hidden Problem</h4>
<p>There is a hidden problem with all of this will finally crop up with the x-copy method. Since LINQ uses a <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" target="_blank">factory pattern</a> to acquire the necessary data provider, the necessary reference to the provider does not occur until runtime. Herein lies the problem.</p>
<p>When your application makes that first attempt via LINQ to connect to the SSCE database file without a system install, you will receive the following error message:</p>
<blockquote><p>Cannot open &#8220;X:Pathtodatafiledatafile.sdf&#8221;. Provider &#8216;System.Data.SqlServerCe.3.5&#8242; not installed.</p>
</blockquote>
<p>If SSCE is installed by the user via the Windows Installer file, this problem is handled for you. The installer adds an entry to your machine.config file. Since the whole purpose of an x-copy install is usually to avoid the need for <em>Administrator</em> privileges, this just will not do.</p>
<p>Instead, you will need to add an application configuration file to your desktop application, if you do not have one already. Right-click your project in &#8220;Solution Explorer&#8221;, choose &#8220;Add new&#8230;&#8221;, select &#8220;Application Configuration&#8221;, and click OK. Make sure the new file looks like this:</p>
<pre name="code" class="xml">&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;configuration&gt;
  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;remove invariant="System.Data.SqlServerCe.3.5" /&gt;
      &lt;add
        name="Microsoft SQL Server Compact Data Provider"
        invariant="System.Data.SqlServerCe.3.5"
        description=".NET Framework Data Provider for Microsoft SQL Server Compact"
        type="System.Data.SqlServerCe.SqlCeProviderFactory,
          System.Data.SqlServerCe,
          Version=3.5.0.0,
          Culture=neutral,
          PublicKeyToken=89845dcd8080cc91"
      /&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;/configuration&gt;</pre>
<p>This ensures that the appropriate database provider factory is added for your application, without the need to edit the end-user&#8217;s machine.config file or require a system installation of SSCE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekfreeq.com/linq-sql-server-ce-35/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
