<?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>Florent Clairambault &#187; .Net</title>
	<atom:link href="http://florent.clairambault.fr/tag/net/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Wed, 28 Jul 2010 20:31:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>ANTS Memory Profiler</title>
		<link>http://florent.clairambault.fr/ants-memory-profiler?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ants-memory-profiler</link>
		<comments>http://florent.clairambault.fr/ants-memory-profiler#comments</comments>
		<pubDate>Wed, 30 Dec 2009 18:00:16 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET Reflector]]></category>
		<category><![CDATA[ANTS Memory Profiler]]></category>
		<category><![CDATA[Memory Profiler]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2263</guid>
		<description><![CDATA[Well, I&#8217;m speaking about a commercial product again. This time it&#8217;s about ANTS Memory Profiler (by Red Gate software, the ones that made .Net reflector). This product will help you identify any .Net memory leak you could have. The truth is, .Net never leaks but you can sometimes make stupid conception mistakes, like forgetting to [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;m speaking about a commercial product again. This time it&#8217;s about ANTS Memory Profiler (by Red Gate software, the ones that made .Net reflector). This product will help you identify any .Net memory leak you could have.</p>
<p>The truth is, .Net never leaks but you can sometimes make stupid conception mistakes, like forgetting to remove references of some objects (that may contains heavy references themselves).</p>
<p>The tool allows you to take snapshots of your running application and compare different snapshots. You can see the difference of memory consumption by some objets or the difference of class instance count.</p>
<p>I&#8217;ve used it at work to solve a Sharepoint memory leak. And I finally discovered that the memory leak is really coming from the .Net Sharepoint object model. I&#8217;ll talk about this later. Sharepoint is amazing both ways.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/ants-memory-profiler/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading plugins assemblies in .Net</title>
		<link>http://florent.clairambault.fr/loading-plugins-assemblies-in-net?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=loading-plugins-assemblies-in-net</link>
		<comments>http://florent.clairambault.fr/loading-plugins-assemblies-in-net#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:00:37 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net Add-In]]></category>
		<category><![CDATA[.Net plugins]]></category>
		<category><![CDATA[C# .Net]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=2267</guid>
		<description><![CDATA[(first post of the year) This might seem like a quite complex thing to do, but it&#8217;s in fact very simple. Thank you .Net for being so well built. Note : With .Net 3.5, there is a much more advanced method called Add-In. But it&#8217;s also much more complex. You should use it on long-term [...]]]></description>
			<content:encoded><![CDATA[<p><em>(first post of the year)</em></p>
<p>This might seem like a quite complex thing to do, but it&#8217;s in fact very simple. Thank you .Net for being so well built.</p>
<p>Note : With .Net 3.5, there is a much more advanced method called <a href="http://msdn.microsoft.com/en-us/library/bb384200.aspx">Add-In</a>. But it&#8217;s also much more complex. You should use it on long-term projects with some evolutions of the plugins API (and no possibility to change the plugins). I&#8217;ve used it for a project and that really made us lose a lot of time.</p>
<p>So here is the code for a simple plugins class loading system :</p>

<div class="wp_codebox"><table><tr id="p22675"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code" id="p2267code5"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>Type<span style="color: #008000;">&gt;</span> GetPlugins<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">string</span> folder <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	var files <span style="color: #008000;">=</span> Directory<span style="color: #008000;">.</span><span style="color: #0000FF;">GetFiles</span><span style="color: #008000;">&#40;</span> folder, <span style="color: #666666;">&quot;*.dll&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	var tList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>Type<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">string</span> file <span style="color: #0600FF; font-weight: bold;">in</span> files <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
			var assembly <span style="color: #008000;">=</span> Assembly<span style="color: #008000;">.</span><span style="color: #0000FF;">LoadFile</span><span style="color: #008000;">&#40;</span> file <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span> Type type <span style="color: #0600FF; font-weight: bold;">in</span> assembly<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTypes</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">!</span>type<span style="color: #008000;">.</span><span style="color: #0000FF;">IsClass</span> <span style="color: #008000;">||</span> type<span style="color: #008000;">.</span><span style="color: #0000FF;">IsNotPublic</span> <span style="color: #008000;">&#41;</span>
					<span style="color: #0600FF; font-weight: bold;">continue</span><span style="color: #008000;">;</span>
				var interfaces <span style="color: #008000;">=</span> type<span style="color: #008000;">.</span><span style="color: #0000FF;">GetInterfaces</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
				<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span>IList<span style="color: #008000;">&#41;</span> interfaces <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span> <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span> T <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>
					tList<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> type <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span> Exception ex <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			Logger<span style="color: #008000;">.</span><span style="color: #0000FF;">LogException</span><span style="color: #008000;">&#40;</span> ex <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0600FF; font-weight: bold;">return</span> tList<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> InstanciatePlugins<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> List<span style="color: #008000;">&lt;</span>Type<span style="color: #008000;">&gt;</span> types, <span style="color: #6666cc; font-weight: bold;">object</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args <span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">where</span> T<span style="color: #008000;">:</span><span style="color: #6666cc; font-weight: bold;">class</span> <span style="color: #008000;">&#123;</span>
	var list <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span> var t <span style="color: #0600FF; font-weight: bold;">in</span> types <span style="color: #008000;">&#41;</span>
		<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#40;</span> t<span style="color: #008000;">.</span><span style="color: #0000FF;">GetInterfaces</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> IList <span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span> <a href="http://www.google.com/search?q=typeof+msdn.microsoft.com"><span style="color: #008000;">typeof</span></a><span style="color: #008000;">&#40;</span> T <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span>
			list<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> Activator<span style="color: #008000;">.</span><span style="color: #0000FF;">CreateInstance</span><span style="color: #008000;">&#40;</span> t, args <span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">as</span> T <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">return</span> list<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Our project can be organized like this :<br />
Project.Project : The application that will load plugins<br />
Project.Common.Plugins : The common types used by the core and the plugins<br />
Project.Plugin.Test1 : One stupid test plugin</p>
<p>In Project.Common.Plugins, we will declare an interface :</p>

<div class="wp_codebox"><table><tr id="p22676"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2267code6"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> Project<span style="color: #008000;">.</span><span style="color: #0000FF;">Common</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Plugins</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IPlugin <span style="color: #008000;">&#123;</span>
		<span style="color: #6666cc; font-weight: bold;">String</span> Name <span style="color: #008000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
		<span style="color: #6666cc; font-weight: bold;">void</span> DoSomeStuff<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>In Project.Plugin.Test1, we will declare a class :</p>

<div class="wp_codebox"><table><tr id="p22677"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p2267code7"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> Project<span style="color: #008000;">.</span><span style="color: #0000FF;">Plugin</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Test1</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PluginTest1 <span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">String</span> Name <span style="color: #008000;">&#123;</span> get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #666666;">&quot;PluginTest1&quot;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span> <span style="color: #008000;">&#125;</span>
		<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DoSomeStuff<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">for</span><span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">100</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span>
				Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;I only count ({0})&quot;</span>, i <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>This assembly has to be generated in a &#8220;plugins&#8221; directory.</p>
<p>Then, in your project, you will just have to use the methods given in the beginning and do something like that :</p>

<div class="wp_codebox"><table><tr id="p22678"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p2267code8"><pre class="csharp" style="font-family:monospace;">var types <span style="color: #008000;">=</span> GetPlugins<span style="color: #008000;">&lt;</span>IPlugin<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;plugins&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var pluginInstances <span style="color: #008000;">=</span> InstanciatePlugins<span style="color: #008000;">&#40;</span> types, <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Plugins are :&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span> var pi <span style="color: #0600FF; font-weight: bold;">in</span> pluginInstances <span style="color: #008000;">&#41;</span>
	Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;* {0}&quot;</span>, pi<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>If you&#8217;re worried that you&#8217;re stuck with these created objects, you should take a look on the AppDomain (I think I will talk about them pretty soon). This allows to load .Net assemblies and types and then unload them when ever you want. But as it can be easily adapted to some existing code, you should start without it and then add it when you feel your application could benefit from it.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/loading-plugins-assemblies-in-net/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NDepend</title>
		<link>http://florent.clairambault.fr/ndepend?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ndepend</link>
		<comments>http://florent.clairambault.fr/ndepend#comments</comments>
		<pubDate>Sun, 08 Nov 2009 19:57:35 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[NDepend]]></category>
		<category><![CDATA[Resharper]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1918</guid>
		<description><![CDATA[Patrick Smacchia gave me a professional license of NDepend v2.12 so that I could write some stuff about it if I liked it. As it was a gift (yes it is), I decided to force myself to look into this software. And after having looked much of its functionalities, I kind of like it. It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codebetter.com/blogs/patricksmacchia/">Patrick Smacchia</a> gave me a professional license of <a href="http://www.ndepend.com/">NDepend</a> v2.12 so that I could write some stuff about it if I liked it. As it was a gift (yes it is), I decided to force myself to look into this software. And after having looked much of its functionalities, I kind of like it. It&#8217;s not THE ultimate tool you have to use, but it&#8217;s a little bit like the other (resharper, reflector, etc.), it gives you a better insight of what you have in hand.</p>
<p>It&#8217;s a little bit like Resharper, it helps you see what you might have done wrong. Except Resharper tells it when you&#8217;re editing the code and NDepend helps you make a full review of the code.</p>
<p>Everything in this software goes around the Code Query Language (CQL). I thought this was some sort of commercial concept to sell more but it turns out that we can do a lot of things with it. It seems like a sensible idea, it&#8217;s SQL for the code. And the CQL textbox supports for auto-completion makes the CQL writing process pretty easy.</p>
<p><strong>Don&#8217;t make it your judgment tool</strong><br />
I guess the most risky think to do would be to give NDepend to dumb people (like code quality reviewers that don&#8217;t understand much of what they do). They would end up getting on everybody&#8217;s nevers. Because I don&#8217;t think that all the code creating query warnings could be changed. I&#8217;ve taken the simple stripped down method example of the StreamRipper app :</p>

<div class="wp_codebox"><table><tr id="p191810"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p1918code10"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> Boolean ParseArgs<span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args, Parameters parameters <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> args<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span> args<span style="color: #008000;">&#91;</span> i <span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;--url&quot;</span><span style="color: #008000;">:</span>
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;-u&quot;</span><span style="color: #008000;">:</span>
					parameters<span style="color: #008000;">.</span><span style="color: #0000FF;">Urls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> args<span style="color: #008000;">&#91;</span> <span style="color: #008000;">++</span>i <span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
					<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
&nbsp;
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;--user-agent&quot;</span><span style="color: #008000;">:</span>
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;-a&quot;</span><span style="color: #008000;">:</span>
					parameters<span style="color: #008000;">.</span><span style="color: #0000FF;">UserAgent</span> <span style="color: #008000;">=</span> args<span style="color: #008000;">&#91;</span> <span style="color: #008000;">++</span>i <span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
					<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
&nbsp;
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;--reconnect-attempts&quot;</span><span style="color: #008000;">:</span>
				<span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;-r&quot;</span><span style="color: #008000;">:</span>
					parameters<span style="color: #008000;">.</span><span style="color: #0000FF;">MaxReconnectionTries</span> <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span> args<span style="color: #008000;">&#91;</span> <span style="color: #008000;">++</span>i <span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
					<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span> Exception <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		Console<span style="color: #008000;">.</span><span style="color: #0000FF;">Error</span><span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Arguments error ! &quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>This code will create a cyclomatic complexity warning (as it would in Resharper 5.0 [I should talk about this someday] with the cyclomatic complexity addin). So, for me, it&#8217;s clear you have to accept to have a lot of warnings. It&#8217;s not like resharper where you can solve all the warnings by accepting every little things he tells you to do (sometimes I&#8217;m resharper&#8217;s slave but I like it).</p>
<p>BUT, if you really want to make it your judgment call tool, you should really stick to this diagram :</p>
<div style="text-align: center"><img src="http://i.mivi.fr/ee5c87844c14b061e7688781307b3376273d6d73.png" /></div>
<p>You can see that in this project some of the projets are in the zone of pain and the zone of uselessness. Don&#8217;t worry. In the zone of uselessness we have the WCF contracts. It&#8217;s quite normal they are totally abstract. And close to the zone of pain, we have low level libraries. So, nothing to worry about.</p>
<p>If you WANT a quick and dirty rule : If your business logic core code is in one of these two red zones, you have a problem.</p>
<p><strong>What I think it does well</strong><br />
I think it gives you a quick view of the software you&#8217;re working on : What are the main projects, classes and methods. What quality of work you should expect from it. The graphical view isn&#8217;t pretty but it gives you a good simplified view :</p>
<div style="text-align: center">
<img src="http://i.mivi.fr/380b2b6f72d30c1c6364d474364d20201923ad54.x.800.png" />
</div>
<p>And anytime you have a doubt, you just double-click on the method and it opens it in Visual Studio.</p>
<p>You have the dependency graphical view :</p>
<div style="text-align: center">
<img src="http://i.mivi.fr/420da71ae9cb3e162609ff3f302194399ff349d1.x.800.png" /></p>
<p>It doesn&#8217;t look very useful like this. But within Visual NDepend, it displays the parent and child assemblies when you move your mouse over a project :<br />
<img src="http://i.mivi.fr/3139ed7c3d9bc525e527b6e950f06c17a1a13657.x.800.png" />
</div>
<p><strong>Evolution of your project</strong><br />
NDepend also saves the results of all previous analysis and allows you to show the evolution of your product. You can see easily what methods have been modified / added / deleted from one analysis to an other. Each analysis you do is saved and can be compared to any other later. This can be done on simple .Net assembly. This will allow you to see what has been changed between two version of an assembly. And with the help of reflector, you can see precisely what has been fixed/improved.</p>
<p>You can see a pretty good example by Patrick Smacchia : <a href="http://codebetter.com/blogs/patricksmacchia/archive/2009/10/21/interesting-findings-in-the-diff-between-net-fx-v4-beta1-and-beta2.aspx">Comparison of .Net Bêta 1 and 2 with NDepend</a>.</p>
<p><strong>My thoughts</strong><br />
I think it gives you a quick and simplified view of the organization and size of a project. It&#8217;s great .Net tool, I would recommend to any company having big .Net projects. But you shouldn&#8217;t spend too much time on trying to comply with all its default CQL query checks as they are a little bit constrictive. If you do, you might want to increase the threshold values. And please take extra care before making judgment calls (it might be tempting).</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/ndepend/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inside Sharepoint</title>
		<link>http://florent.clairambault.fr/inside-sharepoint?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=inside-sharepoint</link>
		<comments>http://florent.clairambault.fr/inside-sharepoint#comments</comments>
		<pubDate>Tue, 04 Aug 2009 20:55:01 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET Reflector]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[File Disassembler]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Sharepoint 2007]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1397</guid>
		<description><![CDATA[I recently took the time to take a look inside the Microsoft.Sharepoint.dll using reflector. I&#8217;m not sure I have the right to do that. And I&#8217;m pretty sure I don&#8217;t have the right to publish any code extracted from it, so I won&#8217;t show any. Using SPSite(s) and SPWeb(s) If you do some timing on [...]]]></description>
			<content:encoded><![CDATA[<p>I recently took the time to take a look inside the Microsoft.Sharepoint.dll <a href="http://florent.clairambault.fr/net-reflector-file-disassembler">using reflector</a>. I&#8217;m <a href="http://stackoverflow.com/questions/906746/is-it-legal-to-use-reflector-to-analyze-binaries-when-the-owner-forbids-a-viewing">not sure I have the right to do that</a>. And I&#8217;m pretty sure I don&#8217;t have the right to publish any code extracted from it, so I won&#8217;t show any.</p>
<p><strong>Using SPSite(s) and SPWeb(s)</strong><br />
If you do some timing on the SPWeb creation call (SPSite.OpenWeb), you will find out that it&#8217;s freaking fast (less then 1 ms on my server). The reason is that the most heavy object, the SPRequest class, is shared among SPWebs of a SPSite. The Dispose call only &#8220;Invalidate&#8221; the SPWeb, and if this SPWeb is the owner of the SPRequest (which is SPContext.Current.Web object in most of the cases), it releases it. </p>
<p>Personnaly, I like to have something like that when I use a particular SPWeb along my code in a WebPart :</p>

<div class="wp_codebox"><table><tr id="p139715"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p1397code15"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> SPWeb _rootWeb<span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> SPWeb RootWeb <span style="color: #008000;">&#123;</span>
    get <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _rootWeb <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            _rootWeb <span style="color: #008000;">=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span><span style="color: #008000;">.</span><span style="color: #0000FF;">RootWeb</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _rootWeb <span style="color: #008000;">!=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span> <span style="color: #008000;">&#41;</span>
                _toDispose<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> _rootWeb <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>  
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> _rootWeb<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>IDisposable<span style="color: #008000;">&gt;</span> _toDispose <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>IDisposable<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnUnLoad<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span> var disp <span style="color: #0600FF; font-weight: bold;">in</span> _toDispose <span style="color: #008000;">&#41;</span>
        disp<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>But the code above won&#8217;t make you gain a 1 ms compared to this code (which is shorter and potentially safer, you don&#8217;t need to dispose everything) :</p>

<div class="wp_codebox"><table><tr id="p139716"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p1397code16"><pre class="csharp" style="font-family:monospace;">var rootWeb <span style="color: #008000;">=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Your code</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0600FF; font-weight: bold;">finally</span> <span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> rootWeb <span style="color: #008000;">!=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span> <span style="color: #008000;">&#41;</span>
         rootWeb<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>If you had to access some more indirect objects, you certainly should keep the code showed earlier. For instance to use a SuperToken Web :</p>

<div class="wp_codebox"><table><tr id="p139717"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code" id="p1397code17"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> SPSite _stSite<span style="color: #008000;">;</span>
SPSite STSite <span style="color: #008000;">&#123;</span>
    get <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _stSite <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            _stSite <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span>, SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span><span style="color: #008000;">.</span><span style="color: #0000FF;">SystemAccount</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UserToken</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _stSite <span style="color: #008000;">!=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Site</span> <span style="color: #008000;">&#41;</span>
                _toDispose<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> _stSite <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> _stSite<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> SPWeb _stWeb<span style="color: #008000;">;</span>
SPWeb STWeb <span style="color: #008000;">&#123;</span>
    get <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _stWeb <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            _stWeb <span style="color: #008000;">=</span> STSite<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenWeb</span><span style="color: #008000;">&#40;</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Url</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> _stWeb <span style="color: #008000;">!=</span> SPContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span> <span style="color: #008000;">&#41;</span>
                _toDispose<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> _stWeb <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> _stWeb<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> List<span style="color: #008000;">&lt;</span>IDisposable<span style="color: #008000;">&gt;</span> _toDispose <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>IDisposable<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnUnLoad<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span> var disp <span style="color: #0600FF; font-weight: bold;">in</span> _toDispose <span style="color: #008000;">&#41;</span>
        disp<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Here, opening these new SPSite and SPWeb takes 200 ms on my server. Making sure this only happen once per webpart (or better, per page) can really boost your performances.</p>
<p><strong>The SPRequest object</strong><br />
Well&#8230; I was very disapointed, the SPRequest object references an SPRequestInternalClass from the Microsoft.Sharepoint.Library assembly which only uses interrop COM+ methods. So, it&#8217;s basically wrapping COM+ methods. The SPRequest does a lot of exception handling and it keeps track of where (with the stacktrace) it has been created and the size of the &#8220;unmanaged stack&#8221;.</p>
<p><strong>Optimization</strong><br />
I like how they did their code. It&#8217;s pretty optimized (they even use a bunch of gotos). But sometimes there is some weird things and I don&#8217;t know if it&#8217;s the compiler&#8217;s or the developer&#8217;s fault. If you look at the code, they have an SPRequestManager.SPRequestsPerThreadWarning property, which gets (in the Registry, at &#8220;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings\LocalSPRequestWarnCount&#8221;) the max number of opened SPRequest objects opened before logging it (or 8 if this entry doesn&#8217;t exist), that takes twice the amount of code it would normaly require.</p>
<p><strong>The limit of disassembling</strong><br />
The most frustrating part is there are tons of really important methods that are obfuscated (and that .Net reflector doesn&#8217;t disassemble, it could at least give the IL code in comments). I just have :</p>

<div class="wp_codebox"><table><tr id="p139718"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1397code18"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> xxx<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// This item is obfuscated and can not be translated.</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>For instance, I really would have liked to see how works the SPList.Update() method, but it&#8217;s also obfuscated. </p>
<p><strong>You should explore it too</strong><br />
In the Microsoft.Office.Server.Search assembly, you will also find some pretty interesting things. If you look how works the standard search webparts, well you will be pretty disapointed. The advanced search uses an internal (in the C# meaning) shared object.</p>
<p>Before doing your own webpart, you should take a look at the overriden methods of some sharepoint webparts. It can show you, for instance, how to create your own toolparts. In my last project, I used a stupid text property instead of using a DropDownList in a ToolPart, I was very disappointed with myself when I discovered this.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/inside-sharepoint/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono Tools for Visual Studio : I have tested it !</title>
		<link>http://florent.clairambault.fr/mono-tools-for-visual-studio-i-have-tested-it?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mono-tools-for-visual-studio-i-have-tested-it</link>
		<comments>http://florent.clairambault.fr/mono-tools-for-visual-studio-i-have-tested-it#comments</comments>
		<pubDate>Thu, 30 Jul 2009 20:46:01 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# .Net]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1583</guid>
		<description><![CDATA[Yes, I have tested MonoVS with the version 0.2.2641 (on both client and server). I installed OpenSuse 11.1 and added the MonoVS software repository, and everything worked ! I would have prefer to get it from SVN in order to use it in my Debian hosts but the mono development team seems to have removed [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I have tested MonoVS with the version 0.2.2641 (on both client and server). I installed OpenSuse 11.1 and added the MonoVS software repository, and everything worked ! I would have prefer to get it from SVN in order to use it in my Debian hosts but the mono development team seems to have removed it from their SVN repository. </p>
<p>So, the Mono Remote Debugger for Visual Studio works, but there still some bugs. Deployment is super fast and it copies all the required DLL. </p>
<p>Remote debugging can be used (launching it is really fast too), but has some bugs, here are the ones I could find  :<br />
- On the classical mouse hover debugging popup, the expandable element &#8220;Non-public members&#8221; is always empty if available. If not available, every private member is displayed like any other public member variable.<br />
- In my first tests, the &#8220;watch&#8221; window wouldn&#8217;t allow any variable to be expanded.<br />
- If you have a variable not yet declared (but available) in the watch window and try to expand it, debugging just stops without any warning<br />
- Sometimes, when I stop debugging I get a message saying something went wrong and the debugger might be unstable<br />
- Once, after making a pause and then a stop, it totally crashed Visual Studio (but it only happened once).</p>
<p>And this is not really a bug, but unhandled exception are displayed in the dirty popup. This isn&#8217;t pretty.</p>
<p>If do &#8220;Run remotely in Mono&#8221;, it will display the Console output in the server&#8217;s console. If you do &#8220;Debug remotely in Mono&#8221;, the Console output is redirect the Debug output window.</p>
<p>This tool is still in private beta (I guess anyone has a good chance to be accepted like I was), but it can already help a lot of people. Even if you just use the Remote Running (which includes deploying the assembly), it still worth using this tool.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/mono-tools-for-visual-studio-i-have-tested-it/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net Reflector + File Disassembler</title>
		<link>http://florent.clairambault.fr/net-reflector-file-disassembler?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=net-reflector-file-disassembler</link>
		<comments>http://florent.clairambault.fr/net-reflector-file-disassembler#comments</comments>
		<pubDate>Wed, 29 Jul 2009 20:45:41 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET Reflector]]></category>
		<category><![CDATA[File Disassembler]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1357</guid>
		<description><![CDATA[.Net reflector is a really good tool. You can see the content of any assembly very easily. But it&#8217;s not really easy to see the full content of a class, or a library with it. The File Disassembler add-in is a totally crazy stuff. You can take any assembly and totally disassemble it. It even [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.red-gate.com/products/reflector/">.Net reflector</a> is a really good tool. You can see the content of any assembly very easily. But it&#8217;s not really easy to see the full content of a class, or a library with it.</p>
<p>The <a href="http://www.denisbauer.com/NETTools/FileDisassembler.aspx">File Disassembler</a> add-in is a totally crazy stuff. You can take any assembly and totally disassemble it. It even creates the .csproj so that you just have to open the project in Visual Studio. But don&#8217;t get too excited if the code is obfuscated you will get some &#8220;empty&#8221; methods with just this comment :</p>

<div class="wp_codebox"><table><tr id="p135720"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1357code20"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// This item is obfuscated and can not be translated.</span></pre></td></tr></table></div>

<p>By the way. As you can see from the .net reflector video, you can register in the context menu for any DLL and EXE assembly by executing it with the /register parameter.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/net-reflector-file-disassembler/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono Tools for Visual Studio</title>
		<link>http://florent.clairambault.fr/mono-tools-for-visual-studio?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mono-tools-for-visual-studio</link>
		<comments>http://florent.clairambault.fr/mono-tools-for-visual-studio#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:45:40 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1471</guid>
		<description><![CDATA[Just a little post for all these people who seem to think Mono is just an other short-term open-source software. I&#8217;ve used it for quite some time with a production &#8220;real time&#8221; network server, which is running for something like 6 months now, and it performs very well. I do everything on my Windows host [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little post for all these people who seem to think Mono is just an other short-term open-source software.</p>
<p>I&#8217;ve used it for quite some time with a production &#8220;real time&#8221; network server, which is running for something like 6 months now, and it performs very well. I do everything on my Windows host and then copy and launch the final app on the Linux host. But there are still two problems :</p>
<ul>
<li>Not all .Net classes are supported. WCF (the most powerfull to do two-way async/sync communication) isn&#8217;t one of them.</li>
<li>You can&#8217;t use the powerfull Visual Studio debugger and you can&#8217;t take advantage of the PDB files (as they are not compatibles with mono).</li>
</ul>
<p>Well, the Mono team has solved this second problem with their <a href="http://go-mono.com/monovs/Debug.aspx">Mono Tools for Visual Studio</a>. I have already applied twice and haven&#8217;t received any inivitation for the private mono tools tryout. But I guess it will be released to the public pretty soon (within 6 months). The mono guys are working really fast (but not as fast as the Microsoft .Net development team).</p>
<p>Sometimes people should just consider using Mono for their (web) applications. In my opinion, an ASP.Net + DataBase Linux server is faster to manage than a equivalent Windows Server. It doesn&#8217;t slow down with uptime, it doesn&#8217;t have dozens of useless services, it doesn&#8217;t require to restart for updates and real problems are way easier to diagnose.<br />
The real limitation for me are the super Microsoft APIs and tools like WCF, LinQ, SQL Server 2008 (with its Integration and Analysis services) that you can only run on Windows.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/mono-tools-for-visual-studio/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging on Sharepoint 2007</title>
		<link>http://florent.clairambault.fr/debugging-on-sharepoint-2007?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=debugging-on-sharepoint-2007</link>
		<comments>http://florent.clairambault.fr/debugging-on-sharepoint-2007#comments</comments>
		<pubDate>Sun, 26 Jul 2009 20:45:48 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Sharepoint 2007]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1361</guid>
		<description><![CDATA[Sharepoint debugging isn&#8217;t fully automated. So you should really know how to debug and diagnose your assemblies in any given situation. 1. Attaching to the process It only applies to a debugging environnement. This is the one that everybody knows (or should at least). You deploy your DLL in the GAC, restart your application pool, [...]]]></description>
			<content:encoded><![CDATA[<p>Sharepoint debugging isn&#8217;t fully automated. So you should really know how to debug and diagnose your assemblies in any given situation.</p>
<p><strong>1. Attaching to the process</strong><br />
It only applies to a debugging environnement. </p>
<p>This is the one that everybody knows (or should at least). You deploy your DLL in the GAC, restart your application pool, access your sharepoint web application in order to load the application pool and the DLL and then attach to the right w3wp.exe process (or every w3wp.exe process if you don&#8217;t really know which one to choose).</p>
<p><strong>2. Displaying where the exception happens</strong><br />
It should be used everywhere.</p>
<p>Just after deploying your DLL into the GAC, you should deploy the PDB file with it. In your exception management code, you have the exact line where the exception was thrown. Wether your users report it (with the exact line number), you see it in the logs or you have an automatic reporting system, the point is : You will know exactly where it fails.</p>
<p>If you have a WSP deployment method, you will have :</p>

<div class="wp_codebox"><table><tr id="p136125"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1361code25"><pre class="batch" style="font-family:monospace;">rem This WSP File contains the MyCorp.MyApp.MyLib library with the 0x123456789 public key token
stsadm -o addsolution -filename %WSPFILE%</pre></td></tr></table></div>

<p>If you have a DLL deployment method, you will have :</p>

<div class="wp_codebox"><table><tr id="p136126"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1361code26"><pre class="batch" style="font-family:monospace;">gacutil /if GAC\MyCorp.MyApp.MyLib.dll</pre></td></tr></table></div>

<p>Either way, you need to add the PDB with this command :</p>

<div class="wp_codebox"><table><tr id="p136127"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1361code27"><pre class="batch" style="font-family:monospace;">subst X: c:\windows\assembly\gac_msil
copy GAC\MyCorp.MyApp.MyLib.pdb X:\MyCorp.MyApp.MyLib\1.0.0.0_123456789\</pre></td></tr></table></div>

<p>If you&#8217;re not willing to give away your PDB file (it contains you complete code source and consumes space), you can find out where you app exactly failed just from the offset of the stacktrace reported by Sharepoint (with the <a href="http://blog.thekid.me.uk/archive/2007/02/15/a-solution-to-quot-an-unexpected-error-has-occurred-quot-in-wss-v3.aspx">CustomError=&#8221;Off&#8221; and StackTrace=&#8221;true&#8221;</a> in the web.config). Some people explain how to do it <a href="http://stackoverflow.com/questions/1037925/recreate-stack-trace-with-line-numbers-from-user-bug-report-in-net">here</a>. Answer &#8220;3&#8243; allows you to get the IL offset like ASP.Net does in its (non customized) error page.</p>
<p><strong>3. Launching the debugger from the code</strong><br />
This is very useful for features deactivation/uninstallation/installation/activation code.</p>
<p>You just have to add this line when you want to ask the debugger to attach to the assembly.</p>

<div class="wp_codebox"><table><tr id="p136128"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1361code28"><pre class="csharp" style="font-family:monospace;">Debugger<span style="color: #008000;">.</span><span style="color: #0000FF;">Launch</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p><strong>4. Other options</strong><br />
<a href="http://blog.thekid.me.uk/archive/2007/07/25/debugging-tips-for-sharepoint-and-wss-exceptions.aspx">This article</a> focuses on hardcore problems : Problems that occur inside sharepoint or weird problem that only appear on your production servers.</p>
<p>The WinDBG method seems a little bit overkill to me. Mostly because you still can&#8217;t analyze the state of the local variables with our current tools (but I hope it will be made available in a short future).</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/debugging-on-sharepoint-2007/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharepoint : SPWebConfigModification</title>
		<link>http://florent.clairambault.fr/sharepoint-spwebconfigmodification?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sharepoint-spwebconfigmodification</link>
		<comments>http://florent.clairambault.fr/sharepoint-spwebconfigmodification#comments</comments>
		<pubDate>Sun, 19 Jul 2009 08:30:10 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[binding redirect]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Sharepoint 2007]]></category>
		<category><![CDATA[SPWebConfigModification]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1265</guid>
		<description><![CDATA[I&#8217;ve seen lots of Sharepoint software having an installation manual of at least 20 pages (sometimes 60). Most of the operations they describe could be fully automated. And these software were made by freaking big companies. They should be ashamed of themselves. Maybe they just forgot that computer science is all about saving some time [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen lots of Sharepoint software having an installation manual of at least 20 pages (sometimes 60). Most of the operations they describe could be fully automated. And these software were made by freaking big companies. They should be ashamed of themselves. Maybe they just forgot that computer science is all about saving some time (and not only making money).</p>
<p>One good example is MOSS Faceted search 2.5 (I haven&#8217;t tested the 3.0). It takes at least 40 minutes to uninstall this crap. Why isn&#8217;t it just ONE WSP or at least one BAT file launching the WSP installation and the other steps ? Is there any real reason for that ?</p>
<p>The SPWebConfigModification solves this web.config modification problem. It&#8217;s a pretty interesting feature of Sharepoint. You can edit the web.config file without any complex XML parsing. It doesn&#8217;t even matter that you add XML or not. The SPWebConfigModification class manages your add/mod/del operations easily. The only restriction is that you have to add your first configuration elements using the SPWebConfigModification.  You cannot modify existing elements this way.</p>

<div class="wp_codebox"><table><tr id="p126531"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code" id="p1265code31"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Source : http://sharethelearning.blogspot.com/2008/01/adding-bindingredirect-to-webconfig.html</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> AddBindingRedirect<span style="color: #008000;">&#40;</span> SPWebApplication webApp, <span style="color: #6666cc; font-weight: bold;">string</span> libraryName, <span style="color: #6666cc; font-weight: bold;">string</span> libraryPublicToken, <span style="color: #6666cc; font-weight: bold;">string</span> oldVersion, <span style="color: #6666cc; font-weight: bold;">string</span> newVersion <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	var ownerName <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;BindingRedirect.{0}&quot;</span>, libraryName <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #008000;">&#123;</span> <span style="color: #008080; font-style: italic;">// We delete last bindingRedirect</span>
&nbsp;
		var list <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> List<span style="color: #008000;">&lt;</span>SPWebConfigModification<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span> SPWebConfigModification mod <span style="color: #0600FF; font-weight: bold;">in</span> webApp<span style="color: #008000;">.</span><span style="color: #0000FF;">WebConfigModifications</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			list<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> mod <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span>
&nbsp;
		<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span> var mod <span style="color: #0600FF; font-weight: bold;">in</span> list <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span> mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Owner</span> <span style="color: #008000;">==</span> ownerName <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				LoggerCommon<span style="color: #008000;">.</span><span style="color: #0000FF;">LogVerbose</span><span style="color: #008000;">&#40;</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;Suppression de la redirection : <span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span>, mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
				webApp<span style="color: #008000;">.</span><span style="color: #0000FF;">WebConfigModifications</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Remove</span><span style="color: #008000;">&#40;</span> mod <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #008000;">&#123;</span> <span style="color: #008080; font-style: italic;">// We add our redirection</span>
		<span style="color: #6666cc; font-weight: bold;">String</span> path <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;configuration/runtime/*[namespace-uri()='urn:schemas-microsoft-com:asm.v1' and local-name()='assemblyBinding']&quot;</span><span style="color: #008000;">;</span>
		<span style="color: #6666cc; font-weight: bold;">String</span> name <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">&quot;*[namespace-uri()='urn:schemas-microsoft-com:asm.v1' and local-name()='dependentAssembly']/*[namespace-uri()='urn:schemas-microsoft-com:asm.v1' and local-name()='assemblyIdentity'][@name='{0}']/parent::*&quot;</span>, libraryName <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #6666cc; font-weight: bold;">String</span> webConfigValue <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">String</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span> <span style="color: #666666;">@&quot;
	&lt;dependentAssembly&gt;
		&lt;!-- Added automatically at {4} --&gt;
		&lt;assemblyIdentity name='{0}' publicKeyToken='{1}' culture='neutral' /&gt;
		&lt;bindingRedirect oldVersion='{2}' newVersion='{3}' /&gt;
	&lt;/dependentAssembly&gt;
&quot;</span>, libraryName, libraryPublicToken, oldVersion, newVersion, DateTime<span style="color: #008000;">.</span><span style="color: #0000FF;">Now</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		SPWebConfigModification mod <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPWebConfigModification<span style="color: #008000;">&#40;</span> name, path <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> webConfigValue<span style="color: #008000;">;</span>
		mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Owner</span> <span style="color: #008000;">=</span> ownerName<span style="color: #008000;">;</span>
		mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Sequence</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
		mod<span style="color: #008000;">.</span><span style="color: #0000FF;">Type</span> <span style="color: #008000;">=</span> SPWebConfigModification<span style="color: #008000;">.</span><span style="color: #0000FF;">SPWebConfigModificationType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnsureChildNode</span><span style="color: #008000;">;</span>
&nbsp;
		webApp<span style="color: #008000;">.</span><span style="color: #0000FF;">WebConfigModifications</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span> mod <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #008000;">&#123;</span> <span style="color: #008080; font-style: italic;">// We save our changes</span>
		webApp<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		SPFarm<span style="color: #008000;">.</span><span style="color: #0000FF;">Local</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Services</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetValue</span><span style="color: #008000;">&lt;</span>SPWebService<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ApplyWebConfigModifications</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>If you do a binding redirect from 1.0.0.0 to 1.0.1.0 and your .webpart file references the 1.0.0.0 version, sharepoint will store your webpart as referencing the 1.0.1.0 assembly (and not 1.0.0.0 as you told him). So if you then chose to change the binding redirect from 1.0.0.0 to 1.0.2.0, without redirecting 1.0.1.0 to 1.0.2.0, your webpart will still be the 1.0.1.0 version.  </p>
<p>I haven&#8217;t tested this for event receivers, but the way they are registered (Sharepoint doesn&#8217;t check the assembly you add to the event receivers of a list), I would guess Sharepoint doesn&#8217;t change the assembly version.</p>
<p>To solve this webpart updating problem, you can use ranged binding redirect (.Net rules) :</p>

<div class="wp_codebox"><table><tr id="p126532"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1265code32"><pre class="csharp" style="font-family:monospace;">var site <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SPSite<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://localhost&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
AddBindingRedirect<span style="color: #008000;">&#40;</span> site<span style="color: #008000;">.</span><span style="color: #0000FF;">WebApplication</span>, <span style="color: #666666;">&quot;MyCorp.MyApp.MyLib&quot;</span>, <span style="color: #666666;">&quot;0x123456789&quot;</span>, <span style="color: #666666;">&quot;1.0.0.0-1.0.3.5&quot;</span>, <span style="color: #666666;">&quot;1.0.3.5&quot;</span> <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>That means that any webpart using a previous version of the &#8220;MyCorp.MyApp.MyLib&#8221; assembly between 1.0.0.0 and 1.0.3.5 will be redirected to the 1.0.3.5 version.</p>
<p>If your assembly contains page code-behind classes, you should take care of updating the aspx files as well.</p>
<p><u>Reference :</u>
<ul>
<li><a href="http://sharethelearning.blogspot.com/2008/01/adding-bindingredirect-to-webconfig.html">The original code</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/sharepoint-spwebconfigmodification/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GAC Download Cache</title>
		<link>http://florent.clairambault.fr/gac-download-cache?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=gac-download-cache</link>
		<comments>http://florent.clairambault.fr/gac-download-cache#comments</comments>
		<pubDate>Thu, 25 Jun 2009 20:55:40 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[GAC]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=411</guid>
		<description><![CDATA[There&#8217;s one little feature that you must have totally forgotten in the .Net framework, but it is great. We can tell our apps to download automatically some DLL we would expect to be in the GAC and that are not. This is one freaking great feature. Instead of forcing your users to install the librairies [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s one little feature that you must have totally forgotten in the .Net framework, but it is great.</p>
<p>We can tell our apps to download automatically some DLL we would expect to be in the GAC and that are not. This is one freaking great feature. Instead of forcing your users to install the librairies in their GAC or including the libraries with your applications, you can specify the URL(s) of the DLL(s) your software application depends on. When you launch your program, the .Net framework program will download them automatically if they&#8217;re not already in the GAC download cache.</p>
<p>You just have to add something like that in the file &#8220;yourapp.exe.config&#8221; in the same directory of your &#8220;yourapp.exe&#8221; application.</p>

<div class="wp_codebox"><table><tr id="p41134"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p411code34"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;runtime<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblyBinding</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:asm.v1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependentAssembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assemblyIdentity</span></span>
<span style="color: #009900;">          <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Lib&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">publicKeyToken</span>=<span style="color: #ff0000;">&quot;9b52b2ba78ecf379&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">culture</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;codeBase</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0.0.0&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://www.yourserver.com/dw-assemblies/Lib.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependentAssembly<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/assemblyBinding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/runtime<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This avoids to :</p>
<ul>
<li>Install something in the GAC</li>
<li>Package the required assembly with your software</li>
<li>Download or copy the required assemblys for each of your software</li>
<li>Clean your old assemblys once your don&#8217;t require them</li>
</ul>
<p>You can see the content of your download cache by typing :</p>
<pre lang="cmd" style="color: #fff; background-color: #000; font-weight: bold">
# gacutil.exe /ldl
</pre>
<p>And you can clear your download cache by typing :</p>
<pre lang="cmd" style="color: #fff; background-color: #000; font-weight: bold">
# gacutil.exe /cdl
</pre>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/gac-download-cache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.482 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 16:36:00 -->
