<?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/"
	>

<channel>
	<title>Brant Burnett&#039;s Development Blog &#187; .NET Framework</title>
	<atom:link href="http://btburnett.com/category/netframework/feed" rel="self" type="application/rss+xml" />
	<link>http://btburnett.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Apr 2010 12:48:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simplify CSS and Javascript Compression In Visual Studio</title>
		<link>http://btburnett.com/2010/02/simplify-css-and-javascript-compression-in-visual-studio.html</link>
		<comments>http://btburnett.com/2010/02/simplify-css-and-javascript-compression-in-visual-studio.html#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:35:26 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://btburnett.com/?p=127</guid>
		<description><![CDATA[I&#8217;ve released a new open source tool that performs design-time compression of your CSS and Javascript files in Visual Studio projects.  This can be a big help, since it allows you to easily do it in your project rather than as part of your build/publish process.  And, since it leaves both the compressed and uncompressed [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released a new open source tool that performs design-time compression of your CSS and Javascript files in Visual Studio projects.  This can be a big help, since it allows you to easily do it in your project rather than as part of your build/publish process.  And, since it leaves both the compressed and uncompressed versions in place, you can still use the uncompressed version for debugging.</p>
<p>Read more about this new tool or download it at <a href="http://btburnett.com/netcompressor">http://btburnett.com/netcompressor</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2010/02/simplify-css-and-javascript-compression-in-visual-studio.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create A Self-Signed SSL Certificate In .NET</title>
		<link>http://btburnett.com/2009/05/create-a-self-signed-ssl-certificate-in-net.html</link>
		<comments>http://btburnett.com/2009/05/create-a-self-signed-ssl-certificate-in-net.html#comments</comments>
		<pubDate>Fri, 08 May 2009 13:50:43 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://btburnett.com/?p=95</guid>
		<description><![CDATA[A problem that I have commonly run into is trying to secure communications using SSL or other encryption for a intranet application. In this scenario, it is unnecessary to have a secure certificate signed by an expensive Internet authority. And often it is intended for deployment in a small-scale scenario where there might not be [...]]]></description>
			<content:encoded><![CDATA[<p>A problem that I have commonly run into is trying to secure communications using SSL or other encryption for a intranet application.  In this scenario, it is unnecessary to have a secure certificate signed by an expensive Internet authority.  And often it is intended for deployment in a small-scale scenario where there might not be a Certification Authority running on a Window Server.  In this case, you want to create a self-signed certificate and use the thumbprint of the certificate for phishing prevention.</p>
<p>Microsoft does provide a utility, makecert, which can create a self-signed certificate.  However, it isn&#8217;t distributed with Windows, is command line only, and definately NOT end user friendly.  I wanted a method for creating a certificate just by clicking a button, without using a shell calls and distributing a copy of makecert with my applications.</p>
<p>To this end, I created a VB.Net class that calls out to the CryptoAPI and creates a self signed certificate with a 2048-bit RSA key.  The certificate and private key are stored in the Local Machine store.  In the Local Machine store it can be accessed by system processes and services.  I&#8217;ve attached an example of the class to this post, feel free to use it as you see fit.</p>
<a class="downloadlink" href="http://btburnett.com/wp-content/plugins/download-monitor/download.php?id=5" title=" downloaded 338 times" >Certificate Creator (338)</a>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2009/05/create-a-self-signed-ssl-certificate-in-net.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Enumerations For Columns With LINQ</title>
		<link>http://btburnett.com/2008/08/using-enumerations-for-columns-with-linq.html</link>
		<comments>http://btburnett.com/2008/08/using-enumerations-for-columns-with-linq.html#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:23:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=18</guid>
		<description><![CDATA[One of the great features of LINQ that DataSets didn&#8217;t support well is the ability to use enumerations for your columns instead of integers. It can make writing and working with your code a lot easier. This is accomplished by manually setting the Type of the column to the type of the enumeration in the [...]]]></description>
			<content:encoded><![CDATA[<div xmlns='http://www.w3.org/1999/xhtml'><small>One of the great features of LINQ that DataSets didn&#8217;t support well is the ability to use enumerations for your columns instead of integers.  It can make writing and working with your code a lot easier.  This is accomplished by manually setting the <em>Type</em> of the column to the type of the enumeration in the visual designer.<br/><br/>There are two important notes to remember about doing this.  First, it takes extra work if you want to use an enumeration that is in a different namespace from the LINQ classes.  You must not only include the full namespace, but also the global:: prefix.  So &#8220;global::EnumNamespace.EnumTypeName&#8221; refers to the enumeration <i>EnumTypeName</i> in the <i>EnumNamespace</i> namespace.  Secondly, if you want to update the data structure from the database, you have to remember to manually set the <i>Type</i> back to the enum type from integer.<br/><br/>This system works great most of the time, including when performing LINQ queries in your code.  However, the one place it doesn&#8217;t seem to work well is in the <i>Where</i> clause of a <i>LinqDataSource</i>.  If you try to select on the column values of an enumeration column here, you&#8217;ll get various exceptions.  If you try to refer to the enumeration constants, you get &#8220;No property or field &#8216;<i>x</i>&#8216; exists in type &#8216;<i>y</i>&#8216;.  I&#8217;ve tried various namespace permutations with no success.  If you try to use integers directly instead of enumeration members, you get &#8220;Argument types do not match&#8221;.<br/><br/>The only solution I have found to the problem is to typecast the column and compare to integers.  For example, &#8220;Int32(ColumnName) == 1&#8243;.  Personally, I don&#8217;t like this solution much because it can cause huge problems if your constants ever change, but it works.<br/><br/>Also, if you are dealing with a <i>Flags</i> enumeration, it gets even worse.  I haven&#8217;t found any way to do bitwise operations in the Where clause, so you have to compare the column to all possible integers that contain the bits you are interested in.<br/><br/>If anybody knows of a better way to address this issue, please post a comment and let me know.  Thanks.<br/></small></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/08/using-enumerations-for-columns-with-linq.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Handlers That Do Thread-Safe Invokes</title>
		<link>http://btburnett.com/2008/07/event-handlers-that-do-thread-safe-invokes.html</link>
		<comments>http://btburnett.com/2008/07/event-handlers-that-do-thread-safe-invokes.html#comments</comments>
		<pubDate>Fri, 11 Jul 2008 10:21:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=17</guid>
		<description><![CDATA[I recently ran into a scenario where I wanted to write a class to do a low-level serial interface to a barcode scanner. When the barcode is scanned I wanted it to fire an event back to the Windows form. The complication was that the SerialPort class provided by .NET 2.0 fires the DataReceived event [...]]]></description>
			<content:encoded><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><small>I recently ran into a scenario where I wanted to write a class to do a low-level serial interface to a barcode scanner.  When the barcode is scanned I wanted it to fire an event back to the Windows form.  The complication was that the SerialPort class provided by .NET 2.0 fires the DataReceived event on an independent thread.  In order to fire the event back to the form it needs to be synchronized to run on the thread of the form using the Invoke method.</p>
<p>While this can be done using manual delegates and other methods, they don&#8217;t work very cleanly like an actual event handler does for simple development.  The fix to this problem is to actually write a custom event handler.  The custom event handler implements all of the back end handling that is normally hidden by VB.  Here is the example code from the barcode scanner class:<br /></small><br />
<blockquote><small>Private _barcodeScannedList As List(Of EventHandler(Of BarcodeScannedEventArgs))<br />Public Custom Event BarcodeScanned As EventHandler(Of BarcodeScannedEventArgs)
<div style="margin-left: 2em">AddHandler(ByVal value As EventHandler(Of BarcodeScannedEventArgs))
<div style="margin-left: 2em">If _barcodeScannedList Is Nothing Then
<div style="margin-left: 2em">_barcodeScannedList = New List(Of EventHandler(Of BarcodeScannedEventArgs))</div>
<p>End If<br />_barcodeScannedList.Add(value)</div>
<p>End AddHandler</p>
<p>RemoveHandler(ByVal value As EventHandler(Of BarcodeScannedEventArgs))
<div style="margin-left: 2em">If Not _barcodeScannedList Is Nothing Then
<div style="margin-left: 2em">_barcodeScannedList.Remove(value)</div>
<p>End If</div>
<p>End RemoveHandler</p>
<p>RaiseEvent(ByVal sender As Object, ByVal e As BarcodeScannedEventArgs)
<div style="margin-left: 2em">If Not _barcodeScannedList Is Nothing Then
<div style="margin-left: 2em">For Each handler As EventHandler(Of BarcodeScannedEventArgs) In _barcodeScannedList
<div style="margin-left: 2em">Dim safeInvoker As ISynchronizeInvoke = TryCast(handler.Target, ISynchronizeInvoke)<br />If safeInvoker Is Nothing Then
<div style="margin-left: 2em">handler.Invoke(sender, e)</div>
<p>Else
<div style="margin-left: 2em">safeInvoker.Invoke(handler, New Object() {sender, e})</div>
<p>End If</div>
<p>Next</div>
<p>End If</div>
<p>End RaiseEvent</div>
<p>End Event</small></p></blockquote>
<p><small>The _barcodeScannedList simply stores a list of all of the event handlers that have been registered with the class.  AddHandler and RemoveHandler do the process of actually adding and removing those event handlers from the list.  The real meat is in the RaiseEvent handler.  Instead of simply iterating through the list and firing all of the event delegates directly like the standard handler does, this handler tests to see if the target class of the delegate implements the ISynchronizeInvoke interface.  System.Windows.Forms.Control does implement this interface, meaning that all Forms implement it.  If this interface is found, then the interface&#8217;s Invoke method is used instead of the delegate&#8217;s Invoke method.  This will synchronize the call onto the delegate&#8217;s target&#8217;s thread.<br /></small></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/07/event-handlers-that-do-thread-safe-invokes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forcing 32-bit Execution in .NET</title>
		<link>http://btburnett.com/2008/06/forcing-32-bit-execution-in-net.html</link>
		<comments>http://btburnett.com/2008/06/forcing-32-bit-execution-in-net.html#comments</comments>
		<pubDate>Tue, 03 Jun 2008 09:55:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[.NET Framework]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=14</guid>
		<description><![CDATA[Sometimes when developing .NET applications it becomes necessary to force an application to run in 32-bit mode, even on a 64-bit processor. One scenario that I&#8217;ve run into is when you&#8217;re using Crystal Reports embedded in the application. I&#8217;m not sure about newer versions, but for Crystal Reports XI R2 it won&#8217;t work in 64-bit [...]]]></description>
			<content:encoded><![CDATA[<div xmlns='http://www.w3.org/1999/xhtml'><small>Sometimes when developing .NET applications it becomes necessary to force an application to run in 32-bit mode, even on a 64-bit processor.  One scenario that I&#8217;ve run into is when you&#8217;re using Crystal Reports embedded in the application.  I&#8217;m not sure about newer versions, but for Crystal Reports XI R2 it won&#8217;t work in 64-bit mode.<br/><br/>In order to get something like that to work, you must force 32-bit execution on the executable.  Forcing it on a DLL assembly in your application won&#8217;t help, then it won&#8217;t be able to load that DLL either.  It needs to start in 32-bit mode from the beginning.  If you can make the change in the development environment before compilation, just set the flags on the assembly there and everything will be great.<br/><br/>However, if you need to make the change to a compiled assembly it&#8217;s a little more difficult.  To do so, use the corflags command-line utility.  This program is included in the Windows SDK.  To do so, simply run &#8220;corflags program.exe /32BIT+&#8221;.<br/><br/>If the assembly is strongly-named, then you must do a little more.  First, you must add a /force flag, running &#8220;corflags program.exe /32BIT+ /Force&#8221;.  Then, you must rehash and resign the assembly, using &#8220;sn -Ra program.exe key.snk&#8221;.  In this case, key.snk is your key file for signing the assembly.<br/><br/>Hope this helps!<br/></small></div>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/06/forcing-32-bit-execution-in-net.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Transactions With DataSets</title>
		<link>http://btburnett.com/2008/03/using-transactions-with-datasets.html</link>
		<comments>http://btburnett.com/2008/03/using-transactions-with-datasets.html#comments</comments>
		<pubDate>Tue, 25 Mar 2008 08:42:00 +0000</pubDate>
		<dc:creator>Brant Burnett</dc:creator>
				<category><![CDATA[ADO.NET]]></category>

		<guid isPermaLink="false">http://www.btburnett.com/?p=4</guid>
		<description><![CDATA[One of the major shortcomings of the ADO.NET dataset system, in my opinion, is the lack of support for transactions. In .NET 2.0 this situation was somewhat addressed by the addition of the System.Transactions namespace. However, this namespace has two flaws when it comes to using it with a DataSet. First, if you open more [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:verdana;font-size:85%;">One of the major shortcomings of the ADO.NET dataset system, in my opinion, is the lack of support for transactions.  In .NET 2.0 this situation was somewhat addressed by the addition of the System.Transactions namespace.  However, this namespace has two flaws when it comes to using it with a DataSet.  First, if you open more than one database connection within the same TransactionScope, it will use the Distributed Transaction Coordinator (MSDTC) instead of more efficient and configuration free database transactions.  Second, if you require backwards compatibility with SQL 2000, it will ALWAYS use the MSDTC even if you open just a single database connection. The first issue can be addressed by opening the connection in advance and passing it to each TableAdapter that you use.  Note that you&#8217;ll need to change the Connection property on the TableAdapter from Friend (internal) to Public in the DataSet designer if the DataSet is in a DLL.</span><br /><span style="font-family:verdana;font-size:85%;"></span><br /><span style="font-family:verdana;font-size:85%;">The second issue is a bit trickier to solve.  In this case, you also need to open a single database connection as before, but then use an old fashioned SqlTransaction instead of the System.Transactions namespace.  Then both the SqlConnection and SqlTransaction need to be set on each TableAdapter.  This can be done by adding a special helper function to the partial class for the TableAdapter, as shown below.</span></p>
<p><span style="font-family:courier new;font-size:70%">Namespace DataSetTableAdapters</span><br /><span style="font-family:Courier New;font-size:70%;"></span><br /><span style="font-family:Courier New;font-size:70%;margin-left: 2em;">Partial Class TableAdapter</span><br /><span style="font-family:Courier New;font-size:70%;"></span><br /><span style="font-family:courier new;font-size:70%;margin-left: 4em;">Public Sub SetConnection(ByVal cn As SqlConnection, trans As SqlTransaction)</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">Connection = cn</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">For Each cmd As SqlCommand In Me.CommandCollection</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 8em;">cmd.Transaction = trans</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">Next</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">Adapter.UpdateCommand.Transaction = trans</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">Adapter.InsertCommand.Transaction = trans</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 6em;">Adapter.DeleteCommand.Transaction = trans</span><br /><span style="font-family:courier new;font-size:70%;margin-left: 4em;">End Sub</span><br /><span style="font-family:Courier New;font-size:70%;"></span><br /><span style="font-family:Courier New;font-size:70%;margin-left: 2em;">End Class</span><br /><span style="font-family:Courier New;font-size:70%;"></span><br /><span style="font-family:Courier New;font-size:70%;">End Namespace</span></p>
]]></content:encoded>
			<wfw:commentRss>http://btburnett.com/2008/03/using-transactions-with-datasets.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
