<?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>Geospecialling &#187; Development</title>
	<atom:link href="http://www.geospecialling.com/index.php/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geospecialling.com</link>
	<description>Being a (G)IS Developer...</description>
	<lastBuildDate>Thu, 26 Jan 2012 04:11:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Log4Net with Visual Lisp</title>
		<link>http://www.geospecialling.com/index.php/2012/01/using-log4net-with-visual-lisp/</link>
		<comments>http://www.geospecialling.com/index.php/2012/01/using-log4net-with-visual-lisp/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 19:07:35 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Log4Net]]></category>
		<category><![CDATA[ObjectARX.NET]]></category>
		<category><![CDATA[Visual Lisp]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2012/01/using-log4net-with-visual-lisp/</guid>
		<description><![CDATA[If you’ve worked with me or talked technical with me in the past there is a good chance you area already very aware that I love Log4Net.&#160; There is also a really good chance that you know I still have a special place in my heart for Visual Lisp.&#160; Not only did I spend what [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve worked with me or talked technical with me in the past there is a good chance you area already very aware that I love <a title="Log4Net for the awesome!" href="http://logging.apache.org/log4net/index.html" rel="tag" target="_blank">Log4Net</a>.&#160; There is also a really good chance that you know I still have a special place in my heart for <a title="Visual Lisp" href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=770237" rel="tag" target="_blank">Visual Lisp</a>.&#160; Not only did I spend what may have been the “best years of my life” buried in VLIDE (or hey, maybe all those 30+ hour days and passing out under my desk were the best years of my life? =)) , I still firmly believe that Lisp is one of the most effective way to bang out even a relatively complex operation in AutoCAD when it comes to data manipulation.&#160; ObjectARX (both original and .NET) is great – but the time and effort overhead is pretty high when you just need to bang out a quick routine.</p>
<h2>&lt;3 Visual Lisp</h2>
<p>Even the quick routines need a little error handling and logging can make a huge difference in documenting the results or diagnosing problems.&#160; Yes, Visual Lisp comes with file I/O calls and I’m sure most of you reading this have rolled your own logging code.&#160; We had some at Kanotech that is still in use for DraftLogic.&#160; Not for long though :=)&#160; Today I’m here to show you how you could bring your Visual Lisp logging into the 21st century.&#160; Not only will it give you <a title="Robust and configurable logging with Log4Net" href="http://logging.apache.org/log4net/release/config-examples.html" rel="tag" target="_blank">insanely robust and configurable logging</a> – it will let even complex systems that mix technologies (ie. Visual Lisp, ObjectARX .NET) to bring the logging together into a common set of log files.</p>
<h2>Overview</h2>
<p>There are two sides to this.&#160; First, in .NET we setup Log4Net and expose it to Visual Lisp.&#160; Over on the Lisp side, we’ll load the vlx, setup an error handler, and issue some logging calls.&#160; As usual I’ve attached a Visual Studio solution with sample code.&#160; I’ve also included a compiled dll that you can just go ahead and use.&#160; The attached project is built using .NET 3.5 as this machine only has AutoCAD 2010 installed.&#160; Log4Net itself is built targeting .NET 1.0 so you can modify the .NET runtimes and ObjectARX references used in the attached project and use this code for pretty much any .NET enabled version of AutoCAD/ObjectARX.</p>
<h2>In .NET – Setup Log4Net and Lisp Bindings</h2>
<p>The Lisp bindings are pretty straight forward.&#160; Expose your call(s) to AutoCAD as a LispFunction.&#160; I’ve built two exposed calls.&#160; One takes two parameters, and uses the value of the first parameter to determine the log type.&#160; The second parameter is the message to log.&#160; The second call is a LogError call that could be used to just log error type messages.&#160; This call could be duplicated for each type of logging state if desired.</p>
<div>&#160;</div>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #008000">/// Lisp exported Log call.  Expects two parameters in lisp.  First the log type which may be either INFO, WARNING, DEBUG, or ERROR.  The second is a string containing the error / message.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #008000">/// &lt;param name=&quot;lispArgs&quot;&gt;&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span> <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> <span style="color: #008000">/// &lt;remarks&gt;Lisp syntax (Loggit &lt;/remarks&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span> [LispFunction(<span style="color: #006080">&quot;Loggit&quot;</span>)]</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> <span style="color: #0000ff">public</span> TypedValue Log(ResultBuffer lispArgs)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>     <span style="color: #008000">//Check that we have the correct number of parameters</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     <span style="color: #0000ff">if</span> (lispArgs == <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>         ed.WriteMessage(<span style="color: #006080">&quot;\nLoggit - Incorrect number of arguments.  Expected 2 parameters, received none\n&quot;</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>     <span style="color: #0000ff">if</span> (lispArgs.AsArray().Length != 2)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span>         ed.WriteMessage(<span style="color: #006080">&quot;\nLoggit - Incorrect number of arguments.  Exepected 2 parameters, received &quot;</span> + Convert.ToString(lispArgs.AsArray().Length));</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>     </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>     <span style="color: #008000">//params are good.  We expect two strings so rather than test type just convert to string</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>     String logType = Convert.ToString(lispArgs.AsArray()[0].Value).ToUpper();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span>     String logMessage = Convert.ToString(lispArgs.AsArray()[1].Value);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span>     <span style="color: #0000ff">switch</span>(logType)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span>         <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;INFO&quot;</span>:</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span>             Logger.Current.Info(logMessage);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span>             <span style="color: #0000ff">break</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  32:</span>         <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;WARNING&quot;</span>:</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  33:</span>         Logger.Current.Warning(logMessage);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  34:</span>             <span style="color: #0000ff">break</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  35:</span>         <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;DEBUG&quot;</span>:</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  36:</span>         Logger.Current.Debug(logMessage);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  37:</span>             <span style="color: #0000ff">break</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  38:</span>         <span style="color: #0000ff">case</span> <span style="color: #006080">&quot;ERROR&quot;</span>:</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  39:</span>             Logger.Current.Error(logMessage);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  40:</span>             <span style="color: #0000ff">break</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  41:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  42:</span>     <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.T_atom);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  43:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  44:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  45:</span> <span style="color: #008000">//Alternately you could expose individual calls like LogError here.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  46:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  47:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  48:</span> <span style="color: #008000">/// Exposed Lisp function that logs an error directly. Expects a single lisp parameter of type string which is the message to log.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  49:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  50:</span> <span style="color: #008000">/// &lt;param name=&quot;lispArgs&quot;&gt;&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  51:</span> <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  52:</span> [LispFunction(<span style="color: #006080">&quot;LogError&quot;</span>)]</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  53:</span> <span style="color: #0000ff">public</span> TypedValue LogError(ResultBuffer lispArgs)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  54:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  55:</span>     <span style="color: #008000">//Check that we have the correct number of parameters</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  56:</span>     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  57:</span>     <span style="color: #0000ff">if</span> (lispArgs == <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  58:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  59:</span>         ed.WriteMessage(<span style="color: #006080">&quot;\nLoggit - Incorrect number of arguments.  Expected 2 parameters, received none\n&quot;</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  60:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  61:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  62:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  63:</span>     String logMessage = Convert.ToString(lispArgs.AsArray()[0].Value);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  64:</span>     Logger.Current.Error(logMessage);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  65:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  66:</span>     <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.T_atom);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  67:</span> }</pre>
</p></div>
</div>
<h2>&#160;</h2>
<p>One awesome little bit of magic exists in the Logger.cs class.&#160; When configuring the logger it loads the assemblies in question using System.Reflection.&#160; Then it checks in the folder of each loaded dll for the log4net.config file.&#160; This means that logging will only actually log if you have a log4net.config file exists in the same folder as the loaded ObjectARX.NET assembly.&#160; With AutoCAD based extensions this is especially important.&#160; I’ve never liked placing my assemblies (vlx, arx, dll) in the AutoCAD folders.&#160; I’ve always been a huge proponent of extending the AutoCAD search path if needed and using my own directory structures.&#160; This configuration searching technique also eliminates the need for hard coded “here is my log config file” stored in the registry or some other config location.&#160; </p>
<p>Compile that dll and you should be able to run with that in Visual Lisp.</p>
<h2>Configure the Logging</h2>
<p>As mentioned previously we need to create the configuration file to place with our dll.&#160; There are a couple of lines of code that are quite relevant to get the logging working.&#160; First we have a hard coded configuration file name defined in Logger.cs.&#160; You can customize this if you want.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #008000">/// Name of the file name to search for when trying to configure logging.</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">string</span> ConfigFileName = <span style="color: #006080">&quot;log4net.config&quot;</span>;</pre>
</p></div>
</div>
<p>Next is the name of the logger.&#160; This is quite relevant when configuring your logging.&#160; If this value does not match the value in the config file you will be very frustrated trying to get the logging to fire! If desired change the VisualLisp value to whatever you would like.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #008000">/// This logger name is referenced in the log4net configuration</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #0000ff">private</span> ILog _logImplementation = LogManager.GetLogger(<span style="color: #006080">&quot;VisualLisp&quot;</span>);</pre>
</p></div>
</div>
<p>Next we have a little bit of XML to slough through.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">=&quot;UTF-8&quot;</span>?<span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">log4net</span> <span style="color: #ff0000">xmlns</span><span style="color: #0000ff">=&quot;urn:log&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">appender</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;GeneralLog&quot;</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;log4net.Appender.FileAppender&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">file</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">=&quot;VisualLisp.log&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">appendToFile</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">=&quot;true&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">layout</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">=&quot;log4net.Layout.PatternLayout&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">conversionPattern</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">=&quot;%date [%thread] %-5level %logger [%property{NDC}] - %message%newline&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">layout</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">appender</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">logger</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;VisualLisp&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">level</span> <span style="color: #ff0000">value</span><span style="color: #0000ff">=&quot;ALL&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">appender-ref</span> <span style="color: #ff0000">ref</span><span style="color: #0000ff">=&quot;GeneralLog&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">logger</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">log4net</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>This is where things can get crazy!&#160; First the appender section.&#160; This is where you define all the different settings for the actual logging.&#160; I’m running with a standard log file appender, but there are so many choices.&#160; Log to file, log to rolling file, log to database, log to e-mail, log to eventlog, log to almost whatever you want.&#160; You can even write your own custom appenders to log to your toaster oven if you really wanted to.&#160; This is one of the many reasons I &lt;3 Log4Net soooo much.&#160;&#160; The basics here are straight forward.&#160; Set the file value=”” to the name and optionally path (either full or relative).&#160; One important note., if you do not specify a full path or you use a relative path the logfile the base point used will be the AutoCAD program files folder.&#160;&#160; If you are not running with administrative rights the Vista/Windows 7 file system virtualization will kick in and the log file location will be quite confusing.&#160; It’s probably a good idea to specify a full path here.&#160; More details on some Log4Net configurations can be found on the <a title="Log4Net configs" href="http://logging.apache.org/log4net/release/config-examples.html" rel="tag" target="_blank">Log4Net site</a>.</p>
<p>Next take a look at the logger element.&#160; You can define multiple loggers, and each can log to multiple appenders.&#160; Or a single logger can log to multiple appenders.&#160;&#160; Note the important value of “Visual Lisp”.&#160; This must match the GetLogger value defined in the private ILog above.&#160; You can also specify which “level” of notice to log.&#160; Though our code may log INFO, WARNING, DEBUG and ERROR calls – if your level is set to ERROR – only the actual error level messages will be logged.</p>
<h2>In Visual Lisp – Setup an Error Handler and Issue Logging </h2>
<p>So now we have an ObjectARX.NET assembly to load.&#160; We have a handle on configuring our logging.&#160; Here is the contents of the included Lisp file.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> ;only load the assembly <span style="color: #0000ff">if</span> it has not been loaded once</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> (<span style="color: #0000ff">if</span> (not (car (atoms-family 1 <span style="color: #006080">'(&quot;loggit&quot;))))</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     (command &quot;netload&quot; &quot;C:/Users/dmaidlow/Documents/Visual Studio 2010/Projects/Log4Net.VisualLisp/bin/debug/Log4Net.VisualLisp.dll&quot;)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> (defun new_ErrorHandler (err)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     (if (or (= (substr err 1 4) &quot;quit&quot;)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>             (= err &quot;Function cancelled&quot;)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span>         )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>         (progn</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>             ;put any function cancelled logic here</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>             (princ)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>         )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>         (progn</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>             ;an actual error happened here..</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>             ;you could spew some stuff out to the console, or issue an alert..</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>             ;(prompt (strcat &quot;\nLisp Returned the following error: \&quot;&quot; st &quot;\&quot;\n&quot;))</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>             ;(alert (strcat &quot;*ERROR*\nLisp returned the following error: \n\t&quot; st))</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>             ;but we'</span>re here to log!</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>             (Loggit <span style="color: #006080">&quot;ERROR&quot;</span> (strcat <span style="color: #006080">&quot;An error occurred\n&quot;</span> err))</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>             </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>         )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>     )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span>     (gc)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span>     (princ)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span> )</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span> (setq *error* new_ErrorHandler)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span> (LogError <span style="color: #006080">&quot;Oh No an Error!&quot;</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span> (Loggit <span style="color: #006080">&quot;INFO&quot;</span> <span style="color: #006080">&quot;This is an informational message&quot;</span>)</pre>
</p></div>
</div>
<p>Not much to it.&#160; To prevent some command line spewage if you load the assembly twice we check first to see if the function has already been exported to the environment.&#160; Here we’ve setup a new error handler that differentiates between a function cancellation and an actual error.&#160; At the bottom you can see a couple of examples of the logging.&#160; If you’ve defined your log4net.config file in the same folder as the assembly if you load this lisp file you will see a log file get created.</p>
<h2>Summary</h2>
<p>So in review – we’ve exposed Log4Net to the Visual Lisp and command line environment inside of AutoCAD.&#160; This will allow you to unify your logging (if you are already using Log4Net) and may even make you a Log4Net enthusiast as well.&#160; As always I’m always interested in your feedback and constructive criticism!</p>
<p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:9c1625b0-792e-4dd7-812d-3835aabd477f" class="wlWriterEditableSmartContent">
<p> <a href="http://www.geospecialling.com/wp-content/uploads/2012/01/Geospecialling.Log4Net.VisualLisp1.zip" target="_blank">Download the Visual Studio solution</a></p>
</div>
<p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d9a34082-84de-4056-8acd-de04abe1fd9f" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Log4Net" rel="tag">Log4Net</a>,<a href="http://technorati.com/tags/Visual+Lisp" rel="tag">Visual Lisp</a>,<a href="http://technorati.com/tags/ObjectARX.NET" rel="tag">ObjectARX.NET</a>,<a href="http://technorati.com/tags/AutoCAD+Customization" rel="tag">AutoCAD Customization</a>,<a href="http://technorati.com/tags/.NET" rel="tag">.NET</a></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2012/01/using-log4net-with-visual-lisp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OracleCommand and parameterized update statements</title>
		<link>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/</link>
		<comments>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 22:07:53 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[RADE]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ODP.NET]]></category>
		<category><![CDATA[Parameterized Queries]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/</guid>
		<description><![CDATA[This week I encountered an irritating situation with Oracle while working on code in the RADE application logic.&#160; In a nutshell I am building dynamically created parameterized insert and update statements based on the RADE metadata and the values entered by the user.&#160; The first call InsertNewRecord works perfectly.&#160; The next call UpdateExistingRecord however was [...]]]></description>
			<content:encoded><![CDATA[<p>This week I encountered an irritating situation with Oracle while working on code in the <a title="RADE" href="http://www.geospecialling.com/index.php/2008/06/rade-build-custom-web-applications-without-writing-custom-code/" rel="tag" target="_blank">RADE</a> application logic.&#160; In a nutshell I am building dynamically created parameterized insert and update statements based on the RADE metadata and the values entered by the user.&#160; The first call InsertNewRecord works perfectly.&#160; The next call UpdateExistingRecord however was not.&#160; The parameterized SQL was being created.&#160; The parameters were being created and assigned to the <a title="DbCommand" href="http://msdn.microsoft.com/en-us/library/system.data.common.dbcommand.aspx" rel="tag" target="_blank">DbCommand</a>.&#160; The ExecuteNonQuery() call was executing without returning an error.&#160; Oracle just would not update.&#160;&#160; Even more frustrating – this “just worked” in SQL server.</p>
<h2>What were the differences?</h2>
<p>The basic logic for insert was this (parts omitted because you probably just don’t care):</p>
<ol>
<li>Get table metadata </li>
<li>Loop through fields in table </li>
<li>for each field retrieve the value from the UI </li>
<li>Add field to parameterized SQL statement with placeholder </li>
<li>Create new parameter with appropriate name and value.&#160;&#160; Add parameter to collection </li>
<li>Loop through parameters in the collection and add to the DbCommand </li>
<li>Finally execute the parameterized SQL statement </li>
</ol>
<p>As I mentioned this worked great.&#160; Fields were inserted and there was much rejoicing.</p>
<p>The logic for an update was similar but there was one big difference:</p>
<ol>
<li>Get Table </li>
<li>Loop through fields in table </li>
<li>for each field retrieve the value from the UI </li>
<li>If the field is a key add the placeholder to the where condition, otherwise add the field name and value to the update fields part of the SQL </li>
<li>Create new parameter with appropriate name and value.&#160; Add parameter to collection </li>
<li>Loop through parameters in the collection and add to the DbCommand </li>
<li>Finally execute the parameterized SQL statement. </li>
</ol>
<p>The branch in step 4 and the if statement ended up causing the problem.</p>
<h2>The Problem</h2>
<p><a title="OracleCommand" href="http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oraclecommand(v=VS.100).aspx" rel="tag" target="_blank">OracleCommand</a> defaults to “bind by order” – making the order in which the parameters exist in the SQL statement match the order in which the parameters are added to the OracleCommand. This was happening during the insert because of the structure of an insert statement being so linear. However in the update statement I was building the SQL in a more dynamic way. I was maintaining a list field=value conditions and a separate where condition. In the ended up merging them :</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> String parameterizedSQL = <span style="color: #006080">&quot;UPDATE &quot;</span> + table.Name + <span style="color: #006080">&quot; SET &quot;</span> + updateStatement + <span style="color: #006080">&quot; WHERE &quot;</span> + whereStatement;</pre>
</p></div>
</div>
<p>So unless my key field( s) all lined up at the end of the table metadata definitions,&#160; appending that where condition at the end my parameter order got all out of whack in the DbCommand.&#160; So my where condition was actually being set to the wrong value – which could have resulted in the wrong records being updated. Nasty.&#160;&#160; Fortunately this can be resolved.</p>
<h2>The Fix – BindByName=true</h2>
<p>To correct this I had to set the Oracle specific BindByName property to true.&#160; (btw this being the default behavior is just silly.&#160; All the other big data providers default to bind by name and Oracle should too.&#160; That’s a rant for another day though.)&#160;&#160; My initial solution was to check if the command is an OracleCommand and if found do a little casting to set the BindByName property then recast it back to DbCommand before executing the query.&#160; Constructive feedback is always welcome!</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #008000">/// Execute the parameterized query</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> <span style="color: #008000">/// &lt;param name=&quot;conn&quot;&gt;open and active DbConnection&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span> <span style="color: #008000">/// &lt;param name=&quot;trans&quot;&gt;Active DbTransaction&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span> <span style="color: #008000">/// &lt;param name=&quot;parameterizedSQL&quot;&gt;the parameterized SQL&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span> <span style="color: #008000">/// &lt;param name=&quot;paramList&quot;&gt;List of OledDbParameter&lt;/param&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span> <span style="color: #008000">/// &lt;returns&gt;DataTable containing the results&lt;/returns&gt;</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> RunParameterizedInsertUpdate(DbConnection conn, DbTransaction trans, String parameterizedSQL, List&lt;DbParameter&gt; paramList)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>     <span style="color: #008000">//create the db command and set the parameterized SQL as a property</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     DbCommand command = conn.CreateCommand();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>     <span style="color: #0000ff">if</span>(trans != <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>         command.Transaction = trans;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>     <span style="color: #008000">//hack attack!  By default, Oracle requires its parameters to be placed into the command</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>     <span style="color: #008000">//in the order the parameters appear in the parameterized SQL.  Little hackery here</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span>     <span style="color: #008000">//to set the Oracle Command to bind by name</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>     <span style="color: #0000ff">if</span> (command <span style="color: #0000ff">is</span> Oracle.DataAccess.Client.OracleCommand)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>         OracleCommand oraCmd = (OracleCommand) command;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>         oraCmd.BindByName = <span style="color: #0000ff">true</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>         command = oraCmd;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span>     command.CommandText = parameterizedSQL;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span>     command.CommandType = CommandType.Text;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span>     <span style="color: #008000">//loop through the params and add them to the command</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span>     <span style="color: #0000ff">foreach</span> (DbParameter parameter <span style="color: #0000ff">in</span> paramList)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  32:</span>         command.Parameters.Add(parameter);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  33:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  34:</span>     <span style="color: #0000ff">try</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  35:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  36:</span>         command.Prepare();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  37:</span>         command.ExecuteNonQuery();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  38:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  39:</span>     <span style="color: #0000ff">catch</span> (Exception ex)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  40:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  41:</span>         command.Dispose();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  42:</span>         <span style="color: #0000ff">throw</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  43:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  44:</span> }</pre>
</p></div>
</div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:65e08d4f-940e-4b86-baf5-ae193e7dbe34" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Oracle.+ODP.NET" rel="tag">Oracle. ODP.NET</a>,<a href="http://technorati.com/tags/c%23" rel="tag">c#</a>,<a href="http://technorati.com/tags/parameterized+query" rel="tag">parameterized query</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/11/oraclecommand-and-parameterized-update-statements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing Question of the Week for ObjectARX.NET and Mapguide</title>
		<link>http://www.geospecialling.com/index.php/2011/11/introducing-question-of-the-week-for-objectarx-net-and-mapguide/</link>
		<comments>http://www.geospecialling.com/index.php/2011/11/introducing-question-of-the-week-for-objectarx-net-and-mapguide/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 05:32:30 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mapguide]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Mapguide Enterprise]]></category>
		<category><![CDATA[ObjectARX.NET]]></category>
		<category><![CDATA[QOTW]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/11/introducing-question-of-the-week-for-objectarx-net-and-mapguide/</guid>
		<description><![CDATA[Every good developer is constantly evolving and learning new technologies.&#160; This can be a challenge when you’re hard at work in maintenance mode on familiar technology or when your every day needs don’t go as deeply into topics as you would like.&#160; If you take a step back and look at AutoCAD and ObjectARX – [...]]]></description>
			<content:encoded><![CDATA[<p>Every good developer is constantly evolving and learning new technologies.&#160; This can be a challenge when you’re hard at work in maintenance mode on familiar technology or when your every day needs don’t go as deeply into topics as you would like.&#160; </p>
<p>If you take a step back and look at AutoCAD and <a title="ObjectARX" href="http://usa.autodesk.com/adsk/servlet/index?id=773204&amp;siteID=123112" rel="tag" target="_blank">ObjectARX</a> – its a huge body of work and it is a challenge to get experience in all the various parts of it.&#160; The recent request I received on how to <a title="Control AutoCAD ribbon from Visual Lisp" href="http://www.geospecialling.com/index.php/2011/10/control-active-autocad-ribbon-tab-from-visual-lisp-ribbonninja/" rel="tag" target="_blank">control the AutoCAD ribbon from Visual Lisp</a> or the command line and the subsequent research, code and blog post I wrote made me think,&#160; what if I solicited small problems from the AutoCAD community that could make fun little 4 hour research projects.&#160; These would allow me to dig into various portions of ObjectARX.NET once a week, write some fun code, and give me things to write about.&#160; Everybody wins!</p>
<p>I’m looking to spend about 4-6 hours on each question.&#160; I’m hoping to do one question per week, assuming I get enough requests.&#160; I’ll provide the full source and project with each post.&#160; All code will be written in c#.&#160; Some examples of valid requests would be:</p>
<ul>
<li>Submit a Visual Lisp routine to convert to ObjectARX.NET.</li>
<li>Request a particular routine that does some sort of drawing clean up or modifies something.</li>
<li>Identify some functionality that is missing in AutoCAD.</li>
<li>Request a piece of sample code explaining how to use API x of ObjectARX.NET or Mapguide Enterprise/Open Source.</li>
</ul>
<h2>The Do’s</h2>
<ul>
<li>Please keep your request realistic.&#160;&#160; I’ve only got 4 to 6 hours and you’re not paying me =)</li>
<li>Please submit specific functionality along with sample data.</li>
<li>Please be available to answer any questions&#160; I might have via e-mail, phone/skype or possibly gotomeeting.</li>
<li>Please keep the underlying technology somewhat current.&#160; Don’ t request AutoCAD/Mapguide 2007.</li>
<li>Please review my code and comment if you see something wrong or that I could do more efficiently.&#160; This is about me learning and I’m gonna make mistakes.</li>
</ul>
<h2>The Don&#8217;ts</h2>
<ul>
<li>Don’t expect days worth of work, I just don’t have that much spare time.</li>
<li>Don’t ask me to work on your project (unless of course you want to hire my team via <a title="ChasmTech Consuting Services" href="http://www.chasmtech.com/services/consulting" rel="tag" target="_blank">ChasmTech</a>).</li>
<li>Please don’t get upset if I don’t pick your question.</li>
<li>I did my ten odd years in the trenches writing Visual Lisp – I don’t really want to write any more, so please don’t ask for lisp code.</li>
<li>Don’t be a ass.&#160; I don’t have time for asses.</li>
</ul>
<h2>Let’s See What Happens</h2>
<p>So I have no idea how this will play out.&#160; I don’t know if 4-6 hours is a reasonable amount of time to allocate each week to do this right.&#160;&#160; I don’t know if I will be able to make the time every week.&#160; Maybe I’ll change it from “Question of the Week” to “Question of the Every Second Week”.&#160; I’m going to put this out there and see what happens.&#160;&#160; I reserve the right to change anything and everything! s&#160; E-mail your requests to contact ~@~ geospecialling dot com.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:317ea19e-9f67-4cf5-8050-e6e87582ce9e" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/ObjectARX.NET" rel="tag">ObjectARX.NET</a>,<a href="http://technorati.com/tags/Visual+Lisp" rel="tag">Visual Lisp</a>,<a href="http://technorati.com/tags/AutoCAD" rel="tag">AutoCAD</a>,<a href="http://technorati.com/tags/Mapguide" rel="tag">Mapguide</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/11/introducing-question-of-the-week-for-objectarx-net-and-mapguide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remotesoft Protector Runtime Error &#8211; yet to handle multiple .NET framework runtime</title>
		<link>http://www.geospecialling.com/index.php/2011/11/remotesoft-protector-runtime-error-yet-to-handle-multiple-net-framework-runtime/</link>
		<comments>http://www.geospecialling.com/index.php/2011/11/remotesoft-protector-runtime-error-yet-to-handle-multiple-net-framework-runtime/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 03:07:49 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code Protection]]></category>
		<category><![CDATA[Remotesoft Protector]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/11/remotesoft-protector-runtime-error-yet-to-handle-multiple-net-framework-runtime/</guid>
		<description><![CDATA[Remotesoft protector is one of the best code protection tools out there.&#160; In fact, its pretty much the only one that really works.&#160; Since I moved to .NET 4.0 I’ve been getting an annoying error when attempting to protect my binaries using the 4.0 suite of tools (with the updated protector runtime).&#160; Everything still runs [...]]]></description>
			<content:encoded><![CDATA[<p>Remotesoft protector is one of the <a title="Remotesoft protector" href="http://www.remotesoft.com/salamander/protector.html" rel="tag" target="_blank">best code protection tools</a> out there.&#160; In fact, its pretty much the only one that really works.&#160; Since I moved to .NET 4.0 I’ve been getting an annoying error when attempting to protect my binaries using the 4.0 suite of tools (with the <a title="updated protector runtime" href="http://www.remotesoft.com/salamander/download_protector/rscoree.zip" rel="tag" target="_blank">updated protector runtime</a>).&#160; Everything still runs – it just pops up nasty alert boxes on load which is no good <img src='http://www.geospecialling.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<blockquote><p>Remotesoft Protector Runtime Error &#8211; yet to handle multiple .NET framework runtime</p>
</blockquote>
<p>One other symptom of this was that .exe files would just blow chunks.&#160; I’ve finally figured out what was causing this!&#160; Most of our products are protected during the nightly builds.&#160; This error however is specific to assemblies protected using the the Remotesoft .NET Explorer UI.&#160; When using this application for the protect or obfuscate functionality it is really just a front end around the protector.exe/obfuscator.exe.&#160; The UI is building the following command line string and tonight it finally dawned on me:<a href="http://www.geospecialling.com/wp-content/uploads/2011/11/Remotesoft-.NET-Explorer.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Remotesoft .NET Explorer" border="0" alt="Remotesoft .NET Explorer" align="right" src="http://www.geospecialling.com/wp-content/uploads/2011/11/Remotesoft-.NET-Explorer_thumb.png" width="232" height="244" /></a></p>
<blockquote><p>Command: C:\Program Files (x86)\Remotesoft\Protector\bin\protector.exe -neutral -resource -string -cctor -clrversion v2.0.50727 &quot;C:\temp\SmartInk for Kahua\SmartInk.UI.exe&quot;</p>
</blockquote>
<p>The UI was forcing the clr version to .NET 2.0 – when my assemblies are all built against .NET 4.0.&#160; Oops…</p>
<p>After a bit of digging I found that you can set the CLR version in .NET Explorer from the Action / CLR Version menu item.&#160; Unfortunately it has not been updated to support .NET 4.0 – and so has been rendered pretty much useless as a front end for protector.</p>
<h2>The Fix</h2>
<p>The only solution is to use the command line to execute your protection.&#160;&#160; The updated command line ended up looking pretty similar:</p>
<blockquote><p>&quot;C:\Program Files (x86)\Remotesoft\Protector\bin\protector.exe&quot; -neutral -resource -string&#160; -clrversion v4.0.30319 &quot;C:\temp\SmartInk for Kahua\SmartInk.UI.exe&quot;</p>
</blockquote>
<p>There you have it – I can’t believe I missed that…</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:372d8d96-7723-4196-8917-b501d70c3e74" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Remotesoft+Protector" rel="tag">Remotesoft Protector</a>,<a href="http://technorati.com/tags/.NET" rel="tag">.NET</a>,<a href="http://technorati.com/tags/Code+Protection" rel="tag">Code Protection</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/11/remotesoft-protector-runtime-error-yet-to-handle-multiple-net-framework-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Control Active AutoCAD Ribbon Tab from Visual Lisp &#8211; RibbonNinja!</title>
		<link>http://www.geospecialling.com/index.php/2011/10/control-active-autocad-ribbon-tab-from-visual-lisp-ribbonninja/</link>
		<comments>http://www.geospecialling.com/index.php/2011/10/control-active-autocad-ribbon-tab-from-visual-lisp-ribbonninja/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 23:18:07 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Ninjas]]></category>
		<category><![CDATA[ObjectARX.NET]]></category>
		<category><![CDATA[Ribbon]]></category>
		<category><![CDATA[Visual Lisp]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/10/control-active-autocad-ribbon-tab-from-visual-lisp-ribbonninja/</guid>
		<description><![CDATA[A friend asked me recently if there was some way to control the active AutoCAD ribbon tab from a macro.&#160; After a little bit of digging I could not find any lisp or command line command that would do this.&#160; ObjectARX however does provide the functionality I needed so I decided to whip something together [...]]]></description>
			<content:encoded><![CDATA[<p>A friend asked me recently if there was some way to control the active <a title="http://usa.autodesk.com/autocad/" href="http://usa.autodesk.com/autocad/" rel="tag" target="_blank">AutoCAD</a> ribbon tab from a macro.&#160; After a little bit of digging I could not find any lisp or command line command that would do this.&#160; ObjectARX however does provide the functionality I needed so I decided to whip something together in c#.&#160; I’ve named it RibbonNinja – because lets face it, ninjas are awesome and should play a much larger part of everyday life.</p>
<h2>How’s it work?</h2>
<p>Attached is a zip file that contains the dll.&#160; To use this simply netload the dll into your AutoCAD session and issue the all powerful RibbonNinja lisp call.&#160; It takes a single string parameter that is the name of the tab you want to activate.&#160; If it finds and activates the tab it will return T, if not it returns nil.&#160; For example given the following AutoCAD ribbon:</p>
<p><a href="http://www.geospecialling.com/wp-content/uploads/2011/10/mapribbon.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="mapribbon" border="0" alt="mapribbon" src="http://www.geospecialling.com/wp-content/uploads/2011/10/mapribbon_thumb.png" width="644" height="107" /></a></p>
<p>Issuing the following lisp statement will change the active tab from “Map Setup” to “Analyze”.&#160; Then it would switch to “Home&quot;</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> (RibbonNinja “Analyze”)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> (RibbonNinja “Home”)</pre>
</p></div>
</div>
<p>This code is not case sensitive.&#160; If its even possible to have multiple menus within AutoCAD with the same spelling but in different cases you’re probably S.O.L. and it will always choose the last one.&#160; I’ve assumed unique tab names.</p>
<p>This dll has been compiled to work against AutoCAD 2012.&#160; It will support both x86 and x64 versions.&#160; It should also work on any AutoCAD vertical (i.e AutoCAD Map, Civil, ADT etc etc).&#160; If you get the following&#160; error when you try to netload the dll we have one last change to make:</p>
<blockquote>
<p><em>Cannot load assembly. Error details: System.IO.FileLoadException: Could not load file or assembly &#8216;file:///C:\Program Files\Autodesk\AutoCAD 2012 – English\RibbonNinja.dll&#8217; or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0&#215;80131515) File name: &#8216;file:/// C:\Program Files\Autodesk\AutoCAD 2012 – English\RibbonNinjadll &#8216; &#8212;&gt; System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.</em></p>
</blockquote>
<p>Please read and try the following posts.&#160; .NET 4.0 is “protecting” us so we need to fix that.&#160; First you can try and “unblock” the dll following the steps outlined on <a title="Unblock dlls to prevent error loading on netload" href="http://labs.blogs.com/its_alive_in_the_lab/2011/05/unblock-net.html" rel="tag" target="_blank">Scott Sheppard’s blog</a>.&#160; If that doesn’t work for you again shut down AutoCAD and edit your acad.exe.config file as explained by Kean Walmsley on <a title="edit AutoCAD config to load downloaded dlls" href="http://through-the-interface.typepad.com/through_the_interface/2011/07/loading-blocked-and-network-hosted-assemblies-with-net-4.html" rel="tag" target="_blank">Through the Interface</a>.&#160; Remember to run notepad or whatever editor you’re using as an administrator – or you will get permission errors when you try to save the config file.</p>
<h2>Turn up the nerd</h2>
<p>For those of you more technically inclined the source is pretty simple once you figure out the mess of&#160; references that are needed:</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> [LispFunction(<span style="color: #006080">&quot;RibbonNinja&quot;</span>)]</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span> <span style="color: #0000ff">public</span> TypedValue GoNinjaGoNinjaGo(ResultBuffer lispArgs)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span>     <span style="color: #008000">//check the params</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   5:</span>     Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">if</span> (lispArgs == <span style="color: #0000ff">null</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   7:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   8:</span>         ed.WriteMessage(<span style="color: #006080">&quot;\nIncorrect number of arguments.  Expected 1 parameter, received none\n&quot;</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  10:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  11:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  12:</span>     <span style="color: #0000ff">if</span>(lispArgs.AsArray().Length != 1)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  13:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  14:</span>         ed.WriteMessage(<span style="color: #006080">&quot;\nRibbonNinja - Incorrect number of arguments.  Expected String - tab keyboard shortcut\n&quot;</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  15:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  16:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  17:</span>     <span style="color: #008000">//get the tab name</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  18:</span>     String tabKey = Convert.ToString(lispArgs.AsArray()[0].Value);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  19:</span>&#160; </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  20:</span>     <span style="color: #008000">//get the ribbon</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  21:</span>     Autodesk.Windows.RibbonControl ribCntrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  22:</span>     </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  23:</span>     <span style="color: #008000">//find the custom tab using the Id</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  24:</span>     <span style="color: #0000ff">foreach</span> (RibbonTab tab <span style="color: #0000ff">in</span> ribCntrl.Tabs)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  25:</span>     {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  26:</span>         <span style="color: #008000">//is this the one we're looking for?</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  27:</span>         <span style="color: #0000ff">if</span>(tab.AutomationName.ToUpper() == tabKey.ToUpper())</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  28:</span>         {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  29:</span>             <span style="color: #008000">//yup - get it active and bail. weeeeee</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  30:</span>             tab.IsActive = <span style="color: #0000ff">true</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  31:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.T_atom);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  32:</span>         }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  33:</span>     }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  34:</span>     <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> TypedValue((<span style="color: #0000ff">int</span>)LispDataType.Nil);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">  35:</span> }</pre>
</p></div>
</div>
<p>Thanks for the challenge <a title="https://plus.google.com/u/0/115187156780570046715/posts" href="https://plus.google.com/u/0/115187156780570046715/posts" target="_blank">Shawn</a>!&#160; Here is your shiny new </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:77ce2ccf-4665-421a-ac2e-4c1c21d24c4b" class="wlWriterEditableSmartContent">
<p> <a href="http://www.geospecialling.com/wp-content/uploads/2011/10/RibbonNinja3.zip" target="_blank">RibbonNinja DLL</a></p>
</div>
<p>.&#160; Feel free to use this commercially – I always appreciate links to my posts in exchange&#160; =) </p>
<p>p.s. Two posts in two days.&#160; that’s crazy talk I tell ya!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b2a16783-b26e-44d7-b233-5be350d07e6f" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/AutoCAD" rel="tag">AutoCAD</a>,<a href="http://technorati.com/tags/ObjectARX.NET" rel="tag">ObjectARX.NET</a>,<a href="http://technorati.com/tags/AutoCAD+Customization" rel="tag">AutoCAD Customization</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/10/control-active-autocad-ribbon-tab-from-visual-lisp-ribbonninja/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hacking Visual Lisp IDE to be a little more awesome!</title>
		<link>http://www.geospecialling.com/index.php/2011/08/hacking-visual-lisp-ide-to-be-a-little-more-awesome/</link>
		<comments>http://www.geospecialling.com/index.php/2011/08/hacking-visual-lisp-ide-to-be-a-little-more-awesome/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 17:12:51 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visual Lisp]]></category>
		<category><![CDATA[VLIDE]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/08/hacking-visual-lisp-ide-to-be-a-little-more-awesome/</guid>
		<description><![CDATA[Even though it’s the year 2011 and ObjectARX is available in all its glory for .NET I still spend a lot of time in the Visual Lisp IDE (VLIDE).&#160;&#160; While ObjectARX is powerful and full of awesome, it comes at a cost of a lot of overhead to setup a project, add all the needed [...]]]></description>
			<content:encoded><![CDATA[<p>Even though it’s the year 2011 and <a title="ObjecARX" href="http://usa.autodesk.com/adsk/servlet/index?id=773204&amp;siteID=123112" rel="tag" target="_blank">ObjectARX</a> is available in all its glory for .NET I still spend a lot of time in the <a title="Visual Lisp" href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=770237" rel="tag" target="_blank">Visual Lisp</a> IDE (VLIDE).&#160;&#160; While ObjectARX is powerful and full of awesome, it comes at a cost of a lot of overhead to setup a project, add all the needed references, heck even compiling / debugging is a huge pain in the ass in comparison to Lisp.&#160; Lisp is still hands down the most efficient way to do most batch modifications within an AutoCAD session for those who have made the time to learn it.<a href="http://www.geospecialling.com/wp-content/uploads/2011/08/lispide.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="lispide" border="0" alt="lispide" align="right" src="http://www.geospecialling.com/wp-content/uploads/2011/08/lispide_thumb.png" width="244" height="154" /></a></p>
<p>There are a couple of problems with Visual Lisp right now though.&#160; One of my biggest complaints about the VLIDE is the default colors.&#160; The high contrast white background is an eye killer.&#160;&#160; The IDE is configurable though and we’re given full a 16 bit color palette – with which I was able to configure a color scheme that was more to my liking.&#160;&#160; If you start Visual Lisp, go to the Tools menu and choose Window Attributes you are presented with the dialog that should let you configure your colors.&#160;&#160; Before opening this configuration dialog select a code window in Visual Lisp to modify. Set the properties accordingly. If you are happy with the colors when you press Ok on the dialog you will be prompted to “Use current as EDITOR prototype?”. Clicking yes here will update you editor prototype, resulting in future windows using these defaults.</p>
<p>One key limitation here is that on x64 editions of AutoCAD this dialog is broken.&#160; You may also see the following error when you attempt to close the dialog:</p>
<blockquote><p>; warning: unwind skipped on exception      <br />; error: Exception occurred: 0xC0000094</p>
</blockquote>
<p>It seems that Autodesk has let this code go to some extent. I’ve seen a number of <a title="Visual Lisp IDE error" href="http://forums.autodesk.com/t5/AutoCAD-Civil-3D/Problem-IDE-Editor-Visual-Lisp-in-Civil-2011-2012-x64-in-Windows/td-p/3091434" rel="tag" target="_blank">forum posts</a> of&#160; people mentioning the unwind error.&#160; This is a shame and partly why I’m writing this post!&#160; First off – if you have an x86 release of AutoCAD you are in luck.&#160; You can configure your IDE no problem using the UI.&#160; For you x64 users, all is not lost.&#160; Lucky for us Visual Lisp saves all this configuration information to a text file named VLIDE.dsk.&#160; On my Vista x64 machine its found in the following locations:</p>
<p>AutoCAD 2006 &#8211; C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2006\R16.2\enu</p>
<p>AutoCAD 2009 &#8211; C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2009\R17.2\enu</p>
<p>AutoCAD 2010 &#8211; C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2010\R18.0\enu</p>
<p>AutoCAD 2011 &#8211; C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2011\R18.1\enu</p>
<p>AutoCAD 2012 &#8211; C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2012 &#8211; English\R18.2\enu</p>
<p>These paths should be the same or similar on Windows 7.</p>
<p>If you open up this file you’ll see a large list of dotted pair lists full of settings.&#160; The one I’m most interested in here is the *editor-sample-window property.&#160; This is the “default” configuration to use when opening a lisp file.</p>
<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> (*editor-sample-window* (:AUTOLISP :FGC 16777215 :BGC 0 :LXC T :CLV #40(nil nil 16711935 nil nil nil 16776960 nil 32768 nil 32768 nil 8421376 nil 8388736 12632256 8388736 12632256 8388736 12632256 255 nil 128 nil 8388608 nil 128 nil 12632256 nil 16777215 0 16777215 16750899 16777215 255 nil 8388608 nil 16776960) :TW 4 :LM 10))</pre>
</p></div>
</div>
<p>Two values of importance are FGC (foreground color) and BGC (background color).&#160; I was having a hard time finding a color wheel that did integer based color codes – but you can convert your favorite hex color codes to decimal (<a title="hex to decimal" href="http://easycalculation.com/decimal-converter.php" rel="tag" target="_blank">helpful hex to decimal converter here</a>).&#160; The next bit is a little ugly.&#160; Within the :CLV property we have a list.&#160; This list is basically a list of 16 bit integers containing a color code of the foreground and background color of each window property.&#160; If the color is set to nil – it is transparent.&#160; This list appears to be in the order in which the properties are displayed within the UI:</p>
<ul>
<li>:LEX-SPACE </li>
<li>:LEX-STR </li>
<li>:LEX-SYM </li>
<li>:LEX-NUM </li>
<li>:LEX-INT </li>
<li>:LEX-REAL </li>
<li>:LEX-COMM </li>
<li>:LEX-COMM1 </li>
<li>:LEX-COMM2 </li>
<li>:LEX-PAREN </li>
<li>:LEX-SPEC </li>
<li>:LEX-SPEC1 </li>
<li>:LEX-UNKN </li>
<li>:WINDOW-TEXT </li>
<li>:WINDOW-SELECTION </li>
<li>:ERROR-HIGHLIGHT </li>
<li>:INPUT-ZONE </li>
<li>:CONSOLE-MESSAGE </li>
</ul>
<p>TW and LM contain the tab width and left margin respectively.&#160; So go wild editing these values and configure your new IDE!&#160; Keep in mind when editing the Visual Lisp settings using the UI, the vlide.dsk file is not saved&#160; until AutoCAD is shutdown cleanly.&#160; If AutoCAD crashes, you will lose your configuration.&#160; If you would like to try out my IDE settings – I’ve attached a zip file containing&#160; a copy of my .DSK file.&#160; I also recommend you make a backup of the .dsk file before you start tinkering.</p>
<p>Now, if only I could figure out some way to build a vlx file from the command line so as to integrate it into my automated build system..</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:018ccf01-e62e-4952-8ac4-a3c942c5378e" class="wlWriterSmartContent">
<p><a href="http://www.geospecialling.com/wp-content/uploads/2011/10/VLIDE.zip" target="_blank">my VLIDE.DSK file</a></p>
</div>
<p><strong>Update!</strong></p>
<p>For those of you who don’t read the comments &#8211; Dennis Hill was cool enough to share his digging into the DSK file and also his IDE colors which I’ve been running for a week or so now.&#160; Take a minute to read the comments and check out his color scheme.&#160; Thanks Dennis!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6deb737d-1817-4743-82ee-46c3b2beded3" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Visual+Lisp" rel="tag">Visual Lisp</a>,<a href="http://technorati.com/tags/VLIDE" rel="tag">VLIDE</a>,<a href="http://technorati.com/tags/Hack" rel="tag">Hack</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/08/hacking-visual-lisp-ide-to-be-a-little-more-awesome/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Debugging COM DLL files in AutoCAD x64 and Visual Studio</title>
		<link>http://www.geospecialling.com/index.php/2011/03/debugging-com-dll-files-in-autocad-x64-and-visual-studio/</link>
		<comments>http://www.geospecialling.com/index.php/2011/03/debugging-com-dll-files-in-autocad-x64-and-visual-studio/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 18:19:46 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Visual Lisp]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/03/debugging-com-dll-files-in-autocad-x64-and-visual-studio/</guid>
		<description><![CDATA[While attempting to work out some x64 specific kinks in some of the DraftLogic COM code that is being migrated to .NET I hit a pretty annoying wall.&#160; Well, it was actually a series of small walls (probably around knee high)&#160; that kept tripping me… In this post, I’m working on a problem that is [...]]]></description>
			<content:encoded><![CDATA[<p>While attempting to work out some x64 specific kinks in some of the <a title="DraftLogic" href="http://www.draftlogic.com" rel="tag" target="_blank">DraftLogic</a> COM code that is being migrated to .NET I hit a pretty annoying wall.&#160; Well, it was actually a series of small walls (probably around knee high)&#160; that kept tripping me…</p>
<p>In this post, I’m working on a problem that is pertaining to a 64 bit version of AutoCAD loading a COM enabled .NET assembly – however this information should apply to any x64 executable calling any x64 COM assembly.&#160;&#160; Replace AutoCAD with &lt;YourApp.exe&gt; and you should be good to go =)</p>
<p>The first thing I did was to ensure each of the projects had been set to build for&#160; “ANY CPU”.&#160;&#160; This got the ball of fun rolling.&#160;&#160; We have a VLX which instantiates the COM class using vlax-get-or-create-object.&#160; When called this would constantly return nil.&#160;&#160; Of course this all works just peachy when running an x86 build of AutoCAD.&#160;&#160; At this point my breakpoints would appear in Visual Studio as disabled and would happily inform me that “The breakpoint will not currently be hit”. </p>
<p>This usually results when the incorrect DLL is being loaded, or when the PDB file is missing.&#160;&#160; Once Visual Studio is running in debug mode you can bring up the Modules window from the Debug/Windows/Modules menu.&#160; This should show you all the assemblies involved in the current session as well a bunch of other information including their paths.&#160; The assembly in question was not listed here – so at this point I’m assuming that Windows cannot find the dll.</p>
<h2>Junk in the Registry</h2>
<p>I am now thinking that I have orphaned and duplicated types and CLSIDs in the registry, likely pointing to other builds of the dlls.&#160;&#160; If the GUIDs for the classes or types changed you end up with a lot of junk in the registry.&#160;&#160; I don’t trust those registry “cleaner” apps and in the interest of keeping my OS working – I chose to manually search out and nuke all the registry references manually.&#160; This can be done by searching both for your assembly’s type name, and COM exposed class names in regedit.&#160; A lot of this was done in the HKEY_CLASSES_ROOT root.&#160; After all of that the problem still exists..</p>
<h2>Wow6432Node Registry Keys</h2>
<p>Registry keys were a two part problem. After dealing with the junk in the registry, I found I also had to deal with the x86 <a title="x86 registry redirection" href="http://msdn.microsoft.com/en-us/library/aa384232(v=vs.85).aspx" rel="tag" target="_blank">registry redirection</a>.&#160;&#160; DraftLogic has been until this point limited to x86 architecture as a result of&#160; the VB6 code not being x64 friendly.&#160;&#160; As a result of this, all of the needed keys had been placed in the WOW6432Node of the appropriate software registry sections.&#160;&#160; This was the easiest wall to find and hop over.&#160; Unfortunately, this also didn’t solve the problem.</p>
<h2>Improperly Registered Assemblies-thanks for nothingVisual Studio</h2>
<p>So the next and fortunately final problem turns out that Visual Studio 2005/2008 (unsure about 2010) <a title="KB956933 COM assemblies in x64" href="http://support.microsoft.com/kb/956933" rel="tag" target="_blank">does not properly register assemblies.</a>&#160; Turns out the last piece of the solution is pretty simple – couple changes to the project.&#160; What’s happening is that Visual Studio is running the x86 build of regasm.exe to register the assemblies on run, probably because Visual Studio is an x86 app itself.&#160; This results in all kinds of x64 hating… To solve this we have to change two things in the COM enabled projects. </p>
<p>First though, I created a new build configuration called x64 so these changes would not affect in my ANY CPU configuration – which will be used to build my shipping assemblies.&#160; It is also important to note that this problem is MOSTLY only a problem when running code from the IDE.&#160; Assemblies installed and registered using an installer should not have this problem if the installer takes into consideration the “bitness” of AutoCAD (or any application calling your COM enabled dll).&#160; ie.&#160; Installshield asks the user on install what “bitness” of AutoCAD they are using, and the assemblies are registered as needed.&#160; It may also be possible to register an assembly using both the 32 and 64 bit versions of regasm – but I have not tried this.</p>
<p>So with the new x64 configuration created I edited the properties of each COM enabled project&#160; I unchecked “Register for COM interop” and added a post-build event command line of:</p>
<p>%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm $(TargetPath) /register /codebase /tlb</p>
<p>This would ensure that my COM enabled assemblies were properly registered for use by 64 bit&#160; applications.</p>
<p>After all that, my breakpoints were finally hit, and I could actually start working out the x64 specific bugs. Too bad we couldn’t have moved this to ObjectARX.NET instead – then this would have been a non-issue =)&#160; In retrospect, each of these problems were a contributing factor and each needed to be resolved.&#160; </p>
<p>Hopefully if you are facing a similar issue this post helps you get over at least a couple of the walls!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5798ded2-acee-42cc-a8d5-8b32f9864e3b" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Visual+Lisp" rel="tag">Visual Lisp</a>,<a href="http://technorati.com/tags/AutoCAD" rel="tag">AutoCAD</a>,<a href="http://technorati.com/tags/COM" rel="tag">COM</a>,<a href="http://technorati.com/tags/x64" rel="tag">x64</a>,<a href="http://technorati.com/tags/Visual+Studio" rel="tag">Visual Studio</a>,<a href="http://technorati.com/tags/COM%2b" rel="tag">COM+</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/03/debugging-com-dll-files-in-autocad-x64-and-visual-studio/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ReSharper 6 is going to be rad!</title>
		<link>http://www.geospecialling.com/index.php/2011/03/resharper-6-is-going-to-be-rad/</link>
		<comments>http://www.geospecialling.com/index.php/2011/03/resharper-6-is-going-to-be-rad/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 20:38:38 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/03/resharper-6-is-going-to-be-rad/</guid>
		<description><![CDATA[Finally had a little time to catch up on the internets today and came across this post on ReSharper 6 bundling a decompiler!&#160;&#160; My curiosity had been piqued by a little tease posted by JetBrains shortlt after the&#160; announcement by Red Gate about reflector and the subsequent firestorm in the .NET community that ensued that [...]]]></description>
			<content:encoded><![CDATA[<p>Finally had a little time to catch up on the internets today and came across this <a title="ReSharper 6 with built in decompiler!" href="http://blogs.jetbrains.com/dotnet/2011/02/resharper-6-bundles-decompiler-free-standalone-tool-to-follow/" rel="tag" target="_blank">post on ReSharper 6</a> bundling a decompiler!&#160;&#160; My curiosity had been piqued by a <a title="ReSharper Tease" href="http://blogs.jetbrains.com/dotnet/2011/02/reflections-on-recent-news/" rel="tag" target="_blank">little tease</a> posted by JetBrains shortlt after the&#160; <a title="red gate makes an oops" href="http://www.red-gate.com/products/dotnet-development/reflector/announcement" rel="tag" target="_blank">announcement by Red Gate</a> about reflector and the subsequent firestorm in the .NET community that ensued that announcement.</p>
<p>The timing is perfect.&#160; We’ve got a growing need to better understand how some of our code is interacting with some vendor provided 3rd party libraries and this is making a huge difference.&#160;&#160; In true ReSharper form – this new functionality looks solid, and easy to use.&#160; The ReSharper navigation tools we’ve all grown love (well maybe not just love, but also&#160; to depend on) are available.&#160;&#160; I’m not going to miss trying to navigate code only to be greeted with an Object Browser window. ..</p>
<p>Looks like a standalone decompiler/browser is also coming too…</p>
<blockquote><p>And by saying “free”, we actually mean “free”.</p>
</blockquote>
<p>Love it!&#160; Keep up the great works JetBrains – looking forward to the release!</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2b7b90f0-bed3-424f-bd1d-a0936ab34258" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/ReSharper" rel="tag">ReSharper</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/03/resharper-6-is-going-to-be-rad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoCAD VBA/VB6 to .NET Similar Function Comparison</title>
		<link>http://www.geospecialling.com/index.php/2011/02/autocad-vbavb6-to-net-similar-function-comparison/</link>
		<comments>http://www.geospecialling.com/index.php/2011/02/autocad-vbavb6-to-net-similar-function-comparison/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 17:53:58 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[ObjectARX.NET]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/02/autocad-vbavb6-to-net-similar-function-comparison/</guid>
		<description><![CDATA[I’ve been working on supporting the team doing the DraftLogic VB6 code migration to .NET the past few weeks.&#160;&#160; This code is many years worth of COM based AutoCAD development.&#160;&#160; Came across this excellent link that will give you a good head start in the right direction on which functions are the new equivalents in [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working on supporting the team doing the <a title="draftlogic" href="http://www.draftlogic.com" rel="tag" target="_blank">DraftLogic</a> VB6 code migration to .NET the past few weeks.&#160;&#160; This code is many years worth of COM based AutoCAD development.&#160;&#160; Came across this <a title="VBA to VB.NET and C# Comparison" href="http://tinyurl.com/5wddgh4" rel="tag" target="_blank">excellent link</a> that will give you a good head start in the right direction on which functions are the new equivalents in .NET of the old VBA/COM&#160; calls.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:21a45279-1e73-45e1-8445-3eb093f7127e" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/AutoCAD.+ObjectARX" rel="tag">AutoCAD. ObjectARX</a>,<a href="http://technorati.com/tags/VBA" rel="tag">VBA</a>,<a href="http://technorati.com/tags/COM%2b" rel="tag">COM+</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/02/autocad-vbavb6-to-net-similar-function-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Visual Lisp and ObjectARX.NET Together</title>
		<link>http://www.geospecialling.com/index.php/2011/02/debugging-visual-lisp-and-objectarx-net-together/</link>
		<comments>http://www.geospecialling.com/index.php/2011/02/debugging-visual-lisp-and-objectarx-net-together/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 18:22:40 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[LoaderLock]]></category>
		<category><![CDATA[ObjectARX.NET]]></category>
		<category><![CDATA[Visual Lisp]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/02/debugging-visual-lisp-and-objectarx-net-together/</guid>
		<description><![CDATA[I encountered the following error when trying to debug a new ObjectARX .NET assembly using Visual Lisp. Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang. This error would occur 95% of the time [...]]]></description>
			<content:encoded><![CDATA[<p>I encountered the following error when trying to debug a new ObjectARX .NET assembly using <a title="Visual Lisp" href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;id=770237" rel="tag" target="_blank">Visual Lisp.</a><a href="http://www.geospecialling.com/wp-content/uploads/2011/02/loaderlockwasdetected.png"><img style="border-right-width: 0px; margin: 20px 0px 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loaderlockwasdetected" border="0" alt="loaderlockwasdetected" align="right" src="http://www.geospecialling.com/wp-content/uploads/2011/02/loaderlockwasdetected_thumb.png" width="244" height="153" /></a></p>
<blockquote><p>Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.</p>
</blockquote>
<p>This error would occur 95% of the time and pretty much took out AutoCAD each time it happened.&#160; Fortunately this can be disabled <a href="http://www.geospecialling.com/wp-content/uploads/2011/02/manageddebuggingeceptions.png"><img style="border-right-width: 0px; margin: 25px 0px 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="manageddebuggingeceptions" border="0" alt="manageddebuggingeceptions" align="right" src="http://www.geospecialling.com/wp-content/uploads/2011/02/manageddebuggingeceptions_thumb.png" width="244" height="125" /></a>pretty easily within Visual Studio (I’ve tried both VS 2008 and VS 2010).&#160;&#160; In Visual Studio bring up the exceptions dialog from the Debug / Exceptions menu (or via the keyboard shortcut Cntrl D+E).&#160; </p>
<p>Expand the “Managed Debugging Exceptions” section and uncheck “LoaderLock” in the “Thrown” column.&#160; Next time you start AutoCAD from Visual Studio and load Visual Lisp you should no longer get this exception and you should be merrily debugging away.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9d64e73b-d68e-40ee-a1ff-dcba31da40f1" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/ObjectARX.Net" rel="tag">ObjectARX.Net</a>,<a href="http://technorati.com/tags/Visual+Lisp" rel="tag">Visual Lisp</a>,<a href="http://technorati.com/tags/Visual+Studio" rel="tag">Visual Studio</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/02/debugging-visual-lisp-and-objectarx-net-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Too many languages &#8211; they&#8217;re melding together into one..</title>
		<link>http://www.geospecialling.com/index.php/2011/02/too-many-languages-theyre-melding-together-into-one/</link>
		<comments>http://www.geospecialling.com/index.php/2011/02/too-many-languages-theyre-melding-together-into-one/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 06:40:17 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AutoLisp]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2011/02/too-many-languages-theyre-melding-together-into-one/</guid>
		<description><![CDATA[1: (if (== (db_checktrouble) 1) 2: (princ &#34;db_Checktrouble returned correct value&#34;) 3: (alert &#34;db_checktrouble returned wrong value&#34;) 4: ) Writing lisp based unit tests for ObjectARX code written in C# and its all melting together into one….Could this be a new Super Language…..nah…..]]></description>
			<content:encoded><![CDATA[<div>
<div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> (<span style="color: #0000ff">if</span> (== (db_checktrouble) 1)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   2:</span>     (princ <span style="color: #006080">&quot;db_Checktrouble returned correct value&quot;</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   3:</span>     (alert <span style="color: #006080">&quot;db_checktrouble returned wrong value&quot;</span>)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   4:</span> )</pre>
</p></div>
</div>
<p>Writing lisp based unit tests for ObjectARX code written in C# and its all melting together into one….Could this be a new Super Language…..nah…..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2011/02/too-many-languages-theyre-melding-together-into-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ERROR: Unable to update the dependencies of the project</title>
		<link>http://www.geospecialling.com/index.php/2010/11/error-unable-to-update-the-dependencies-of-the-project/</link>
		<comments>http://www.geospecialling.com/index.php/2010/11/error-unable-to-update-the-dependencies-of-the-project/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 05:22:08 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Installer]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/11/error-unable-to-update-the-dependencies-of-the-project/</guid>
		<description><![CDATA[Working on the automated build process for FullCircle SmartForms tonight and I came across an irritating problem tonight: &#34;ERROR: Unable to update the dependencies of the project. The dependencies for the object &#8216;NHibernate.Validator.DLL&#8217; cannot be determined.&#34; One of my three Visual Studio 2010 installer projects started failing during the automated build process with this error [...]]]></description>
			<content:encoded><![CDATA[<p>Working on the automated build process for FullCircle SmartForms tonight and I came across an irritating problem tonight:</p>
<blockquote><p><b>&quot;ERROR: Unable to update the dependencies of the project. The dependencies for the object &#8216;NHibernate.Validator.DLL&#8217; cannot be determined.&quot;</b></p>
</blockquote>
<p>One of my three Visual Studio 2010 installer projects started failing during the automated build process with this error on a dozen included assemblies.&#160; When the project was built using the Visual Studio IDE the installer would build just fine.&#160; With a little bit of digging and a great deal of screwing around, I found a <a title="Microsoft Knowledge Base" href="http://support.microsoft.com/kb/2286556" rel="tag" target="_blank">Microsoft KB article</a> and <a title="el hotfixo for &quot;Unable to update the dependancies of the project" href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30681" rel="tag" target="_blank">hotfix</a> for this problem.</p>
<p>After installing the patch – my automated build system is happily compiling the installation project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/11/error-unable-to-update-the-dependencies-of-the-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating .NET objects for Mapguide Enterprise 2011</title>
		<link>http://www.geospecialling.com/index.php/2010/07/creating-net-objects-for-mapguide-enterprise-2011/</link>
		<comments>http://www.geospecialling.com/index.php/2010/07/creating-net-objects-for-mapguide-enterprise-2011/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 05:15:41 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mapguide]]></category>
		<category><![CDATA[RADE]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Mapguide Enterprise]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/07/creating-net-objects-for-mapguide-enterprise-2011/</guid>
		<description><![CDATA[Better late than never…&#160; I’ve updated my Mapguide Enterprise .NET objects to work with 2011.&#160; The steps in my previous post for creating .NET objects for Mapguide Enterprise 2009&#160; have been modernized and simplified significantly.&#160;&#160; This post will show you how to create (or re-create) these objects for the 2011 release of Mapguide.&#160; Sorry for [...]]]></description>
			<content:encoded><![CDATA[<p>Better late than never…&#160; I’ve updated my <a title="Autodesk Mapguide" href="http://www.mapguide.com" target="_blank"></a><a title="Autodesk Mapguide Enterprise" href="http://www.mapguide.com" target="_blank">Mapguide Enterprise</a> .NET</a> objects to work with 2011.&#160; The steps in my <a title="Creating .NET objects for Mapguide XML schema definitions" href="http://www.webrade.com/blogs/darrin/2008/05/16/CreatingNETObjectsForMapguideXMLSchemaDefinitionsXSDUsingLINQ.aspx" target="_blank" rel="tag">previous post for creating .NET objects for Mapguide Enterprise 2009</a>&#160; have been modernized and simplified significantly.&#160;&#160; This post will show you how to create (or re-create) these objects for the 2011 release of Mapguide.&#160; Sorry for skipping 2010 =)</p>
<p>First, download the actual non-aplha release of <a title="LINQ to XSD" href="http://linqtoxsd.codeplex.com/releases/view/41258" target="_blank" rel="tag">LINQ to XSD</a> and extract it.&#160; You will need to have <a href="http://www.webrade.com/blogs/darrin/ct.ashx?id=f6d81338-14fd-4465-a8bd-8eeee747cdd4&amp;url=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fdetails.aspx%3fFamilyID%3da45f58cd-fcfc-439e-b735-8182775560af%26displaylang%3den">.NET 3.5</a> installed to run LINQ to XSD.&#160; The project itself is a Visual Studio 2010, .NET 4.0 project.&#160; You should be able to change it to .NET 3.5 with no problems.&#160; I’m not sure about using .NET 2.0.&#160;&#160; I still assume these steps should work with <a title="Mapguide Open Source" href="http://mapguide.osgeo.org" target="_blank">Mapguide Open Source</a> 2.2 given its pretty much the same thing as MGE 2011.&#160; Please let me know if you try it and that is not the case.</p>
<h3>Building the classes</h3>
<p>Last time around we had to mess around with Visual Studio projects, building temporary code, finding and extracting that code from temporary files.&#160; This time around, we’re given a nice little executable that can be run in a batch file.&#160;&#160; I’ve posted a copy of my batch file below but it was simply made using a dir /b &gt; CreateMapguideNetObjects.cmd in the <a title="Autodesk Mapguide" href="http://www.mapguide.com" target="_blank">Mapguide</a> server schema folder (which by default is to c:\Program Files\Autodesk\MapGuideEnterprise2011\Server\Schema) .&#160; I then edited that file with a text editor that support macros and removed the following schema files:</p>
<ul>
<li>FdoProviderCapabilities-1.0.0.xsd </li>
<li>LoadProcedure-1.0.0.xsd </li>
<li>LoadProcedure-1.1.0.xsd </li>
<li>LayerDefinition-1.0.0.xsd </li>
<li>LayerDefinition-1.1.0.xsd </li>
<li>LayerDefinition-1.2.0.xsd </li>
<li>SiteInformation-1.0.0.xsd </li>
<li>SiteVersion-1.0.0.xsd </li>
<li>SymbolDefinition-1.0.0.xsd </li>
<li>WebLayout-1.0.0.xsd </li>
</ul>
<p>These files are deprecated object definitions from previous Mapguide releases.&#160; In the end each line in the batch file looks a little like this:</p>
<blockquote><p>LinqToXsd ApplicationDefinition-1.0.0.xsd /filename:ApplicationDefinition.cs</p>
</blockquote>
<p>Executing the batch file will create a number of C# files containing appropriately named classes.</p>
<h3>Setting up your project</h3>
<p>At this point you should be able to fire up Visual Studio and create a new C# project.&#160;&#160; If you have an existing project from a previous version of Mapguide its good to start fresh.&#160; Also, don’t try this in an existing solution that is dependant on the project that contains the Mapguide objects.&#160; This will just result in a bunch of extra screwing around to avoid compiler errors from missing code during the process.&#160;&#160;&#160; This time around its a lot easier.&#160; Create a new DLL project.&#160; Add a reference to the Xml.Schema.Linq.dll file that was included with LinqToXsd.exe.&#160;&#160; Add a reference to the following Mapguide dlls:</p>
<ul>
<li>OSGeo.Mapguide.Foundation</li>
<li>OSGeo.Mapguide.Geometry</li>
<li>OSGeo.Mapguide.MapguideCommon</li>
<li>OSGeo.Mapguide.PlatformBase</li>
<li>OSGeo.Mapguide.Web</li>
</ul>
<p>You’ll also need to ensure that the appropriate unmanaged assemblies are available in the calling applications bin folder when you go to run this stuff.&#160; </p>
<p>Next place all of the generated C# files in the new project.&#160; Once you build you’re going to see a ton of errors.&#160; We’ll clean those up.</p>
<p>To resolve a lot of these errors I did a global search and replace on “global::” and replaced it with nothing.&#160; Also, I wrapped each class in a unique wrapper classes to prevent duplicate type errors.&#160; Finally, the case issue with DataType was still an issue – and I resolved it by changing the case on DataType to be Datatype:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> DataType {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Datatype {</pre>
</p></div>
</div>
<p>For a complete view of the changes I made do a file compare between the code in the attached zip file and your newly generated code.</p>
<p>&lt;insert 3 week gap here, wherein I had <a title="Mapguide Enterprise 2011 installation and licensing fun" href="http://www.geospecialling.com/index.php/2010/07/mapguide-2011-javascript-error-openlayers-lang-is-null-or-not-an-object/" target="_blank" rel="tag">a hell of a time getting MGE 2011 installed and properly licensed</a> so that I could actually test this newly created code, oh and I also went on vacation for a few days too =)/&gt;</p>
<p>And back.&#160; The best part about this is that it seems ALL my old <a title="RADE" href="http://www.geospecialling.com/index.php/2008/06/rade-build-custom-web-applications-without-writing-custom-code/" target="_blank" rel="tag">RADE</a> code just worked with upgraded basic layouts after changing it to look for the object definitions within the new wrapper classes.&#160;&#160; Now I just need to add support for flexible layouts and we’ll be laughing.</p>
<h3>The Code</h3>
<p>Please note – I didn’t rebase the code.&#160; It’s all in the RADE.MGE namespace.&#160; If you would like to use it, feel free to re-base it – or just leave it as is.&#160; Also, if you create any unit tests or enhancements and would like to share them – please feel free!&#160;&#160; </p>
<p>As I update the project myself, or receive updates I will update this file.</p>
<div class="wlWriterEditableSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:5b76b660-1647-415a-861e-ec611af03c8f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<p>Download the <a href="http://www.geospecialling.com/wp-content/uploads/2010/07/RADE.MGE_.2011.zip" target="_blank">Mapguide .NET Objects Visual Studio 2010 solution</a></p>
</div>
<p>.&#160;
<p>Finally, the <a title="Examples of using the Mapguide .NET objects" href="http://www.webrade.com/blogs/darrin/2008/05/21/DynamicAuthoringInMapguideEnterpriseBeforeTheViewerHasLoaded.aspx" target="_blank" rel="tag">example code I posted long ago</a> will still work with this new project.&#160; Perhaps one day, I’ll post some fancy new code in C# =) </p>
<p>Hope this comes in handy, I welcome your comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/07/creating-net-objects-for-mapguide-enterprise-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Effortlessly map domain and DTO entities</title>
		<link>http://www.geospecialling.com/index.php/2010/06/effortlessly-map-domain-and-dto-entities/</link>
		<comments>http://www.geospecialling.com/index.php/2010/06/effortlessly-map-domain-and-dto-entities/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 04:19:19 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[DTO]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/06/effortlessly-map-domain-and-dto-entities/</guid>
		<description><![CDATA[I recently created a set of DTO objects to complement the domain entities we use for our data access layer for a new project we’re working on.&#160; I immediately set out to write a mapping utility.&#160; After a bit of thought pondering the complexity of the problem I decided to look around on the magical [...]]]></description>
			<content:encoded><![CDATA[<p>I recently created a set of <a title="data transfer object" href="http://en.wikipedia.org/wiki/Data_Transfer_Object" target="_blank" rel="tag">DTO</a> objects to complement the domain entities we use for our data access layer for a new project we’re working on.&#160; I immediately set out to write a mapping utility.&#160; After a bit of thought pondering the complexity of the problem I decided to look around on the magical internets to see what options were available.</p>
<p>Came across <a title="Automappper - convention-based object-object mapper" href="http://automapper.codeplex.com/" target="_blank" rel="tag">Automapper</a>.&#160;&#160; This is a perfect match for my needs:</p>
<blockquote><p>AutoMapper uses a fluent configuration API to define an object-object mapping strategy.&#160;&#160; AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.</p>
</blockquote>
<p>It was quick to setup, and painless to use.&#160; First define your object to object mappings:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> Mapper.CreateMap&lt;RADE.BO.Domain.Application, RADE.BO.Entity.Application&gt;();</pre>
</p></div>
</div>
<div>&#160;</div>
<div>Next, whip up a small conversion function:</div>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #008000">/// Convert a DTOApplication to abnd </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #008000">/// &lt;param name=&quot;app&quot;&gt;&lt;/param&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> RADE.BO.Domain.Application Convert(Application app)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>   <span style="color: #0000ff">if</span> (app == <span style="color: #0000ff">null</span>) <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>   LoadDtoMappings();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>   <span style="color: #0000ff">return</span> AutoMapper.Mapper.Map&lt;Application, RADE.BO.Domain.Application&gt;(app);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> <span style="color: #008000">/// Convert a list of domain Application objects to DTO Application objects</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span> <span style="color: #008000">/// &lt;/summary&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span> <span style="color: #008000">/// &lt;param name=&quot;apps&quot;&gt;List of domain Application objects&lt;/param&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> <span style="color: #008000">/// &lt;returns&gt;List of DTO Application objects&lt;/returns&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> List&lt;Application&gt; Convert(List&lt;RADE.BO.Domain.Application&gt; apps)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     LoadDtoMappings();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     <span style="color: #0000ff">return</span> apps.Select(AutoMapper.Mapper.Map&lt;RADE.BO.Domain.Application, Application&gt;).ToList();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span> }</pre>
</p></div>
</div>
<p>It’s important to note that if your source object contains nested objects – a mapping for each nested object must also be defined.&#160; This goes on recursively through nested objects.&#160; My domain Application object contains some numerous sub objects – Map, Layer etc.&#160; In this case rather than establish mappings for these child objects – I removed these objects from my DTO as the client consuming these objects would never need that data.&#160; This also keeps the size of any data possibly being serialized down.&#160;&#160; Automapper dealt with this automatically.</p>
<p>I’ve only scratched the surface of what Automapper can do.&#160; Next step is to define unit test coverage using the <a title="Automapper configuration validation" href="http://automapper.codeplex.com/wikipage?title=Configuration%20Validation&amp;referringTitle=Home" target="_blank" rel="tag">configuration validation</a>, but it’s sleep time now… =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/06/effortlessly-map-domain-and-dto-entities/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deployment project crashes on execution with .NET version error</title>
		<link>http://www.geospecialling.com/index.php/2010/04/deployment-project-crashes-on-execution-with-net-version-error/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/deployment-project-crashes-on-execution-with-net-version-error/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 20:47:58 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Installer]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/deployment-project-crashes-on-execution-with-net-version-error/</guid>
		<description><![CDATA[This week I jumped on the .NET 4 bandwagon.&#160; I had a proof of concept project that I wanted to bring up to the “real product” level.&#160;&#160; This new product consists of a console application, a windows service, and some business logic and data access assemblies.&#160; During the development of my proof I created a [...]]]></description>
			<content:encoded><![CDATA[<p>This week I jumped on the <a title=".NET 4.0 bandwagon" href="http://www.microsoft.com/visualstudio/en-us/" target="_blank" rel="tag">.NET 4</a> bandwagon.&#160; I had a proof of concept project that I wanted to bring up to the “real product” level.&#160;&#160; This new product consists of a console application, a windows service, and some business logic and data access assemblies.&#160; During the development of my proof I created a small deployment project to build a quick and dirty installer.&#160;&#160; </p>
<p>I’ve upgraded the solution to 2010.&#160; I’ve done all the refactoring and finished my work.&#160; Everything tests out great in both unit tests and “developers computer” tests.&#160; Just need to get the installer updated and get the pesky “other peoples computers” thing out of the way.&#160; </p>
<p>I’ve updated the pre-requisites on my installer to include .NET 4.0 – rebuilt the installer and boom.&#160; </p>
<blockquote><p>Error 1001.&#160; Exception occurred while initializing the installation.&#160; System.BadImageFormatException: Could not load file or assembly ‘file:///C:\Program Files\Landor\ … \RADE.Connect.Service.exe’ or one of its dependencies.&#160; This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.</p>
</blockquote>
<p>After much mucking around I found the hidden property that I needed to change.&#160; I needed to change the .NET version of the .NET Launch Condition.&#160; To find this gem right click on the deployment project in the solution explorer and choose View\Launch Conditions.&#160; Next right click on the “.NET Framework” under “Launch Conditions” and choose “properties”.&#160; In the properties dialog change the Version to be “.NET Framework 4”.</p>
<h4>Update 4/20/2010</h4>
<p>Don’t forget to edit the .NET version for both Release and Debug configurations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/deployment-project-crashes-on-execution-with-net-version-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 and .NET 4.0 Full available on MSDN!</title>
		<link>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-and-net-4-0-full-available-on-msdn/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-and-net-4-0-full-available-on-msdn/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 16:06:51 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-and-net-4-0-full-available-on-msdn/</guid>
		<description><![CDATA[MSDN has been updated with the full releases of VS 2010 and .NET 4.0.&#160; Getting some decent download speeds too.. http://msdn.microsoft.com wooo!]]></description>
			<content:encoded><![CDATA[<p>MSDN has been updated with the full releases of VS 2010 and .NET 4.0.&#160; Getting some decent download speeds too..</p>
<p><a href="http://msdn.microsoft.com">http://msdn.microsoft.com</a></p>
<p>wooo!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-and-net-4-0-full-available-on-msdn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010, .NET 4.0, AND ReSharper 5.0 launch today!</title>
		<link>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-net-4-0-and-resharper-5-0-launch-today/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-net-4-0-and-resharper-5-0-launch-today/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 14:32:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ReSharper]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-net-4-0-and-resharper-5-0-launch-today/</guid>
		<description><![CDATA[I may be weird, but I actually went to bed excited last night.&#160; VS 2010, .NET 4.0, AND Resharper 5.0 are supposed to be released today.&#160;&#160; For the first time in probably months I got out of bed at 7am -&#160; It’s now 7:30 Redmond time – but MSDN has not yet been updated!&#160; Apparently [...]]]></description>
			<content:encoded><![CDATA[<p>I may be weird, but I actually went to bed excited last night.&#160; VS 2010, .NET 4.0, AND <a title="Resharper 5.0" href="http://www.jetbrains.com/resharper/" target="_blank" rel="tag">Resharper 5.0</a> are supposed to be released today.&#160;&#160; For the first time in probably months I got out of bed at 7am -&#160; It’s now 7:30 Redmond time – but MSDN has not yet been updated!&#160; Apparently we have to wait until 8:30 Redmond time.&#160;&#160; Adobe is all over their release of CS5 today, and they didn’t make their users wait until 8:30 Redmond time! =) </p>
<p>In the meantime, The Register has a good write up on some of the <a title="Visual Studio 2010 goodies coming" href="http://www.theregister.co.uk/2010/04/12/visual_studio_2010_platform_challenge/" target="_blank" rel="tag">new goodies</a> coming in an hour or so.&#160; That will learn me for getting up early.&#160; Oh well, time for another <a title="mmmm mr. cappuccino how I love you..." href="http://www.healthycoder.com/index.php/2009/10/a-new-addiction-cappuccino/" target="_blank" rel="tag">cap</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/visual-studio-2010-net-4-0-and-resharper-5-0-launch-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NHibernate 2.1 throws System.InvalidCastException on Oracle 10g R1 client</title>
		<link>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 21:52:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[nHibernate]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/</guid>
		<description><![CDATA[When deploying an early build of an up and coming product on a customers machine I came across the following error: System.InvalidCastException: Unable to cast object of type &#8216;Oracle.DataAccess.Client.OracleConnection&#8217; to type &#8216;System.Data.Common.DbConnection&#8217; This was one of those awesome “doesn’t happen on any of my machine” errors.&#160; After some mucking around we determined that the client [...]]]></description>
			<content:encoded><![CDATA[<p>When deploying an early build of an up and coming product on a customers machine I came across the following error:</p>
<p><em>System.InvalidCastException: Unable to cast object of type &#8216;Oracle.DataAccess.Client.OracleConnection&#8217; to type &#8216;System.Data.Common.DbConnection&#8217; </em></p>
<p>This was one of those awesome “doesn’t happen on any of my machine” errors.&#160; After some mucking around we determined that the client machine was using the Oracle 10g&#160; R1 client.&#160; The machines and VMs here we used for testing were all running either 11g, or 10g R2.&#160; Doh!</p>
<p>The simple resolution to this was to modify the NHhibernate config and add the following property:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;hbm2ddl.keywords&quot;</span><span style="color: #0000ff">&gt;</span>none<span style="color: #0000ff">&lt;/</span><span style="color: #800000">property</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<p>Depending on your underlying databases and mappings this could cause problems with your code project.&#160; Hopefully you’re not using reserved words, or bad Oracle syntax =).</p>
<p>Under the hood, the problem seems to be that the Oracle10gDialect does not provide an implementation of IDataBaseSchema for 10gR1.&#160;&#160; Fabio Maulo has provided some sample code and the steps on <a title="Create missing IDataBaseSchema for submission to NHibernate" href="http://fabiomaulo.blogspot.com/2009/06/from-where-start-to-implements.html" rel="tag">how to create the appropriate metadata</a> for your database and submit it to the NHibernate project for inclusion. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/nhibernate-2-1-throws-system-invalidcastexception-on-oracle-10g-r1-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper 5.0 is coming!</title>
		<link>http://www.geospecialling.com/index.php/2010/04/resharper-5-0-is-coming/</link>
		<comments>http://www.geospecialling.com/index.php/2010/04/resharper-5-0-is-coming/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 23:29:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/04/resharper-5-0-is-coming/</guid>
		<description><![CDATA[Ok, I’ve mentioned ReSharper in the past – but I had to bring it up again..&#160; Version 5 has some great new functionality and its coming soon!&#160; I’m especially excited about the huge functionality added for ASP.NET web development.&#160; I’ve been using the 5 beta and RC for probably a month or two and its [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I’ve <a title="Re-Sharper - A class creating machine" href="http://www.geospecialling.com/index.php/2008/07/resharper-a-class-creating-machine/" rel="tag">mentioned ReSharper</a> in the past – but I had to bring it up again..&#160; Version 5 has some great new functionality and its <a title="ReSharper 5 goes RC" href="http://blogs.jetbrains.com/dotnet/2010/03/resharper-50-goes-rc/" rel="tag">coming soon!</a>&#160; I’m especially excited about the huge <a title="ReSharper ASP.NET functionality" href="http://www.jetbrains.com/resharper/beta/beta.html#web_development" rel="tag">functionality added for ASP.NET</a> web development.&#160; I’ve been using the 5 beta and RC for probably a month or two and its great – I’ve been doing a metric butt-ton of refactoring and its great to have my changes go all the way into the .aspx files.&#160; </p>
<p>The NUnit test engine is great.&#160;&#160; I didn’t realize this was a ReSharper tool at first.&#160; Now, I can’t live without it.</p>
<p>The localization plugin is going to save me days of effort on an upcoming action item.&#160; </p>
<p>The class/code generating tools are indispensible – especially if you create a lot of classes (e.g NHibernate POCO’s). </p>
<p>The refactorings have been helping me slowly increase the legibility of my code – and also helping me build better coding habits.&#160; Check out the comparison between <a title="ReSharper 4.5 - 5.0 comparison" href="http://www.jetbrains.com/resharper/documentation/resharper5_vs_resharper45.html" rel="tag">version 5.0 and 4.5.</a></p>
<p>If you’ve never tried ReSharper – <a title="Try ReSharper" href="http://www.jetbrains.com/resharper/" rel="tag">now is the time.</a>&#160; only I could make the time to properly learn all the different tools available…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/04/resharper-5-0-is-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to NHibernate 2.1 for new Validators!</title>
		<link>http://www.geospecialling.com/index.php/2010/03/upgrading-to-nhibernate-2-1-for-new-validators/</link>
		<comments>http://www.geospecialling.com/index.php/2010/03/upgrading-to-nhibernate-2-1-for-new-validators/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 23:04:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[nHibernate]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2010/03/upgrading-to-nhibernate-2-1-for-new-validators/</guid>
		<description><![CDATA[I wanted to implemented the new NHibernate Validators which meant upgrading to NH 2.1.&#160;&#160; Found a great post documenting the new “breaking change” between 2.0 and 2.1 pertaining to the new proxy factory functionality in NH.&#160; “The ProxyFactoryFactory was not configured.” jumped up and bit me in the ass.&#160;&#160; NH used to assume Castle – [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to implemented the new <a title="NHibernate Validators" href="http://nhforge.org/wikis/validator/nhibernate-validator-1-0-0-documentation.aspx" rel="tag">NHibernate Validators</a> which meant upgrading to NH 2.1.&#160;&#160; Found a great post documenting the new “breaking change” between 2.0 and 2.1 pertaining to the new proxy factory functionality in NH.&#160; “The ProxyFactoryFactory was not configured.” jumped up and bit me in the ass.&#160;&#160; </p>
<p>NH used to assume Castle – but now it needs to be configured.&#160; In addition to the Castly proxy, there is a new LinFu proxy available too.&#160;&#160; <a title="Upgrading to NHibernate 2.1 - The ProxyFactoryFactory was not configured." href="http://davybrion.com/blog/2009/03/upgrading-to-nhibernate-21/" rel="tag">Don’t bother with NHibernate the release notes!</a> , Davy Brion has it all for you here =).&#160; </p>
<p>I opted to go with the Castly Dynamic Proxy – I’m not in a position to do any performance tests between– Castle has been around a long time and has a pretty big user base.&#160; Good <a title="Castly Dynamic Proxy vs LinFu" href="http://stackoverflow.com/questions/1406762/what-are-the-differences-between-linfu-dynamicproxy-and-castle-dynamicproxy" rel="tag">post on stackoverflow</a> on this subject.&#160; However, LinFu would have won if I was basing my choice on name alone…</p>
<p>After a bit of fiddling, I’m back up and running with NH 2.1 and shiny new validation attributes.&#160;&#160;&#160; </p>
<p>mmmm validation…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2010/03/upgrading-to-nhibernate-2-1-for-new-validators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper 4.5 Released!</title>
		<link>http://www.geospecialling.com/index.php/2009/04/resharper-45-released/</link>
		<comments>http://www.geospecialling.com/index.php/2009/04/resharper-45-released/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 01:09:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://www.landoris.com/blogs/darrin/index.php/2009/04/resharper-45-released/</guid>
		<description><![CDATA[JetBrains has just released ReSharper 4.5!&#160;&#160; Some of the key features of this upgrade are: 1. performance and memory usage improvements 2. Solution-wide code inspections (tons of cool tools to find unused params, privates, etc) 3. VB9 support (too bad I’ve been busy moving to C# =]) 4. Native MSTest Support (I much prefer NUnit [...]]]></description>
			<content:encoded><![CDATA[<p>JetBrains has just released <a title="ReSharper 4.5 Released!" href="http://www.jetbrains.com/resharper/" target="_blank" rel="tag">ReSharper 4.5</a>!&#160;&#160; Some of the key features of this upgrade are:</p>
<ol>
<li>1. performance and memory usage improvements </li>
<li>2. Solution-wide code inspections (tons of cool tools to find unused params, privates, etc) </li>
<li>3. VB9 support (too bad I’ve been busy moving to C# =]) </li>
<li>4. Native MSTest Support (I much prefer <a title="NUnit - .NET Unit Testing" href="http://www.nunit.org/index.php" target="_blank" rel="tag">NUnit</a> though) </li>
</ol>
<p>&#160;</p>
<p>Check it out.&#160; ReSharper is one of the tools I use every day and couldn’t live without…One more day and I’ll be done in Visual Lisp and can actually try out the new release a little more =)</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c19e754d-f489-4b40-b8e0-d62f44054fff" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/ReSharper" rel="tag">ReSharper</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2009/04/resharper-45-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Relative URLs in CSS with ASP.NET</title>
		<link>http://www.geospecialling.com/index.php/2009/04/using-relative-urls-in-css-with-aspnet/</link>
		<comments>http://www.geospecialling.com/index.php/2009/04/using-relative-urls-in-css-with-aspnet/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 00:42:23 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.landoris.com/blogs/darrin/index.php/2009/04/using-relative-urls-in-css-with-aspnet/</guid>
		<description><![CDATA[When we started redoing the company website I decided that this new site would be all CSS based.&#160; No more nasty tables.&#160;&#160; Once the initial xhtml/css template was made I moved it into and ASP.NET master page.&#160; As the site was fleshed out I ran into a problem where some of the images were not [...]]]></description>
			<content:encoded><![CDATA[<p>When we started redoing the <a title="Landor Information Systems" href="http://www.landorIS.com" target="_blank" rel="tag">company website</a> I decided that this new site would be all CSS based.&#160; No more nasty tables.&#160;&#160; Once the initial xhtml/css template was made I moved it into and ASP.NET master page.&#160; As the site was fleshed out I ran into a problem where some of the images were not loading as the master page was used deeper within the sites structure.&#160;&#160; A little inspection of the underlying CSS and I noticed this:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> #header {<span style="color: #0000ff">width</span>:<span style="color: #006080">100%;</span> <span style="color: #0000ff">height</span>:<span style="color: #006080">50px;</span>    <span style="color: #0000ff">background</span>: #7D7D7D url(images/header<span style="color: #cc6633">.gif</span>) <span style="color: #0000ff">left</span> <span style="color: #0000ff">top</span> no<span style="color: #006080">-repeat;</span>}</pre>
</p></div>
</div>
<p>&#160;</p>
<p>When the master page is used from a page deeper than the site root, the paths in the CSS become invalid.&#160; To work around this I made my CSS dynamic!&#160; I added a new page to my project in the CSS folder.&#160; I called this page allcss.aspx.css.&#160;&#160; Open up this new aspx file and remove all the html.&#160; Leave only the page header definition:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="background-color: #ffff00">&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;all.css.aspx.cs&quot; Inherits=&quot;landorIS.com.css.allcss&quot; ContentType=&quot;text/css&quot; %&gt;</span></pre>
</p></div>
</div>
<p><a href="http://www.landoris.com/blogs/darrin/wp-content/uploads/2009/04/image10.png"></a></p>
<p><a href="http://www.landoris.com/blogs/darrin/wp-content/uploads/2009/04/image10.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; margin-left: 0px; border-left: 0px; margin-right: 0px; border-bottom: 0px" height="149" alt="image" src="http://www.landoris.com/blogs/darrin/wp-content/uploads/2009/04/image10-thumb.png" width="244" align="right" border="0" /></a></p>
<p>Note that you may need to update your classnames and stuff depending on how you name the file.&#160; I wanted my file name to reflect the fact that it was a CSS file – but it’s still needed to end with .aspx to ensure the file would be properly parsed by the ASP.NET engine without having to mess with the extension mapping on the web server.&#160; This resulted in Visual Studio making some illegal class names. </p>
<p>Also be sure that you add the ContentType attribute to the @Page definition, and set it to “text/css”, or you will get an error in some browsers stating that the Mime Type “text/html” is not “text/css”.&#160; Nice of Firefox to do a little validation on the content.</p>
<p>At this point you can add your CSS to the file and use &lt;%%&gt; tags or codebehind to manipulate the values.&#160; Now the CSS that was causing problems with the images looks like this:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">background</span>:url('<span style="color: #006080">&lt;</span>%=ResolveUrl(&quot;~/<span style="color: #0000ff">img</span>/header-bg<span style="color: #cc6633">.png</span>&quot;)%<span style="color: #006080">&gt;</span>') no<span style="color: #006080">-repeat 0 0;</span></pre>
</p></div>
</div>
<p>&#160;</p>
<p>Now when the CSS is requested by the browser and rendered out, the URL to the image file will be properly displayed as /RootFoolder/img/header-bg.png.&#160; This is a very simple modification, but one could go a little more crazy and do something like&#160; detect browser make/model and send out browser specific css in pre-defined literals, or possibly add authentication checks.&#160; </p>
<p>&#160;</p>
<p>&#160;</p>
</p>
</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:d4c81f90-214f-4750-a10f-101a629a419d" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/ASP.NET" rel="tag">ASP.NET</a>,<a href="http://technorati.com/tags/CSS" rel="tag">CSS</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2009/04/using-relative-urls-in-css-with-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Click Builds Are A Beautiful Thing &#8211; Automated Build Studio</title>
		<link>http://www.geospecialling.com/index.php/2009/03/one-click-builds-are-a-beautiful-thing-automated-build-studio/</link>
		<comments>http://www.geospecialling.com/index.php/2009/03/one-click-builds-are-a-beautiful-thing-automated-build-studio/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 13:00:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Automated Build Studio]]></category>
		<category><![CDATA[One Click Build]]></category>

		<guid isPermaLink="false">http://www.landoris.com/blogs/darrin/index.php/2009/03/one-click-builds-are-a-beautiful-thing-automated-build-studio/</guid>
		<description><![CDATA[I’ve known for a long time that an automated build system is valuable, hey it’s number two on the Joel test.&#160; Recently the complexity of some of our products made an automated build system a requirement.&#160; It was getting to the point where creating a build of RADE was a four plus hour ordeal.&#160; It [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve known for a long time that an automated build system is valuable, hey it’s number two on <a title="The Joel Test" href="http://www.joelonsoftware.com/articles/fog0000000043.html" target="_blank" rel="tag">the Joel test</a>.&#160; Recently the complexity of some of our products made an automated build system a requirement.&#160; It was getting to the point where creating a build of <a title="RADE - Configurable Web based Solutions" href="http://www.landorIS.com/solutions/RADE" target="_blank" rel="tag">RADE</a> was a four plus hour ordeal.&#160; It had dozens of little steps, and missing even one would result in a defect.&#160;&#160; This defect would be a vicious cycle.&#160; We would have to debug to find the problem and fix it.&#160; This would cause ANOTHER four hour rebuilt, and the “cycle of bug” would continue.</p>
<p>This complexity resulted in infrequent builds and as a result the code was not tested as well as it should have been.&#160; Not to mention, I’d get really frustrated and even pissed off on build days.&#160;&#160; It took me a while to find a system that really made me happy.&#160; On a whim one night I downloaded <a title="Automated Build Studio - One Click Build Goodness!" href="http://www.automatedqa.com/products/abs/index.asp" target="_blank" rel="tag">Automated Build Studio</a> (ABS) and gave it a shot.&#160; After installing ABS on a new virtual machine that would become our dedicated build system I fired it up.&#160; I was pretty impressed with the wide range of actions and&#160; tools it supported.&#160; In our environment we had several must have items:</p>
<ul>
<li>1. SourceGear Vault </li>
<li>2. Visual Studio 2008 </li>
<li>3. Oracle/SQL Server </li>
<li>4. Installshield 2009 </li>
</ul>
<p>&#160;</p>
<p>ABS worked with all of them.&#160; In addition to the key requirements I had &#8211; it supported a <a title="Automated Build Studio operations" href="http://www.automatedqa.com/products/abs/operations.asp" target="_blank">plethora of other operations</a>.</p>
<p>First thing I did was sketch out a rough outline of what was involved in creating a build.&#160; Get latest source code, compile, delete temporary files, etc etc etc.&#160; I started selecting various options from the ABS and fleshing out my macro.&#160; Within a couple of hours, I had a sweet macro in place.&#160; My macro started to look like this:</p>
<ul>
<li>Getting the latest code from Vault </li>
<li>Compile all assemblies </li>
<li>Delete the temporary files </li>
<li>Build the needed release folder structure </li>
<li>Move the new files into the needed structure </li>
<li>Execute <a title="Remotesoft Protector" href="http://www.remotesoft.com/salamander/protector.html" target="_blank" rel="tag">Remotesoft Protector</a> on all assemblies </li>
<li>Increment the build version, and set the version on all assemblies </li>
<li>Create a label of the build in Vault </li>
<li>Build a zip of the release </li>
<li>Build the Installshield installer </li>
<li>Connect to the build FTP and upload the new build </li>
</ul>
<p>&#160;</p>
<p>The best part – all of this was occurring in a 100% reliable fashion, oh and it took minutes for a full build to occur.&#160; Over time, this project was tweaked, and copied.&#160; It evolved as I learned more about ABS – or thought up new requirements.&#160; Take <a title="FullCircle - Excel to Database" href="http://www.landorIS.com/solutions/fullcircle" target="_blank" rel="tag">FullCircle</a> for example, it has evolved into three editions, sharing a similar yet different set of source files.&#160; ABS lets me rebuild all three editions with the click of a button – in minutes.&#160;&#160; Long long ago, in the before times something like this would have taken days, and years off my life.</p>
<p>I’ve only scratched the surface of what I’ve been able to do with ABS – some other cool features worth mentioning is that builds can be scheduled to run, there is a web application for viewing build history as well as kicking off builds.&#160; It has a scripting language, and the support I’ve received is fantastic.&#160; The price of the product makes the decision to buy ABS a non issue.</p>
<p>Man, now I’m starting to sound like a sales guy. =)&#160; Seriously though, check out <a title="Automated Build Studio" href="http://www.automatedqa.com/products/abs/index.asp" target="_blank" rel="tag">Automated Build Studio</a> if you develop boxed, or even custom software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2009/03/one-click-builds-are-a-beautiful-thing-automated-build-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET 3.5 &#8220;Attempted to read or write protected memory&#8221; Caused by Remotesoft Protector</title>
		<link>http://www.geospecialling.com/index.php/2008/11/net-3-5-attempted-to-read-or-write-protected-memory-caused-by-remotesoft-protector/</link>
		<comments>http://www.geospecialling.com/index.php/2008/11/net-3-5-attempted-to-read-or-write-protected-memory-caused-by-remotesoft-protector/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 05:25:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Remotesoft Protector]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2008/11/net-3-5-attempted-to-read-or-write-protected-memory-caused-by-remotesoft-protector/</guid>
		<description><![CDATA[Months ago, I started getting the “Attempted to read or write protected memory” error.&#160; In hindsight (as always) its all clear.&#160; In short, it seems .NET 3.5 SP1 and Remotesoft Protector v2.x do not play nicely resulting in this error.&#160; Either stop using Protector, or upgrade to the latest version. In long – for a [...]]]></description>
			<content:encoded><![CDATA[<p>Months ago, I started getting the “Attempted to read or write protected memory” error.&#160; In hindsight (as always) its all clear.&#160; In short, it seems .NET 3.5 SP1 and <a title="Remotesoft Protector" href="http://www.remotesoft.com/salamander/protector.html" target="_blank" rel="tag">Remotesoft Protector</a> v2.x do not play nicely resulting in this error.&#160; Either stop using Protector, or upgrade to the latest version.</p>
<p>In long – for a number of reasons there was not a strait line between upgrading my machine to SP1 and noticing the problem.&#160; This made diagnosing the problem significantly more complicated because I had no idea when it actually started.&#160; At the time, I was dealing with <a title="Vista x64 and Oracle Client" href="http://www.webrade.com/blogs/darrin/2008/10/23/OracleClientODACOnVistaX64MostlyWorkingFinally.aspx" target="_blank" rel="tag">x64 and Oracle clients</a>.&#160; This had prompted me to start doing all my dev in an XP virtual machine.&#160; Eventually, the slowless of developing in a VM drove me insane and I just had to get my machine working again.&#160; So I got Oracle dealt with – but that left this annoying error.</p>
<p>It was a complete fluke that I noticed this.&#160; The stars aligned, and I manually compiled some assemblies, instead of pushing the big green button on my build system.&#160; This resulted in my assemblies not being run through the Remotesoft Protector.&#160; All of a sudden the problem went away.&#160; At the time I had been using Protector 2.x which would not support .NET 3.5 SP1 fully. So, either stop using Protector, or upgrade to the latest version which resolves this problem =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2008/11/net-3-5-attempted-to-read-or-write-protected-memory-caused-by-remotesoft-protector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper &#8211; A Class Creating Machine</title>
		<link>http://www.geospecialling.com/index.php/2008/07/resharper-a-class-creating-machine/</link>
		<comments>http://www.geospecialling.com/index.php/2008/07/resharper-a-class-creating-machine/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 13:43:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ReSharper]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2008/07/resharper-a-class-creating-machine/</guid>
		<description><![CDATA[Recently, I purchased a copy of ReSharper 4.0.&#160; I&#8217;m not even going to pretend I&#8217;ve scratched the surface of what ReSharper can do, but I can assure you it&#8217;s a massive time saver when creating classes from scratch.&#160; I&#8217;m furiously plugging away, implementing an nHibernate ORM for RADE, and to do that I needed to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I purchased a copy of <a title="ReSharper 4.0 - A Class Creating Machine!" href="http://www.jetbrains.com/resharper/index.html" target="_blank" rel="tag">ReSharper 4.0</a>.&#160; I&#8217;m not even going to pretend I&#8217;ve scratched the surface of what ReSharper can do, but I can assure you it&#8217;s a massive time saver when creating classes from scratch.&#160; I&#8217;m furiously plugging away, implementing an <a title="nHibernate Object Relational Mapper" href="http://www.nhibernate.org" target="_blank" rel="tag">nHibernate</a> ORM for RADE, and to do that I needed to create a lot of classes pretty much from scratch (oh, and do I have a few things to say about that, but that&#8217;s for another day).&#160; Let&#8217;s look at a simple example.&#160; To get things started, create a new class.&#160; Select the folder in the solution explorer, and press Alt+Insert:</p>
<p align="center"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image6.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="184" alt="ReSharper Class Creation" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb6.png" width="227" border="0" /></a> </p>
<p align="left">Press enter and you are prompted for the class name.&#160; So Visual Studio has this of course, but this is a small example of some of the time savings you can achieve.&#160; Enter the class name and you start off with an empty class.&#160; Next, lets define a couple of private members.&#160;&#160; Let&#8217;s run with the following example.</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> namespace RADE.BO.Domain</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     public class SampleClass</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         private Int32 _ID;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         private String _Description;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         private Int64 _BiggerInt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> }</pre>
</p></div>
</div>
<p>&#160;</p>
<p>Simple class.&#160; Three member variables.&#160; Here is where the big time savers come in.&#160; Next, click Alt+Insert again and you will be prompted with the following options:</p>
<p align="center"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image7.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="Some ReSharper Code Generation Tools" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb7.png" width="207" border="0" /></a> </p>
<p align="left">Choose Properties.&#160; You will now be given the option to select one or many fields, set the access rights, read only and virtual properties as well a bunch of others.&#160; </p>
<p align="center"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="ReSharper Properties Generator" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb8.png" width="244" border="0" /></a> </p>
<p align="left">Execute that and all of your get/sets are defined.&#160; My one complaint is that ReSharper is not maintaining the type on the properties.&#160; My Int32&#8242;s become int, and Int64&#8242;s become long&#8217;s.&#160; Apparently this is slated to be fixed.&#160;&#160; </p>
<p align="left">So yes, this sample class is tiny, but the time savings on larger classes, or projects full of classes are significant.&#160; The last feature I&#8217;ve been using extensively in this project is the generate constructor tool.&#160; Again, a form is displayed with the defined properties, select the ones you want and boom.&#160; You can create half a dozen different constructors in seconds.&#160; I&#8217;ve created a full object model on, roughly 20 different mildly complex objects in less than an hour, around midnight on a Sunday =)</p>
<p align="left">Some of the other things ReSharper does is suggest code cleanup ideas by removing unused directives, easy execution of <a title="NUnit unit-testing framework" href="http://www.nunit.org" target="_blank" rel="tag">NUnit tests</a>, improved code completion.&#160; I encourage you to check it out, <a title="ReSharper 4.0 Download Trial" href="http://www.jetbrains.com/resharper/download/" target="_blank" rel="tag">download a ReSharper trial</a>.</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8dcb5def-80db-43d5-9cd3-dc2a526c7b9c" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/ReSharper" rel="tag">ReSharper</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2008/07/resharper-a-class-creating-machine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>.NET Code Protection &#8211; Remotesoft Protector to the Rescue!</title>
		<link>http://www.geospecialling.com/index.php/2008/05/net-code-protection-remotesoft-protector-to-the-rescue/</link>
		<comments>http://www.geospecialling.com/index.php/2008/05/net-code-protection-remotesoft-protector-to-the-rescue/#comments</comments>
		<pubDate>Sun, 25 May 2008 07:53:00 +0000</pubDate>
		<dc:creator>Darrin Maidlow</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Code Protection]]></category>

		<guid isPermaLink="false">http://www.geospecialling.com/index.php/2008/05/net-code-protection-remotesoft-protector-to-the-rescue/</guid>
		<description><![CDATA[When .NET based assemblies go out the door, it&#8217;s incredibly simple for others to get access to your code.&#160;&#160; Download Lutz Roeder&#8217;s Reflector and take a look at what some of your assemblies have to say.&#160; The code visible is likely not going to be anywhere near as elegant as the original.&#160; The comments will [...]]]></description>
			<content:encoded><![CDATA[<p>When .NET based assemblies go out the door, it&#8217;s incredibly simple for others to get access to your code.&#160;&#160; Download <a title="Lutz Roeder&#39;s Reflector" href="http://www.aisto.com/roeder/dotnet/" target="_blank" rel="tag">Lutz Roeder&#8217;s Reflector</a> and take a look at what some of your assemblies have to say.&#160; The code visible is likely not going to be anywhere near as elegant as the original.&#160; The comments will be gone.&#160; The gist of what you are doing will be there.&#160; If you would prefer that your work be a little tougher to get at, read on.</p>
<p>Obfuscation was one of my first answers to this problem.&#160; An obfuscator ships with Visual Studio Pro, free and there are many available on the market.&#160; Obfuscation just didn&#8217;t do it for me.&#160; I once helped a customer troubleshoot problems with one of their software solutions from an unnamed vendor using Reflector and walking through the obfuscated code.&#160; This was really a painful experience, it does make it harder to figure out what is going on &#8211; but a friend of mine suggested a product that takes code protection one step further.</p>
<p>Hello <a title="Remotesoft Protector - protect your code" href="http://www.remotesoft.com/salamander/protector.html" target="_blank" rel="tag">Remotesoft Protector</a>.&#160; This product is pretty cool.&#160; If you purchase the protector product you will receive three components.&#160; Salamander .NET Decompiler, .NET Obfuscator, and .NET Protector.&#160; Initially I was processing my assemblies with both the obfuscator and the protector.&#160;&#160; Now a days, I pretty much only run my assemblies through the protector.</p>
<p>Once you&#8217;ve processed an assembly with the protector and you open it up in reflector things are going to look a little different.&#160; Here is a little before and after action for you:</p>
<p align="center"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="478" alt="Code as disassembled by Reflector" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb2.png" width="644" border="0" /></a>&#160;</p>
<p align="left">Now lets take a look at the same code, but after being protected:</p>
<p align="center"><a href="http://www.geospecialling.com/wp-content/uploads/2010/02/image3.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="73" alt="image" src="http://www.geospecialling.com/wp-content/uploads/2010/02/image_thumb3.png" width="244" border="0" /></a> </p>
<p align="left">That&#8217;s it.&#160; Protector has made all your code go bye bye =)&#160; What&#8217;s happened here?&#160; As I understand it, Protector compiles all your managed .NET code into native code.&#160; So, yes, is it possible to disassemble native binaries.&#160; The difference here is the height of the bar &#8211; with plain .NET assemblies even my grand mother could get my code.&#160; Reverse engineering a native assembly is a different story.&#160; If someone with the skill to do that wants your code &#8211; well you must be writing some damn fine code.&#160; It would probably be easier for that kind of person to write it from scratch =)</p>
<p align="left">I&#8217;ve been working on increasing my <a title="The Joel Test - 12 Steps to Better Code" href="http://www.joelonsoftware.com/articles/fog0000000043.html" target="_blank" rel="tag">Joel Test</a> score lately.&#160; One of my biggies is the one step build for RADE.&#160; That sentence really doesn&#8217;t do the task justice.&#160; The first step I&#8217;m tackling in the one step build is automating the process of protecting my .NET assemblies.&#160; I could not find any resources on doing with with MSBuild.&#160; Once I get it working, I&#8217;ll post some code.</p>
<p align="left">All that said, I highly recommend you check out Protector if code protection is your thing.&#160; The price is a little bit steep at 1899$ for 1-5 developers &#8211; but how much money have you invested in that one little DLL or EXE file?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geospecialling.com/index.php/2008/05/net-code-protection-remotesoft-protector-to-the-rescue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

