<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><id>tag:blogger.com,1999:blog-6908201609754153877</id><updated>2009-10-16T15:10:33.025+02:00</updated><title type="text">Developing dotnet architect</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://dhvik.blogspot.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default?start-index=26&amp;max-results=25" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/DevelopingDotnetArchitect" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-3663095176049954080</id><published>2009-10-16T14:46:00.007+02:00</published><updated>2009-10-16T15:10:33.031+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CCNET" /><title type="text">Converting word doc to pdf in CruiseControl.Net</title><content type="html">Today I needed to automate the process where we create PDF files out of our client documentation in Microsoft Word format. Since up to now we have done it manually by opening the document and printing to a installed PDF printer. Quite tedious work.&lt;br /&gt;After some searching I start to realize that there are &lt;span style="font-weight: bold;"&gt;many &lt;/span&gt;PDF creators around; and most of them uses Ms word and prints using a pdf printer (just as we use to do, but by automation).&lt;br /&gt;The problem is that I don't want to install printers or the Ms Office package on our build server (if I can avoid it). Another wish is that the solution should be free and open source.&lt;br /&gt;So finally I stumbled upon &lt;a href="http://www.togaware.com/linux/survivor/Convert_MS_Word.html"&gt;this article&lt;/a&gt; by Graham J. Williams that uses &lt;a href="http://www.openoffice.org/"&gt;OpenOffice.org&lt;/a&gt; to do the conversion and a custom macro to allow the conversion to be called from the commandline.&lt;br /&gt;&lt;pre class="basic:nocontrols:nogutter" name="code"&gt;REM  *****  BASIC  *****&lt;br /&gt;&lt;br /&gt;Sub ConvertWordToPDF(cFile)&lt;br /&gt;cURL = ConvertToURL(cFile)&lt;br /&gt;&lt;br /&gt;' Open the document.&lt;br /&gt;' Just blindly assume that the document is of a type that OOo will&lt;br /&gt;'  correctly recognize and open -- without specifying an import filter.&lt;br /&gt;oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))&lt;br /&gt;&lt;br /&gt;cFile = Left(cFile, InStr((Len(cFile)-6),cFile,".")) + "pdf"&lt;br /&gt;cURL = ConvertToURL(cFile)&lt;br /&gt;&lt;br /&gt;' Save the document using a filter.&lt;br /&gt;oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))&lt;br /&gt;&lt;br /&gt;oDoc.close(True)&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue&lt;br /&gt;Dim oPropertyValue As New com.sun.star.beans.PropertyValue&lt;br /&gt;If Not IsMissing( cName ) Then&lt;br /&gt;   oPropertyValue.Name = cName&lt;br /&gt;EndIf&lt;br /&gt;If Not IsMissing( uValue ) Then&lt;br /&gt;   oPropertyValue.Value = uValue&lt;br /&gt;EndIf&lt;br /&gt;MakePropertyValue() = oPropertyValue&lt;br /&gt;End Function&lt;br /&gt;&lt;/pre&gt;I modified it a bit to allow correct handing of extensions.&lt;br /&gt;To call it from a windows command prompt just enter&lt;br /&gt;&lt;pre class="basic:nocontrols:nogutter" name="code"&gt;c:\program files\OpenOffice.Org 3\Program\swriter.exe -invisible "macro:///Standard.Module1.ConvertWordToPDF(c:\temp\My word document.doc)"&lt;br /&gt;&lt;/pre&gt;I incorporated it in our cruisecontrol.net nant scripts so all solutions that needs pdf conversions in the build chain can have it.&lt;br /&gt;Great!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-3663095176049954080?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=EDhEtkA_CFI:DnywY385znA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=EDhEtkA_CFI:DnywY385znA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=EDhEtkA_CFI:DnywY385znA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/3663095176049954080/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/10/converting-word-doc-to-pdf-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/3663095176049954080" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/3663095176049954080" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/EDhEtkA_CFI/converting-word-doc-to-pdf-in.html" title="Converting word doc to pdf in CruiseControl.Net" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/10/converting-word-doc-to-pdf-in.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-8454250546558814303</id><published>2009-08-06T00:10:00.006+02:00</published><updated>2009-08-06T00:20:04.881+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><category scheme="http://www.blogger.com/atom/ns#" term="Macros" /><title type="text">Bugfix for Documentator Macros (VB)</title><content type="html">&lt;div&gt;A small bug fix for the auto documentation feature for VB.Net.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Thanks for the report Sam; what has it been, nearly 2 years since you reported the bug finally I've come about... ( You said it wasn't urgent... you'll probably reconsider next time ;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;When autodocumenting a Sub or function that is connected to an event, an error occurs.&lt;/div&gt;&lt;br /&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;The fix is included in version 2.5.3.0 that can be downloaded from &lt;a href="http://dan.meridium.se/DocumentatorMacros/v2.5.3.0/Meridium.rar"&gt;http://dan.meridium.se/DocumentatorMacros/v2.5.3.0/Meridium.rar&lt;/a&gt;.&lt;/div&gt;&lt;br /&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;(For more information about the Documentator Macros, see &lt;a href="http://www.codeproject.com/KB/cs/documentatormacros.aspx"&gt;http://www.codeproject.com/KB/cs/documentatormacros.aspx&lt;/a&gt; )&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-8454250546558814303?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=J7luaxUzEg0:1TQlI4uE5-g:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=J7luaxUzEg0:1TQlI4uE5-g:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=J7luaxUzEg0:1TQlI4uE5-g:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/8454250546558814303/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/08/bugfix-for-documentator-macros-vb.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8454250546558814303" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8454250546558814303" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/J7luaxUzEg0/bugfix-for-documentator-macros-vb.html" title="Bugfix for Documentator Macros (VB)" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/08/bugfix-for-documentator-macros-vb.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-2718870077747005393</id><published>2009-07-27T21:47:00.011+02:00</published><updated>2009-07-28T00:02:40.846+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">Mvc for Winforms - Mapping the View event to the Controller action Part III</title><content type="html">Long time since part I and II were posted, but I've been quite busy lately so I haven't found time (or prioritized) to write the last part, but here we are :)&lt;br /&gt;&lt;br /&gt;To recap, in &lt;a href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to.html"&gt;part I&lt;/a&gt; I explained about the background of the issue, that I was writing a small winforms MVC framework. The goal of the framework was to be able to instruct the controller to listen to a component in the view and when the component called an event, a specific method would be called.&lt;br /&gt;For example, the call below would register the click event from the saveButton&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;Controller.RegisterAction(saveButton,"Save");&lt;br /&gt;&lt;/pre&gt;(in later editions I have also added support for lamda expressions instead of method names, and thus almost abandoned the previous)&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;Controller.RegisterAction(rotateRightButton,() =&gt; Controller.Rotate(90));&lt;br /&gt;Controller.RegisterAction(rotateLeftButton,() =&gt; Controller.Rotate(-90));&lt;br /&gt;&lt;/pre&gt;In &lt;a href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to_02.html"&gt;part II&lt;/a&gt; I wrote about how find and listen to the event of the component.&lt;br /&gt;In this section I will explain how I call the method.&lt;br /&gt;&lt;br /&gt;What we ended with in the last post was that we had registered the controllers event to call the ExecuteAction method of the Controller class.&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;public void ExecuteAction(object source, object eventArgs, ActionData actionData)&lt;br /&gt;&lt;/pre&gt; or in the latter case using lambda expressions (or action)&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;public void ExecuteAction(object source, object eventArgs, Action action)&lt;br /&gt;&lt;/pre&gt; In this case the Action is the easiest to implement. Just call the Invoke method of the Action instance and you are done.&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;public void ExecuteAction(object source, object eventArgs, Action action) {&lt;br /&gt;   action.Invoke();&lt;br /&gt;}&lt;/pre&gt;&lt;span style="font-weight: bold;"&gt;The no Action ExecuteAction method (almost abandoned way )&lt;/span&gt;&lt;br /&gt;The ActionData variant is somewhat more tedious but this is how ASP.NET MVC does it.&lt;br /&gt;First we need to find the method to call. The ActionData contains the name of the method. We now needs to find the method of the controller that matches that name. MVC for ASP.NET uses the ActionSelectorClass. The ActionSelectorClass is responsible for retrieving the MethodInfo for an action by passing in the name of the action. It support action aliases and other things so look it up for a great example.&lt;br /&gt;In short it uses reflection to get all methods, filters out irrelevant methods and returns the one that matches the name.&lt;br /&gt;Example (really shortened example, lookup ActionSelectorClass in the ASP.NET MVC framework for a complete example.)&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;//get all methods&lt;br /&gt;MethodInfo[] array = ControllerType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance);&lt;br /&gt;//convert to a dictionary&lt;br /&gt;ILookup&amp;lt;string,MethodInfo&amp;gt; methodLookup = array.ToLookup(method =&gt; method.Name, StringComparer.OrdinalIgnoreCase);&lt;br /&gt;//return the matching MethodInfo&lt;br /&gt;MethodInfo action = methodLookup[actionName];&lt;br /&gt;&lt;/pre&gt;Now we have the MethodInfo to invoke, only to calculate the parameters to pass to the method is left.&lt;br /&gt;&lt;br /&gt;The action is invoked using the Invoke method of the MethodInfo class and we need to pass the instance to invoke it on (the controller instance) and the object array containing the parameters to pass to the method/action.&lt;br /&gt;Example&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;action.Invoke(controller,parameterValues);&lt;/pre&gt;If the action don't have any parameters we just pass null, but if we do have parameters we need to assign values for them.&lt;br /&gt;Remember: we  wanted to be able to register the call&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;Controller.RegisterAction(createBoldTextButton, "CreateText", new {name="Bold", type=4}); &lt;/pre&gt;To call the action method&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;public void CreateText(string name, int type) {...}  &lt;/pre&gt;using the "Bold" as value for the name parameter and 4 as value for the type parameter.&lt;br /&gt;&lt;br /&gt;To succeed with this we need to do some parsing.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Iterate all parameters of the method info.&lt;/li&gt;&lt;li&gt;Handle special cases (like if the parameter is named source and is of type object, then the source value from the event handler method should be passed).&lt;/li&gt;&lt;li&gt;Find a property with a matching name from the value object passed in the RegisterAction.&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Iterate all parameters of the method info&lt;/span&gt;&lt;br /&gt;Using reflection it's easy to find the parameters.&lt;br /&gt;&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;List&amp;lt;object&amp;gt; objects = new List&amp;lt;object&amp;gt;();&lt;br /&gt;foreach (ParameterInfo info in method.GetParameters()) {              &lt;br /&gt;  objects.Add(GetParameterValue(info));&lt;br /&gt;}&lt;br /&gt;return objects.ToArray();&lt;/pre&gt;&lt;span style="font-weight: bold;"&gt;Handle special cases&lt;/span&gt;&lt;br /&gt;The GetParameterValue method will return the value to pass to the supplied ParameterInfo. In some cases the value to be passed as parameter is not any of the values passed to the values parameter (in the RegisterAction method), like for example, if one would need to get the EventArgs or source parameter passed from the event component, then we would need to handle them. (other customizations can be done here, this is an example)&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;Type parameterType = parameterInfo.ParameterType;&lt;br /&gt;string parameterName = parameterInfo.Name;&lt;br /&gt;&lt;br /&gt;//handle eventArgs and source parameters&lt;br /&gt;if (string.Equals(parameterName, "e", StringComparison.OrdinalIgnoreCase) &amp;amp;&amp;amp; _eventArgs != null &amp;amp;&amp;amp; parameterType.IsAssignableFrom(_eventArgs.GetType()))&lt;br /&gt;  return _eventArgs;&lt;br /&gt;if (string.Equals(parameterName, "source", StringComparison.OrdinalIgnoreCase)&amp;amp;&amp;amp; parameterType.Equals(typeof(object)))&lt;br /&gt;  return _source;&lt;br /&gt;&lt;br /&gt;//parse the values object&lt;br /&gt;return GetValuesValue(parameterType, parameterName);&lt;/pre&gt;Find a matching property of the value object&lt;br /&gt;At last we would try to find a matching property of the value object that matches the parameter type and name. (First we check that the parameter don't matches the whole value object)&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;//if we don't have a value, return null&lt;br /&gt;if (ValueType == null)&lt;br /&gt;  return null;&lt;br /&gt;//if the value is matching, use it as value&lt;br /&gt;if (type.Equals(ValueType))&lt;br /&gt;  return _actionData.Values;&lt;br /&gt;PropertyInfo[] valueProperties= ValueType.GetProperties();&lt;br /&gt;//if the value don't have any properties, return null&lt;br /&gt;if (valueProperties.Length == 0)&lt;br /&gt;  return null;&lt;br /&gt;//find matching property&lt;br /&gt;PropertyInfo[] possibleMatches = valueProperties&lt;br /&gt;     .Where(p =&gt; string.Equals(name, p.Name, StringComparison.OrdinalIgnoreCase)&lt;br /&gt;            &amp;amp;&amp;amp; type.IsAssignableFrom(p.PropertyType))&lt;br /&gt;     .ToArray();&lt;br /&gt;if (possibleMatches == null || possibleMatches.Length == 0)&lt;br /&gt;  return null;&lt;br /&gt;if (possibleMatches.Length &gt; 1)&lt;br /&gt;  throw new AmbiguousMatchException(string.Format("The value collection contains ambigous match values for the parameter {0} {1}", type, name));&lt;br /&gt;return possibleMatches[0].GetValue(_actionData.Values, null);&lt;br /&gt;&lt;/pre&gt;Ok, so now we can invoke the method with our array of parameters. (as I said, a bit tedious).&lt;br /&gt;If we compare the two variants,&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;Controller.RegisterAction(createBoldTextButton, "CreateText", new {name="Bold", type=4});&lt;br /&gt;Controller.RegisterAction(createBoldTextButton, ()=&gt; Controller.CreateText("Bold", 4);&lt;br /&gt;&lt;/pre&gt;you understand why I have abandoned this last variant and only uses Actions/lambda functions.&lt;br /&gt;The tedious method can still be used if you want to lift the connection between view and controller to a configuration layer. Then the Action method will be hard to implement.&lt;br /&gt;&lt;br /&gt;That sums up this last part of my WinForms MVC framework lessons and experiences. Hope that you learned something.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-2718870077747005393?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=kwJF6artvLo:ZW-WovmQRIQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=kwJF6artvLo:ZW-WovmQRIQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=kwJF6artvLo:ZW-WovmQRIQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/2718870077747005393/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/07/mvc-for-winforms-mapping-view-event-to.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/2718870077747005393" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/2718870077747005393" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/kwJF6artvLo/mvc-for-winforms-mapping-view-event-to.html" title="Mvc for Winforms - Mapping the View event to the Controller action Part III" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/07/mvc-for-winforms-mapping-view-event-to.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-4030078708965151168</id><published>2009-06-24T11:40:00.009+02:00</published><updated>2009-06-26T07:28:45.708+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint" /><title type="text">The start address &lt;https://newhostname.domain.com&gt; cannot be crawled</title><content type="html">Have a SharePoint site on one of our servers and have lately added a new hostname to that server to access a new site collection. I started getting a lot of entries in the eventlog using event id 2436 stating:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;The start address &amp;lt;https://newhostname.domain.com&amp;gt; cannot be crawled.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Context: Application 'Search index file on the search server', Catalog 'Search'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Details:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Access is denied. Check that the Default Content Access Account has access to this content, or add a crawl rule to crawl this content. (0x80041205)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another symptom on this error is that if you open a web browser on the server itself and try to navigate to the url, you'll only get an authentication dialog (symptom on a 401 error).&lt;br /&gt;&lt;br /&gt;After a bit of searching I found a solution that I recognized. The following kb article &lt;a href="http://support.microsoft.com/kb/971382"&gt;http://support.microsoft.com/kb/971382&lt;/a&gt; provided the solution to add the new hostname to the registry key &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\MSV1_0\BackConnectionHostNames &lt;/span&gt;&lt;/span&gt; .&lt;br /&gt;&lt;br /&gt;When I started regedit I found that the key already existed and a couple of hostnames already was present. It seems that I had implemented this fix before.&lt;br /&gt;Better to write a post about it so I don't forget it in the future :)&lt;br /&gt;&lt;br /&gt;Ps. Don't forget to restart the server after applying the registry change. Ds.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-4030078708965151168?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=bmDDfAtxFC4:6cka8LUU64E:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=bmDDfAtxFC4:6cka8LUU64E:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=bmDDfAtxFC4:6cka8LUU64E:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/4030078708965151168/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/06/start-address-cannot-be-crawled.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/4030078708965151168" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/4030078708965151168" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/bmDDfAtxFC4/start-address-cannot-be-crawled.html" title="The start address &amp;lt;https://newhostname.domain.com&amp;gt; cannot be crawled" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/06/start-address-cannot-be-crawled.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-5960759059021408684</id><published>2009-06-24T07:26:00.005+02:00</published><updated>2009-09-28T06:10:43.354+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tfs" /><category scheme="http://www.blogger.com/atom/ns#" term="WorkItemQueries" /><title type="text">Export and Import Work item queries in TFS projects</title><content type="html">I have lately been introducing new WorkItemTypes in our TFS project to handle tests and support cases. With those new types the need for modifying the queries in the current projects was necessary. To modify a query I could have opened them in visual studio and saved them to disk and then saved them individually to each project. Since we are getting a lot of projects (60+) this would be a quite tedious task to update 10+ queries in each project individually.&lt;br /&gt;To solve this administrative plague I  wrote a small commandline program that allows you to export and import queries from a project.&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;To list all queries in a project&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;TFSQueryUtil.exe /t https://tfsserver.domain.com:8143 /p "My Tfs Project"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will list every Work Item Query by Scope, Name and description&lt;br /&gt;&lt;br /&gt;To export all queries to the current folder&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;TFSQueryUtil.exe /t https://tfsserver.domain.com:8143 /p "My Tfs Project" /o Export /q *&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will export each query using the name of the query (plus the .wiq extension) as name of the exported file. If you want to only export one query, use the example below.&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;TFSQueryUtil.exe /t https://tfsserver.domain.com:8143 /p "My Tfs Project" /o Export /q "My query"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To import all *.wiq files to a project as Team queries&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;TFSQueryUtil.exe /t https://tfsserver.domain.com:8143 /p "My Tfs Project" /o Import /f *.wiq /qs Public&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This command will use the filename (without the .wiq extension) as name for the imported query.&lt;br /&gt;You can also specify a Description of the query by using the /qd switch (best for use with one query imports)&lt;br /&gt;&lt;br /&gt;The format of the wiq files follows the &lt;a href="http://msdn.microsoft.com/en-us/library/aa721763.aspx"&gt;WorkItemQuery schema&lt;/a&gt; but since the schema only includes the query and no meta data (like name, scope or description) this has to be provided as parameter switches... (Perhaps something to fix in TFS 2010)&lt;br /&gt;&lt;br /&gt;If you need more help add the /? parameter.&lt;br /&gt;&lt;br /&gt;I haven't released the program as open source but feel free to use it if you have need for it.&lt;br /&gt;Can be downloaded from &lt;a href="http://dan.meridium.se/TfsQueryUtil.rar"&gt;http://dan.meridium.se/TfsQueryUtil.rar&lt;/a&gt;&lt;br /&gt;To use it you need to have Team Foundation Explorer 2008 installed. (needs the tfs dlls in the GAC).&lt;br /&gt;&lt;br /&gt;2009-09-28 Update; small bugfix&lt;br /&gt;* Now writes xml files as utf-8 (was an in consequence between xml notation and file encoding)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-5960759059021408684?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=xVOOVehhrI4:K4tyu9ffp2A:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=xVOOVehhrI4:K4tyu9ffp2A:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=xVOOVehhrI4:K4tyu9ffp2A:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/5960759059021408684/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/06/handling-work-item-queries.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5960759059021408684" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5960759059021408684" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/xVOOVehhrI4/handling-work-item-queries.html" title="Export and Import Work item queries in TFS projects" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/06/handling-work-item-queries.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-3598932492597013336</id><published>2009-05-05T14:27:00.005+02:00</published><updated>2009-05-05T15:50:36.346+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><category scheme="http://www.blogger.com/atom/ns#" term="Macros" /><title type="text">New version of DocumentatorMacros</title><content type="html">Long time since last version was released officially... (almost two years), time to make a change.&lt;br /&gt;New version can be downloaded from &lt;a href="http://dan.meridium.se/DocumentatorMacros/v2.5.2.0/Meridium.rar"&gt;http://dan.meridium.se/DocumentatorMacros/v2.5.2.0/Meridium.rar&lt;/a&gt;&lt;br /&gt;(For more information about the Documentator Macros, see &lt;a href="http://www.codeproject.com/KB/cs/documentatormacros.aspx"&gt;http://www.codeproject.com/KB/cs/documentatormacros.aspx&lt;/a&gt; )&lt;br /&gt;&lt;br /&gt;New version contains some news:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Contains support for Resharper 4.5, Visual studio 2008 and some minor changes.&lt;/p&gt;&lt;p&gt;Enhancements /Bugfixes&lt;/p&gt;&lt;ul&gt;&lt;li&gt;No longer enters wrong type of linefeeds when applying some functions&lt;/li&gt;&lt;li&gt;PasteTemplate &lt;ul&gt;&lt;li&gt;now indents correctly&lt;/li&gt;&lt;li&gt;Handles static events&lt;/li&gt;&lt;li&gt;Handles new, virtual, override keywords when converting fields-&gt;property&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;DocumentThis - Now autodocuments thrown exceptions&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-3598932492597013336?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=zJEQGNloERs:5OHFRCCdrtY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=zJEQGNloERs:5OHFRCCdrtY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=zJEQGNloERs:5OHFRCCdrtY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/3598932492597013336/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/05/new-version-of-documentatormacros.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/3598932492597013336" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/3598932492597013336" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/zJEQGNloERs/new-version-of-documentatormacros.html" title="New version of DocumentatorMacros" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/05/new-version-of-documentatormacros.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-1140612338907618620</id><published>2009-05-04T13:31:00.008+02:00</published><updated>2009-05-05T15:52:13.442+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Linq" /><category scheme="http://www.blogger.com/atom/ns#" term="Lambda" /><title type="text">AssemblyName.GetPublicKeyToken() ToString using lambda</title><content type="html">I was searching for a convenient way to get the public key token from a signed assembly and present it in an ordinary string style that is found in all FQ assembly names. The problem is that the GetPublicKeyToken() method from the Assembly type returns a byte array and using ToString() isn’t that great.&lt;br /&gt;&lt;br /&gt;I searched the net a bit and all I found was examples on how to do it with a loop and using ToString(”x2”) on every byte, or even more horrible, indexing the 8 bytes by hand...&lt;br /&gt;But if I use a linq/lambda expression, this could be a nice one-liner? ’aye?!&lt;br /&gt;&lt;br /&gt;Ok, first convert the byte array to a string array&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;GetPublicKeyToken().Select(x=&gt;x.ToString(”x2”))&lt;/pre&gt;Then aggregate (i was trying the concat first, but that didn’t make any sense) to a single string.&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;.Aggregate((x, y) =&gt; x + y)&lt;/pre&gt;With some error handling this boils down to the following method.&lt;br /&gt;&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;#region public static string GetAssemblyPublickKeyToken(Assembly assembly)&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Gets the public key token of the supplied argument&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="assembly"&amp;gt;The &amp;lt;see cref="Assembly"&amp;gt;to get the public key token for&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;/// &amp;lt;exception cref="ArgumentNullException"&amp;gt;If &amp;lt;paramref name="assembly"&amp;gt;is null.&amp;lt;/exception&amp;gt;&lt;br /&gt;public static string GetAssemblyPublickKeyToken(Assembly assembly) {&lt;br /&gt;    if (assembly == null) {&lt;br /&gt;        throw new ArgumentNullException("assembly");&lt;br /&gt;    }&lt;br /&gt;    byte[] token = assembly.GetName().GetPublicKeyToken();&lt;br /&gt;    if(token == null token.Length==0)&lt;br /&gt;        return null;&lt;br /&gt;    return token.Select(x =&amp;gt; x.ToString("x2")).Aggregate((x, y) =&amp;gt; x + y);&lt;br /&gt;}&lt;br /&gt;#endregion&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-1140612338907618620?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=_U_qZsChk0M:vMfB-dxUOWw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=_U_qZsChk0M:vMfB-dxUOWw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=_U_qZsChk0M:vMfB-dxUOWw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/1140612338907618620/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/05/assemblynamegetpublickeytoken-tostring.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/1140612338907618620" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/1140612338907618620" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/_U_qZsChk0M/assemblynamegetpublickeytoken-tostring.html" title="AssemblyName.GetPublicKeyToken() ToString using lambda" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/05/assemblynamegetpublickeytoken-tostring.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-5015030584530540449</id><published>2009-01-21T15:17:00.008+01:00</published><updated>2009-01-21T15:42:57.673+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title type="text">RadioButton helper and label</title><content type="html">When using Mvc (beta) and rendering RadioButtons using the HtmlHelper they are rendered without any text or description. The label tag is used for this but is not rendered by the RadionButtons method.&lt;br /&gt;Example;&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;&amp;lt;%=Html.RadioButton("MyRadioButton","MyValue")%&amp;gt;&lt;/pre&gt;renders&lt;br /&gt;&lt;pre name="code" class="html:nocontrols:nogutter"&gt;&amp;lt;input id="MyRadioButton" value="MyValue" name="MyRadioButton" type="radio"&amp;gt;&lt;br /&gt;&lt;/pre&gt;To get the label we just add the label tag and uses the input tags id as reference for the label.&lt;br /&gt;&lt;pre name="code" class="html:nocontrols:nogutter"&gt;&amp;lt;label for="MyRadioButton"&amp;gt;My description&amp;lt;/label&amp;gt;&lt;/pre&gt;This will allow us to check the radio button by clicking on the label as well.&lt;br /&gt;&lt;br /&gt;Then the problem occurs if we should use multiple radio buttons with the same name.&lt;br /&gt;Example;&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;&amp;lt;%=Html.RadioButton("IsItRaining","Yes")%&amp;gt;&lt;br /&gt;&amp;lt;%=Html.RadioButton("IsItRaining","No")%&amp;gt;&lt;/pre&gt;This will render&lt;br /&gt;renders&lt;br /&gt;&lt;pre name="code" class="html:nocontrols:nogutter"&gt;&amp;lt;input id="IsItRaining" value="Yes" name="IsItRaining" type="radio"&amp;gt;&lt;br /&gt;&amp;lt;input id="IsItRaining" value="No" name="IsItRaining" type="radio"&amp;gt;&lt;/pre&gt;&lt;br /&gt;This it not so well since we need different id attributes to be able to bind the label tags.&lt;br /&gt;To fix this we need to add different ids to the input tags.&lt;br /&gt;Example:&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;&amp;lt;%=Html.RadioButton("IsItRaining", "Yes", new {id="IsItRaining_Yes"})%&amp;gt;&amp;lt;label for="IsItRaining_Yes"&amp;gt;Yes&amp;lt;/label&amp;gt;&lt;br /&gt;&amp;lt;%=Html.RadioButton("IsItRaining", "No", new {id="IsItRaining_No"})%&amp;gt;&amp;lt;label for="IsItRaining_No"&amp;gt;No&amp;lt;/label&amp;gt;&lt;/pre&gt;That will produce the intended output;&lt;br /&gt;&lt;pre name="code" class="html:nocontrols:nogutter"&gt;&amp;lt;input id="IsItRaining_Yes" type="radio" value="Yes" name="IsItRaining"/&amp;gt;&lt;br /&gt;&amp;lt;label for="IsItRaining_Yes"&amp;gt;Yes&amp;lt;/label&amp;gt;&lt;br /&gt;&amp;lt;input id="IsItRaining_No" type="radio" value="No" name="IsItRaining"/&amp;gt;&lt;br /&gt;&amp;lt;label for="IsItRaining_No"&amp;gt;No&amp;lt;/label&amp;gt;&lt;/pre&gt;And will work as below&lt;br /&gt;&lt;br /&gt;&lt;input id="IsItRaining_Yes" value="Yes" name="IsItRaining" type="radio"&gt;&lt;label for="IsItRaining_Yes"&gt;Yes&lt;/label&gt;&lt;input id="IsItRaining_No" value="No" name="IsItRaining" type="radio"&gt;&lt;label for="IsItRaining_No"&gt;No&lt;/label&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-5015030584530540449?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=JXV0fzrFFrI:NpVluqHW1FY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=JXV0fzrFFrI:NpVluqHW1FY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=JXV0fzrFFrI:NpVluqHW1FY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/5015030584530540449/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2009/01/radiobutton-helper-and-label.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5015030584530540449" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5015030584530540449" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/JXV0fzrFFrI/radiobutton-helper-and-label.html" title="RadioButton helper and label" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2009/01/radiobutton-helper-and-label.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-7420980092512393354</id><published>2008-11-27T12:22:00.004+01:00</published><updated>2008-11-27T12:35:35.193+01:00</updated><title type="text">The GetField method</title><content type="html">Last month I wrote an &lt;a href="http://dhvik.blogspot.com/2008/10/clicking-winforms-button-from-code.html"&gt;article about clicking a button in a winforms application&lt;/a&gt; and in my code example I referred to the ReflectionUtil.GetField method. &lt;br /&gt;The ReflectionUtil class is an utility class that I have used for several years and they provide a better/easier way to use reflection. They are in line to be converted as Extension methods for the Type type, but for now they are ordinary static methods.&lt;br /&gt;I'll post the GetField method to allow the example to be complete.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;#region public static object GetField(Type type, string name, object instance)&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Gets the field from the instance&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="type"&amp;gt;The &amp;lt;see cref="Type"/&amp;gt; that contains the field&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="name"&amp;gt;The name of the field&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="instance"&amp;gt;The instance to get the value from&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;The value of the field&amp;lt;/returns&amp;gt;&lt;br /&gt;public static object GetField(Type type, string name, object instance) {&lt;br /&gt;    return InvokeMember(type, name, instance, BindingFlags.GetField | BindingFlags.Instance);&lt;br /&gt;}&lt;br /&gt;#endregion&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The GetField only wraps the InvokeMember method. (I have more wrappers named GetProperty, SetField, SetProperty, InvokeMethod, InvokeStaticMethod etc. that calls the InvokeMember method)&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;#region public static object InvokeMember(Type type, string name, object instance, BindingFlags flags, params object[] parameters)&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Invokes the member&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="type"&amp;gt;The &amp;lt;see cref="Type"/&amp;gt; that contains the member&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="name"&amp;gt;The name of the member&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="instance"&amp;gt;The instance to invoke on&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="flags"&amp;gt;The &amp;lt;see cref="BindingFlags"/&amp;gt; to use&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="parameters"&amp;gt;The &amp;lt;see cref="object"/&amp;gt; array to pass as parameters&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;The returnvalue&amp;lt;/returns&amp;gt;&lt;br /&gt;public static object InvokeMember(Type type, string name, object instance, BindingFlags flags, params object[] parameters) {&lt;br /&gt;    if (instance == null) {&lt;br /&gt;        flags |= BindingFlags.Static;&lt;br /&gt;        flags &amp;= ~BindingFlags.Instance;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    try {&lt;br /&gt;        return type.InvokeMember(name,BindingFlags.Public | BindingFlags.NonPublic | flags,null,instance,parameters);&lt;br /&gt;&lt;br /&gt;        //if the target threw an exception, throw this instead.&lt;br /&gt;    } catch (TargetInvocationException e) {&lt;br /&gt;&lt;br /&gt;        // if no exception is found, throw the TIException instead.&lt;br /&gt;        if (e.InnerException == null)&lt;br /&gt;            throw;&lt;br /&gt;        throw e.InnerException;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;#endregion&lt;/pre&gt;&lt;br /&gt;Hope the click button example can make more sense now :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-7420980092512393354?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=pyTZN_yt-5g:CwFtAO1N40w:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=pyTZN_yt-5g:CwFtAO1N40w:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=pyTZN_yt-5g:CwFtAO1N40w:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/7420980092512393354/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/11/getfield-method.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7420980092512393354" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7420980092512393354" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/pyTZN_yt-5g/getfield-method.html" title="The GetField method" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/11/getfield-method.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-7136687347448278039</id><published>2008-11-02T21:11:00.009+01:00</published><updated>2008-11-02T23:01:27.852+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="Lambda" /><category scheme="http://www.blogger.com/atom/ns#" term="Winforms" /><title type="text">Mvc for Winforms - Mapping the View event to the Controller action Part II</title><content type="html">This time I will try to deliver part of the answer to the requirements from &lt;a href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to.html"&gt;my previous post&lt;/a&gt;. To recap I would like to be able to connect a component to a controller action by calling the RegisterAction method like below.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Controller.RegisterAction(saveButton, "Save");&lt;br /&gt;Controller.RegisterAction(createBoldTextButton, "CreateText", new {name="Bold", type=4});&lt;br /&gt;Controller.RegisterAction(myTextBox, "ValidateText","Validating", null);&lt;br /&gt;&lt;/pre&gt;And letting those events call the actions defined below&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;public void Save() {...}&lt;br /&gt;public void CreateText(string name, int type) {...}&lt;br /&gt;public void ValidateText(CancelEventArgs e, object source) {...}&lt;br /&gt;&lt;/pre&gt;I will divide the solution in two steps and in this post I will cover the first, that is capturing the event of the object.&lt;br /&gt;&lt;br /&gt;We start by creating the RegisterAction method. We get the object which event should be listened to and sometimes also the name of the event that we should listen to. If this argument isn't supplied we need to find the DefaultEvent of the object.&lt;br /&gt;&lt;br /&gt;By using reflection we can retrieve the DefaultEventAttribute of the object. The following unit test shows how to get the attribute for a Button object. Notice the true flag on the GetCustomAttributes call. Since the DefaultEventAttribute is not present on the Button class itself, we need to go down in the inheritance chain to look for the attribute. Not until we reach the Control class we find the DefaultEventAttribute.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;[Test]&lt;br /&gt;public void GetDefaultEventAttribute() {&lt;br /&gt; object obj = new Button();&lt;br /&gt; DefaultEventAttribute attribute = null;&lt;br /&gt; Attribute[] attributes = obj.GetType().GetCustomAttributes(typeof(DefaultEventAttribute), true) as Attribute[];&lt;br /&gt; if (attributes != null &amp;amp;&amp;amp; attributes.Length &gt; 0) {&lt;br /&gt;     attribute = attributes[0] as DefaultEventAttribute;&lt;br /&gt; }&lt;br /&gt; Assert.IsNotNull(attribute);&lt;br /&gt;}&lt;/pre&gt;When we have the attribute, we just look at the Name property to get the name of the default event.&lt;br /&gt;&lt;br /&gt;Now when we have the name of the event (either by parameter or using the DefaultEventAttribute) we should add listener to the event. The listener method is a method in the Controller class, not the controller Action (we will get to that in the next part), but a event hub where all the Views events will pass before they are dispatched to the correct Action. The event hub method is declared as below&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;public void ExecuteAction(object source, object eventArgs, ActionData actionData)&lt;/pre&gt;The ExecuteAction method takes three parameters. The source and arguments of the event that was fired (this is the same values that the original event passes along). The third parameter contains the data for the action that is to take place, like the name of the action and any value parameters (The values that are stated when registering the action).&lt;br /&gt;&lt;br /&gt;So we got the object and the name of the event and the target method of the event, but how can we connect them?&lt;br /&gt;&lt;br /&gt;My first thought was to generate a delegate to the ExecuteAction and use reflection to get the EventInfo for the event and use the AddEventHandler of the EventInfo class to bind to the ExecuteAction method.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;[Test]&lt;br /&gt;public void BindToButtonClickEvent() {&lt;br /&gt; object obj = new Button();&lt;br /&gt; EventInfo info = obj.GetType().GetEvent("Click");&lt;br /&gt; MethodInfo method = GetType().GetMethod("ExecuteAction");&lt;br /&gt; Delegate d = Delegate.CreateDelegate(typeof(MyExecuteAction),method);&lt;br /&gt; info.AddEventHandler(obj,d);&lt;br /&gt;}&lt;br /&gt;private delegate void MyExecuteAction(object source, object eventArgs, ActionData actionData);&lt;br /&gt;public void ExecuteAction(object source, object eventArgs, ActionData actionData) {}&lt;/pre&gt;But when I ran this code I got an Exception&lt;br /&gt;&lt;pre&gt;System.ArgumentException: Error binding to target method.&lt;/pre&gt;Of course this won't work since the Click event cannot directly connect to the ExecuteAction method because the Click event can only add handlers that matches the EventHandler delegate, a method with a void return value and two arguments, object and EventArgs.&lt;br /&gt;&lt;br /&gt;The conclusion of this is that if I would like to have a single method that acts as an event hub and it must be able to handle any type of delegate that the event declares (note that events as practice should always return void and take two arguments, object and a instance of an EventArgs derived class), I need to generate this method in runtime.&lt;br /&gt;&lt;br /&gt;The first option that comes to mind is using Emit. I have tested this in the past, it has worked but comes not so natural to me. &lt;a href="http://ayende.com/Blog/archive/2007/10/29/Dynamic-Methods.aspx"&gt;Oren Eini&lt;/a&gt; used this technique but since I would like to pass a local variable (the ActionData instance) in the call, I needed to modify this piece of code, and possibly use an external list of ActionData instances if I couldn't pass them along using the dynamic method, I searched a bit more for an alternative (second opinion)...&lt;br /&gt;&lt;br /&gt;Finally I came across &lt;a href="http://stackoverflow.com/questions/45779"&gt;an answer from Mark Cidade&lt;/a&gt; that compiled a method in runtime using lambda expressions and that was fairly easy to modify.&lt;br /&gt;First we need to setup the call to the ExecuteAction method. This is done using a lambda expression and storing it in the &lt;a href="http://msdn.microsoft.com/en-us/library/bb549311.aspx"&gt;Action&lt;t1,t2&gt; delegate&lt;/t1,t2&gt;&lt;/a&gt;.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;ActionData actionData = new ActionData("Save", null);&lt;br /&gt;//Create the delegate using an lambda expression&lt;br /&gt;Action&amp;lt;object,object&amp;gt; eventHubCall = (source, e) =&gt; ExecuteAction(source, e, actionData);&lt;br /&gt;&lt;/pre&gt;This action will take two parameters and call the ExecuteAction just the way as we would like it to. The problem is that this expression is not typed the correct way as the event is so we need to create a new method using lambda expressions again but with the correct declaration. So we start by getting the information about the event.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Type type = obj.GetType();&lt;br /&gt;EventInfo evt = type.GetEvent("Click");&lt;br /&gt;ParameterInfo[] eventParams = evt.EventHandlerType.GetMethod("Invoke").GetParameters();&lt;/pre&gt;Then we create the lambda&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;ParameterExpression[] parameters = eventParams.&lt;br /&gt;  Select(p =&gt; Expression.Parameter(p.ParameterType, "x")).ToArray();&lt;br /&gt;MethodCallExpression body = Expression.Call(Expression.Constant(eventHubCall),&lt;br /&gt;  eventHubCall.GetType().GetMethod("Invoke"), parameters);&lt;br /&gt;LambdaExpression lambda = Expression.Lambda(body, parameters);&lt;br /&gt;&lt;/pre&gt;Now we have a method with two parameters of the correct type, the only thing left is to create a delegate that we can use for adding to the event.&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Delegate proxy = Delegate.CreateDelegate(evt.EventHandlerType, lambda.Compile(), "Invoke", false);&lt;br /&gt;evt.AddEventHandler(obj, proxy);      &lt;br /&gt;&lt;/pre&gt;Tada!! No more Error binding to target method errors.&lt;br /&gt;The complete test follows.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;[Test]&lt;br /&gt;public void BindToButtonClickEvent2() {&lt;br /&gt; ActionData actionData = new ActionData("Save", null);&lt;br /&gt; //Create the delegate using an lambda expression&lt;br /&gt; Action&amp;lt;object,object&amp;gt; eventHubCall = (source, e) =&gt; ExecuteAction(source, e, actionData);&lt;br /&gt;&lt;br /&gt; object obj = new Button();&lt;br /&gt; //find the exact definition of the event&lt;br /&gt; Type type = obj.GetType();&lt;br /&gt; EventInfo evt = type.GetEvent("Click");&lt;br /&gt; ParameterInfo[] eventParams = evt.EventHandlerType.GetMethod("Invoke").GetParameters();&lt;br /&gt;&lt;br /&gt; //create a new lambda expression using the correct parameters&lt;br /&gt; ParameterExpression[] parameters = eventParams.&lt;br /&gt;      Select(p =&gt; Expression.Parameter(p.ParameterType, "x")).ToArray();&lt;br /&gt; //call the event hub&lt;br /&gt; MethodCallExpression body = Expression.Call(Expression.Constant(eventHubCall),&lt;br /&gt;      eventHubCall.GetType().GetMethod("Invoke"), parameters);&lt;br /&gt; //create the expression with the correct parameters to match the event&lt;br /&gt; LambdaExpression lambda = Expression.Lambda(body, parameters);&lt;br /&gt; //and then create the delegate that wraps the lambda expression.&lt;br /&gt; Delegate proxy= Delegate.CreateDelegate(evt.EventHandlerType, lambda.Compile(), "Invoke", false);&lt;br /&gt;&lt;br /&gt; evt.AddEventHandler(obj, proxy);      &lt;br /&gt;}&lt;/pre&gt;Not so dumb ey! All credits goes to &lt;a href="http://www.marxidad.com/"&gt;Mark Cidade&lt;/a&gt; for providing the elegant solution. (So I perhaps my greatest talent is to find solutions that others have done before me, and use them ;)&lt;br /&gt;Anyway, that concludes part II and next we will look how to call the action method of the controller from the ExecuteAction method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-7136687347448278039?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=hTm7rdxw_SU:-Xi5Ldw2XDw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=hTm7rdxw_SU:-Xi5Ldw2XDw:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=hTm7rdxw_SU:-Xi5Ldw2XDw:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/7136687347448278039/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to_02.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7136687347448278039" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7136687347448278039" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/hTm7rdxw_SU/mvc-for-winforms-mapping-view-event-to_02.html" title="Mvc for Winforms - Mapping the View event to the Controller action Part II" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to_02.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-1787092027089813591</id><published>2008-11-01T23:41:00.008+01:00</published><updated>2008-11-02T22:54:19.656+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC" /><category scheme="http://www.blogger.com/atom/ns#" term="Winforms" /><title type="text">Mvc for Winforms - Mapping the View event to the Controller action</title><content type="html">In my current (or rather one of my current projects) I'm writing a small MVC framework for a WinForms application (I mentioned this in my &lt;a href="http://dhvik.blogspot.com/2008/10/clicking-winforms-button-from-code.html"&gt;last post&lt;/a&gt;). The latest issue that I stumbled upon and found worth mentioning is about connecting the Views events to the Controllers actions.&lt;br /&gt;&lt;br /&gt;If we look at the MVC for ASP.NET the events is the requests by the web client and the URL contains the information that the Routing module uses to find an appropriate action to call. It should be nice to have such a feature in the WinForms solution as well so after some thought I summarized a small example.&lt;br /&gt;&lt;br /&gt;In my view I can have several objects (not necessary controls) that can/will fire some events (like a button firering the click event when the user clicks it).&lt;br /&gt;In my controller I have several action methods that should be called by the view when the appropriate event occurs. (Like a Save action that should be called when the user clicks the save button, thus triggering the save button click event) (nothing out of the ordinary here;)&lt;br /&gt;&lt;br /&gt;Whats the fuzz about this then, you may think? This is normal stuff, no strange things!? (who is this dumb guy anyway...)&lt;br /&gt;&lt;br /&gt;Yes I see your point. I could easily use the Forms designer in Visual studio, double click the Save button and enter the code below to call the Save button.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;private void saveButton_Click(object sender, System.EventArgs e) {&lt;br /&gt;  Controller.Save();&lt;br /&gt;}&lt;/pre&gt;But thats not what I want. I don't want to litter the View with a lot of event methods just calling one line of code. The purpose of the MVC pattern is to separate the View from the logic and if we start putting those event handler methods in the view, soon some line of controller logic will be entered in there (just to test) and we'll never find the way to clean them up again.&lt;br /&gt;&lt;br /&gt;My vision is to register these events one by one in the Views constructor, on one line that enables me to&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Listen to an event from an object in the view&lt;/li&gt;&lt;li&gt;Capture the event and pass it to an action in the controller&lt;/li&gt;&lt;li&gt;Allow the mapping to pass additional parameters to the action (compare the routing in MVC for ASP.NET)&lt;/li&gt;&lt;/ul&gt;If I would make the same example like the one above but using the one liner instead, it would look like below.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Controller.RegisterAction(saveButton,"Save");&lt;/pre&gt;If I would pass some parameters to the action I could use the same syntax as when defining default routes in MVC for ASP.NET.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Controller.RegisterAction(createBoldTextButton,"CreateText", new {name="Bold",type=4});&lt;/pre&gt;This would then be mapped to the action CreateText which declaration looks like below.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;public void CreateText(string name, int type) {...}&lt;/pre&gt;If I want to listen to an event that isn't the DefaultEvent (see the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaulteventattribute.aspx"&gt;DefaultEventAttribute&lt;/a&gt;) I could state this as well in the call&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Controller.RegisterAction(myTextBox,"ValidateText","Validating", null);&lt;/pre&gt;And if I declare the action to include the event argument and/or source they should be passed along as well&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;public void ValidateText(CancelEventArgs e, object source) {...}&lt;/pre&gt; How do I code this to be like I want it to then???&lt;br /&gt;&lt;br /&gt;In my &lt;a href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to_02.html"&gt;next post&lt;/a&gt; I will try to give you a solution to the requirements above and hopefully prove that I'm not a dumb guy after all ;)&lt;br /&gt;See ya!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-1787092027089813591?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=i5XBHJEbfKQ:IydJ8p1e5Zs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=i5XBHJEbfKQ:IydJ8p1e5Zs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=i5XBHJEbfKQ:IydJ8p1e5Zs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/1787092027089813591/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/1787092027089813591" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/1787092027089813591" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/i5XBHJEbfKQ/mvc-for-winforms-mapping-view-event-to.html" title="Mvc for Winforms - Mapping the View event to the Controller action" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/11/mvc-for-winforms-mapping-view-event-to.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-7362925671236316634</id><published>2008-10-27T11:11:00.006+01:00</published><updated>2008-10-27T11:43:27.884+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unittest" /><title type="text">Clicking a winforms button from code</title><content type="html">Today I was writing a unit test for a winforms application (or rather a small Mvc framework for winforms) and I would like to simulate a button click on the form to se that all events had been wired correctly.&lt;br /&gt;Since the event is a delegate, I thought it would be easy to just call the Invoke/DynamicInvoke methods of the Click delegate instance to get the events fiering...&lt;br /&gt;It wasn't quite that easy though. When I tried to use the code&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;button.Click.Invoke(this,EventArgs.Empty);&lt;/pre&gt;I got a compiler error&lt;br /&gt;&lt;br /&gt;The event 'System.Windows.Forms.Control.Click' can only appear on the left hand side of += or -=&lt;br /&gt;&lt;br /&gt;After a search I found &lt;a href="http://it.toolbox.com/blogs/parthas/events-vs-delegates-contd-10596"&gt;an article by Partha S&lt;/a&gt; that summarized the issue quite well, namely the difference between an event and a delegate is that the event can control the chaining and the event can only be invoked from within the declaring class. Partha also provided a solution for declaring an event that can be called from external code but that don't help me since I cannot modify the Button class.&lt;br /&gt;&lt;br /&gt;A workaround is then to use reflection for retrieving the delegate field from the button class and when we have direct access to the delegate (not through the event wrapper construct) we will be able to Invoke the event.&lt;br /&gt;The code below contains a method "GetField" that is included in our base library that I can post if anyone is interested, but for now it returns the value of a field.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;//All events in a Component is listed in an EventHandlerList &lt;br /&gt;//called events in the Component class. &lt;br /&gt;//b is the button instance.&lt;br /&gt;EventHandlerList list = ReflectionUtil.GetField(&lt;br /&gt;    typeof(Component), "events", b) as EventHandlerList;&lt;br /&gt;Assert.IsNotNull(list,"Cannot get eventlist from component");&lt;br /&gt;&lt;br /&gt;//in the EventHandlerList, each delegate is identified by a&lt;br /&gt;//static object instance in the control class&lt;br /&gt;object eventClick = ReflectionUtil.GetField(typeof(Control),&lt;br /&gt;    "EventClick",null);&lt;br /&gt;&lt;br /&gt;//now we get the click event delegate&lt;br /&gt;Delegate click = list[eventClick];&lt;br /&gt;&lt;br /&gt;//finally we can invoke the listeners of the click event.&lt;br /&gt;click.DynamicInvoke(this, EventArgs.Empty);&lt;br /&gt;&lt;/pre&gt;So now I can click da button in my unittest :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-7362925671236316634?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=uw2YReL0LsI:jRcY8b6O0wk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=uw2YReL0LsI:jRcY8b6O0wk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=uw2YReL0LsI:jRcY8b6O0wk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/7362925671236316634/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/10/clicking-winforms-button-from-code.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7362925671236316634" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7362925671236316634" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/uw2YReL0LsI/clicking-winforms-button-from-code.html" title="Clicking a winforms button from code" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/10/clicking-winforms-button-from-code.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-8300924836014477363</id><published>2008-10-22T12:07:00.005+02:00</published><updated>2008-10-22T12:24:26.437+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Vista x64 .Net" /><title type="text">BadImageFormatException when loading Microsoft.TeamFoundation.Client.dll</title><content type="html">I tried to make a small winforms application on my 64bit Vista that talks with our TeamFoundationServer today. I use a plugin based application that loads the assemblies using Assembly.Load (utilizing the AppDomain.AssemblyResolve event).&lt;br /&gt;&lt;br /&gt;The problem surfaced when I tried to activate a function in one of my loaded plugins that used the TeamFoundation client dll, this was not located in the same folder as the exe.&lt;br /&gt;Using the AppDomain.CurrentDomain.AssemblyResolve event, I was easy to find the assembly dll and using Assembly.LoadFrom(filename) I could return the needed assembly.&lt;br /&gt;&lt;br /&gt;The problem was that when I tried to do this, I got a BadImageFormatException stating that&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;Could not load file or assembly 'file:///C:\MyPath\MyProject\bin\Debug\Plugins\MyPlugin\Microsoft.TeamFoundation.Client.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp;amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp;amp; stackMark, Boolean forIntrospection)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   at System.Reflection.Assembly.LoadFrom(String assemblyFile)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;   at Meridium.Plugins.PluginLoader.CurrentDomain_AssemblyResolve(Object sender, ResolveEventArgs args) in C:\VSS\TFS\Meridium\Source\Meridium.Plugins\PluginLoader.cs:line 606&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This seemed not quite correct, since the assembly at the location is ok and can be opened for instance in Reflector.&lt;br /&gt;&lt;br /&gt;After a bit of searching I found more clues pointing to the fact that a 64bit application cannot load 32bit assemblies if they are in "Mixed mode" since they contain native code and thus are platform specific. The forum post &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=665884&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=665884&amp;amp;SiteID=1&lt;/a&gt; stated the problem and provided the solution to set the project output to be built for the x86 platform.&lt;br /&gt;&lt;br /&gt;After changing the settings in the project, it worked like a charm.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-8300924836014477363?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=w63bdXafZ28:rmfR3Vuiqwo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=w63bdXafZ28:rmfR3Vuiqwo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=w63bdXafZ28:rmfR3Vuiqwo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/8300924836014477363/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/10/badimageformatexception-when-loading.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8300924836014477363" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8300924836014477363" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/w63bdXafZ28/badimageformatexception-when-loading.html" title="BadImageFormatException when loading Microsoft.TeamFoundation.Client.dll" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/10/badimageformatexception-when-loading.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-9030877207448599649</id><published>2008-08-26T16:35:00.012+02:00</published><updated>2008-08-27T08:20:46.411+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unittest" /><category scheme="http://www.blogger.com/atom/ns#" term="log4net" /><title type="text">Adding an appender to log4net in runtime</title><content type="html">I was testing logging with log4net today and wanted to create a unit test that verified that the method logged alright.&lt;br /&gt;To verify that the logging worked I wanted to create a log appender (the MemoryAppender) and add it to the log4net configuration to be able to compare the actual logged messages with the expected ones. (The MemoryAppender has the GetEvents() and Clear() methods which works well in a unit test case).&lt;br /&gt;&lt;br /&gt;Normally you use a configuration file (xml) to add your appenders but using configuration files in a unit test is not quite the optimal solution. So how could I set it in runtime in my test method. After a bit of testing and reading (I wonder why the testing and reading always seem to be in that order? (for me anyway) Shouldn't you start reading about the theory before you start coding and testing? ;)&lt;br /&gt;&lt;br /&gt;I found some tips using the Hierarchy class to access the root level logger and add append the MemoryAppender there.&lt;br /&gt;&lt;br /&gt;The important steps where to set the Configured property of the Hierarchy and call the RaiseConfigurationChanged() method to actually utilize the configuration changes.&lt;br /&gt;&lt;br /&gt;Here is a complete example.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;//First create and configure the appender&lt;br /&gt;MemoryAppender memoryAppender = new MemoryAppender();&lt;br /&gt;memoryAppender.Name = "MyAppender";&lt;br /&gt;&lt;br /&gt;//Notify the appender on the configuration changes&lt;br /&gt;memoryAppender.ActivateOptions();&lt;br /&gt;&lt;br /&gt;//Get the logger repository hierarchy.&lt;br /&gt;log4net.Repository.Hierarchy.Hierarchy repository =&lt;br /&gt;   LogManager.GetRepository() as Hierarchy;&lt;br /&gt;&lt;br /&gt;//and add the appender to the root level&lt;br /&gt;//of the logging hierarchy&lt;br /&gt;repository.Root.AddAppender(memoryAppender);&lt;br /&gt;&lt;br /&gt;//configure the logging at the root.&lt;br /&gt;repository.Root.Level = Level.All;&lt;br /&gt;&lt;br /&gt;//mark repository as configured and&lt;br /&gt;//notify that is has changed.&lt;br /&gt;repository.Configured = true;&lt;br /&gt;repository.RaiseConfigurationChanged(EventArgs.Empty);&lt;/pre&gt;Now we have prepared the logging for the root (all log events) and directed it to the memoryAppender.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;//Call the method to test (this one creates&lt;br /&gt;//an info level message to the log&lt;br /&gt;//stating the string "GetConfiguration()".&lt;br /&gt;ServerDataFactory.Instance.GetConfiguration();&lt;/pre&gt;When we have ran the code that has produced some logging, we add assert statements to check that the code behaved as we expected.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;//use the memoryAppender to get the logged events&lt;br /&gt;LoggingEvent[] events = memoryAppender.GetEvents();&lt;br /&gt;&lt;br /&gt;//We only expect one log statement on the info level&lt;br /&gt;Assert.AreEqual(1, events.Length,&lt;br /&gt;   "Incorrect number of log statements");&lt;br /&gt;LoggingEvent e = events[0];&lt;br /&gt;Assert.AreEqual(Level.Info, e.Level,&lt;br /&gt;   "Incorrect logging level");&lt;br /&gt;Assert.AreEqual("GetConfiguration()", e.MessageObject,&lt;br /&gt;   "Incorrect log message");&lt;/pre&gt;Thats how I did it. Does anyone has another solution that works well?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-9030877207448599649?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=wfNuXSYxQ3M:_H-OHO_HzW8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=wfNuXSYxQ3M:_H-OHO_HzW8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=wfNuXSYxQ3M:_H-OHO_HzW8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/9030877207448599649/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/08/adding-appender-to-log4net-in-runtime.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/9030877207448599649" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/9030877207448599649" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/wfNuXSYxQ3M/adding-appender-to-log4net-in-runtime.html" title="Adding an appender to log4net in runtime" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/08/adding-appender-to-log4net-in-runtime.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-6256130887663238495</id><published>2008-02-28T13:50:00.005+01:00</published><updated>2008-02-28T14:01:39.677+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ClickOnce" /><category scheme="http://www.blogger.com/atom/ns#" term="SharePoint" /><title type="text">ClickOnce, SharePoint and Anonymous access</title><content type="html">I have been laborating with a ClickOnce deployed application in SharePoint and all seems to work well until I tried to connect to SharePoint (wss3) from a workstation where I used another locally logged in user than the one I used to authenticate myself at the SharePoint server.&lt;br /&gt;&lt;br /&gt;When I then tried to access the ClickOnce application the bootstrap downloader (ApplicationActivator) prompts a "Cannot Start Application" error that says "Cannot retrieve application. Authentication error".&lt;br /&gt;&lt;br /&gt;The details of the error indicates a 401 response from the webserver.&lt;br /&gt;&lt;pre&gt;System.Deployment.Application.DeploymentDownloadException (Unknown subtype)&lt;br /&gt;  - Downloading http://wm20031/_layouts/MyApp/MyApp.application did not succeed.&lt;br /&gt;  - Source: System.Deployment&lt;br /&gt;  - Stack trace:&lt;br /&gt;    at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)&lt;br /&gt;    at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()&lt;br /&gt;    at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)&lt;br /&gt;    at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri&amp;amp; sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation&amp;amp; serverInformation)&lt;br /&gt;    at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri&amp;amp; sourceUri, TempFile&amp;amp; tempFile, SubscriptionState&amp;amp; subState, IDownloadNotification notification, DownloadOptions options, ServerInformation&amp;amp; serverInformation)&lt;br /&gt;    at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri&amp;amp; sourceUri, TempFile&amp;amp; tempFile, SubscriptionState&amp;amp; subState, IDownloadNotification notification, DownloadOptions options)&lt;br /&gt;    at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension)&lt;br /&gt;    at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)&lt;br /&gt;&lt;br /&gt;--- Inner Exception ---&lt;br /&gt;System.Net.WebException&lt;br /&gt;  - The remote server returned an error: (401) Unauthorized.&lt;br /&gt;  - Source: System&lt;br /&gt;  - Stack trace:&lt;br /&gt;    at System.Net.HttpWebRequest.GetResponse()&lt;br /&gt;    at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)&lt;/pre&gt;&lt;p&gt;If I check the weblog we can se the following two entries &lt;/p&gt;&lt;pre&gt;2008-02-28 12:05:29 W3SVC1265274740 192.168.1.199 GET /_layouts/MyApp/MyApp.application 80 domain\administrator 192.168.1.2 Mozilla/4.0+(...) 206 0 0&lt;br /&gt;2008-02-28 12:05:29 W3SVC1265274740 192.168.1.199 GET /_layouts/MyApp/MyApp.application  80 - 192.168.1.2 - 401 5 0&lt;/pre&gt;The first is the webbrowser access where I authenticate using the domain\administrator account and the application manifest is successfully returned to the browser. Then the ApplicationActivator tries the same thing as anonymous but fails utterly. Ok, so perhaps this is only anonymous user access that is denied, but I had already checked the "Enable Anonymous access" in the IIS manager for the _layouts/MyApp folder.&lt;br /&gt;&lt;br /&gt;Testing with firefox and anonymous access proved that is not the access rights that is incorrectly set.&lt;br /&gt;&lt;pre&gt;2008-02-28 12:16:56 W3SVC1265274740 192.168.1.199 GET /_layouts/MyApp/MyApp.application 80 - 192.168.1.2 Mozilla/5.0+... 200 0 0&lt;/pre&gt;So the IIS is not blocking access, then it has to be SharePoint? (_layouts is a SharePoint managed folder)&lt;br /&gt;&lt;br /&gt;To test I checked the code for the System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next) method and reproduced the code that was processed there.&lt;br /&gt;&lt;br /&gt;&lt;pre class="c-sharp:nocontrols:nogutter" name="code"&gt;WebRequest request = WebRequest.Create("http://wm20031/_layouts/MyApp/MyApp.application");&lt;br /&gt;request.Credentials = CredentialCache.DefaultCredentials;&lt;br /&gt;RequestCachePolicy policy = new RequestCachePolicy(RequestCacheLevel.BypassCache);&lt;br /&gt;request.CachePolicy = policy;&lt;br /&gt;HttpWebRequest request2 = request as HttpWebRequest;&lt;br /&gt;if (request2 != null) {&lt;br /&gt;  request2.UnsafeAuthenticatedConnectionSharing = true;&lt;br /&gt;  request2.AutomaticDecompression = DecompressionMethods.GZip;&lt;br /&gt;  request2.CookieContainer = GetUriCookieContainer(request2.RequestUri);&lt;br /&gt;  WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;&lt;br /&gt;}&lt;br /&gt;WebResponse response = null;&lt;br /&gt;response = request.GetResponse();&lt;br /&gt;using (StreamReader reader = new StreamReader(response.GetResponseStream())) {&lt;br /&gt;  Console.WriteLine(reader.ReadToEnd());&lt;br /&gt;}&lt;br /&gt;response.Close();&lt;/pre&gt;This code fails with the same exception as the Application Activator and after some debugging I noticed that if I didn't copy the cookies to the request, then it worked?!&lt;br /&gt;Checking further in the cookie container, it only added one cookie &lt;tt&gt;MSOWebPartPage_AnonymousAccessCookie&lt;/tt&gt; and with the value of the webapplication port. (80)&lt;br /&gt;&lt;br /&gt;The GetUriCookieContainer parsed the cookies retrieved in IE for the url. If I removed the cookie for the server in the temporary internet files folder, the code above worked even with the cookie row (no cookies added).&lt;br /&gt;&lt;br /&gt;To solve the problem one workaround is to create a virtual folder in the root of the SharePoint site (MyApp) (that is not managed by SharePoint), map this to the same folder as _layouts/MyApp, allow anonymous access there and navigate to that url instead (/MyApp/MyApp.application). This works since the cookie is not present for the application.&lt;br /&gt;&lt;br /&gt;But what I really like to know is the purpose of the &lt;strong&gt;MSOWebPartPage_AnonymousAccessCookie&lt;/strong&gt;, especially why SharePoint sets this cookie when I navigate to the site and why it throws an access denied when I try to access with the cookie set?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-6256130887663238495?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=SYXSTRn-1b0:UvfEHBdaHp4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=SYXSTRn-1b0:UvfEHBdaHp4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=SYXSTRn-1b0:UvfEHBdaHp4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/6256130887663238495/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2008/02/clickonce-sharepoint-and-anonymous.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6256130887663238495" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6256130887663238495" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/SYXSTRn-1b0/clickonce-sharepoint-and-anonymous.html" title="ClickOnce, SharePoint and Anonymous access" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2008/02/clickonce-sharepoint-and-anonymous.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-5112114397826610577</id><published>2007-11-26T15:10:00.001+01:00</published><updated>2007-11-26T15:12:59.740+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title type="text">Task failed because "sgen.exe" was not found</title><content type="html">I installed Visual Studio 2008 (final) and started to create a WinForms (2.0) application that calls a webservice and is deployed with clickonce. When I try to compile it (after adding the webreference) I get the following build error&lt;br /&gt;&lt;span style="font-family:Courier;"&gt;&lt;br /&gt;C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1993,9):&lt;br /&gt;error MSB3091:&lt;br /&gt;Task failed because "sgen.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following:&lt;br /&gt; 1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5.&lt;br /&gt; 2) Install Visual Studio 2008.&lt;br /&gt; 3) Manually set the above registry key to the correct location.&lt;br /&gt; 4) Pass the correct location into the "ToolPath" parameter of the task.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I thought that the SDK was to be installed with VisualStudio 2008, but when looking into the SDKs folder (C:\Program Files\Microsoft Visual Studio 9.0\SDK) it contains almost nothing, only a few files in the v3.5 folder.&lt;br /&gt;&lt;br /&gt;When I searched for the SDK for framework 3.5 it seems that is included in the windows server 2008 platform sdk and that is only avaliable for beta2 so far...&lt;br /&gt;&lt;br /&gt;Regarding the registry settings, I have the SDK for v2.0 installed and since I build vs the 2.0 framework, shouldn't it look in the &lt;span style="font-family:Courier;"&gt;KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v2.0&lt;span style="font-family:Arial;"&gt; key?&lt;br /&gt;&lt;br /&gt;How do I set the ToolPath?&lt;br /&gt;&lt;br /&gt;Anyway, I came around the issue by setting the &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier;"&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A&lt;span style="font-family:Arial;"&gt; InstallationFolder key to the same path as the 2.0 Sdk path and compilation was successful...&lt;br /&gt;&lt;br /&gt;Is the VisualStudio 2008 release not final since it seems to miss the SDK or have I been sloppy installing the product?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-5112114397826610577?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=8oSDBDiqPac:khVGzv42uDE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=8oSDBDiqPac:khVGzv42uDE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=8oSDBDiqPac:khVGzv42uDE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/5112114397826610577/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/11/task-failed-because-was-not-found.html#comment-form" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5112114397826610577" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5112114397826610577" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/8oSDBDiqPac/task-failed-because-was-not-found.html" title="Task failed because &amp;quot;sgen.exe&amp;quot; was not found" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">7</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/11/task-failed-because-was-not-found.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-6200140454739453986</id><published>2007-11-26T12:03:00.001+01:00</published><updated>2007-11-26T12:09:13.147+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ClickOnce" /><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title type="text">Signing a ClickOnce manifest file using a spc/pvk certificate</title><content type="html">&lt;p&gt;To sign a ClickOnce manifest file/assembly you need a pfx file without chaining information.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;First we need to convert the spc/pvk file to a pfx file. As &lt;a href="http://processbridge.spaces.live.com/blog/cns%21674C1260C39F1DB8%21116.entry?&amp;amp;_c02_owner=1"&gt;Stuart found out&lt;/a&gt; you use the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa906332.aspx"&gt;pvk2pfx tool&lt;/a&gt; to accomplish this.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If we try to use this certificate and it contains chaining information we will get an error stating&lt;br /&gt;&lt;/p&gt;&lt;div style="margin-left: 40px;"&gt;&lt;span style="font-family: Courier;"&gt;"Cannot find the certificate and private key for decryption"&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;Then we need to make sure that the pfx don't include the chaining information as described in &lt;a href="https://support.comodo.com/index.php?_m=knowledgebase&amp;amp;_a=viewarticle&amp;amp;kbarticleid=1078"&gt;the case @ commodo&lt;/a&gt; (importing and exporting the pfx).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;When these steps has been completed, you can build and sign your application.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-6200140454739453986?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=FXaBV4mOg6M:fPGl28l2XBg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=FXaBV4mOg6M:fPGl28l2XBg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=FXaBV4mOg6M:fPGl28l2XBg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/6200140454739453986/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/11/signing-clickonce-manifest-file-using.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6200140454739453986" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6200140454739453986" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/FXaBV4mOg6M/signing-clickonce-manifest-file-using.html" title="Signing a ClickOnce manifest file using a spc/pvk certificate" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/11/signing-clickonce-manifest-file-using.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-302866460016145756</id><published>2007-10-27T08:47:00.000+02:00</published><updated>2007-10-27T09:30:14.272+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Media Center" /><title type="text">Media center automatically starts the computer from standby</title><content type="html">&lt;p&gt;I've had a problem that I have finally found time to solve. I have a windows media center machine at home connected to my tv set. At night I put the machine in standby and every morning it start by itself at around 7. This is rather annoying since I don't have any scheduled jobs or recordings at that time.&lt;/p&gt;&lt;p&gt;I checked the event log and one of the first logs after startup in the application log was an 'Event Info: Guide Successfully Downloaded'.&lt;br /&gt;Perhaps it's the EPG download that forces the machine to start? Can this be configured to another time in the day?&lt;/p&gt;&lt;p&gt;I checked the settings in mce but no entry states when to download the epg. So after some googling I found a &lt;a href="http://thegreenbutton.com/forums/thread/182826.aspx"&gt;post&lt;/a&gt; in one of the The Green Button forums that took up the issue.&lt;/p&gt;&lt;p&gt;To cut it short, the user &lt;a href="http://thegreenbutton.com/members/Cowboy.aspx"&gt;Cowboy&lt;/a&gt; found out that there are two registry keys controlling this behavior&lt;br /&gt;&lt;/p&gt;&lt;dd&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\EPG\dlLastTime&lt;/dd&gt;&lt;br /&gt;&lt;dd&gt;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\EPG\dlRegTime&lt;/dd&gt;&lt;br /&gt;&lt;br /&gt;These keys contain the date when the guide was downloaded the last time and when it is registered to run the next time. The data format is stored in NT Time Epoch format but backwards. (see &lt;a href="http://thegreenbutton.com/members/Cowboy.aspx"&gt;Cowboys&lt;/a&gt; &lt;a href="http://thegreenbutton.com/forums/thread/182826.aspx"&gt;forum post&lt;/a&gt; for detailed information)&lt;p&gt;&lt;/p&gt;&lt;p&gt;To fix this you can set these values to another time and date by updating these registry values and restart the computer. For ease of use &lt;a href="http://thegreenbutton.com/members/riesm.aspx"&gt;riesm&lt;/a&gt; had &lt;a href="http://thegreenbutton.com/forums/permalink/182826/31957/ShowThread.aspx#31957"&gt;posted &lt;/a&gt; an &lt;a href="http://www.avsoft.nl/download/mce/EPG_ChangeDownloadTime.zip"&gt;application&lt;/a&gt; that provides a nice GUI for setting the download time. After using this and restarting the computer is not autostarted every morning at 7.&lt;/p&gt;&lt;p&gt;Thanks to &lt;a href="http://thegreenbutton.com/members/Cowboy.aspx"&gt;Cowboy&lt;/a&gt; and &lt;a href="http://thegreenbutton.com/members/riesm.aspx"&gt;riesm&lt;/a&gt; for providing the great community support.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-302866460016145756?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=vMV5DwUsLNk:INxsXtDtRXU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=vMV5DwUsLNk:INxsXtDtRXU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=vMV5DwUsLNk:INxsXtDtRXU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/302866460016145756/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/10/media-center-automatically-starts.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/302866460016145756" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/302866460016145756" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/vMV5DwUsLNk/media-center-automatically-starts.html" title="Media center automatically starts the computer from standby" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/10/media-center-automatically-starts.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-8804047105673152330</id><published>2007-09-19T13:39:00.000+02:00</published><updated>2008-12-11T14:31:44.018+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IIS" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title type="text">Running multiple versions of ASP.NET on the same IIS</title><content type="html">When configuring a website to run multiple applications with different versions of ASP.NET there are some issues that needs to be resolved before the applications are running smoothly. The guide below describes the setup for a windows 2003 server.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:trebuchet ms;font-size:130%;"  &gt;1. Install the different dotnet framework versions on the server.&lt;/span&gt;&lt;br /&gt;When installed you can check the c:\windows\microsoft.net\framework folder and each installed version contains an own folder named vx.x.xxxx. On my server, running&lt;pre&gt;dir c:\WINDOWS\Microsoft.NET\Framework\v*&lt;/pre&gt;gives the following output&lt;br /&gt;&lt;pre&gt;2007-09-12  08:15    &amp;lt;dir&amp;gt;          v1.1.4322&lt;br /&gt;2007-09-12  08:44    &amp;lt;dir&amp;gt;          v2.0.50727&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;font-family:trebuchet ms;font-size:130%;"  &gt;2. Make sure the needed framework is installed in the IIS&lt;/span&gt;&lt;br /&gt;Each framework version installs a tool named aspnet_regiis.exe. This tool is used to manipulate the IIS metabase for asp.net registrations and mappings. Depending on which version of the framework the tool is shipped with, there exists different switches that can be used. Run the exe in a command window to see which are supported for your version.&lt;br /&gt;To see which frameworks is installed in the IIS metabase, run the tool with the -lv flags. (Example below)&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727&gt;aspnet_regiis.exe -lv&lt;br /&gt;2.0.50727.0 Valid (Root)  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;If your needed framework isn't listed, go to the version folder and run the aspnet_regiis.exe with the -ir flag. (the -i flag will also install the framework but will also update the scriptmaps, which we don't want to do (not yet anyway))&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322&gt;aspnet_regiis.exe -ir&lt;br /&gt;Start installing ASP.NET (1.1.4322.0) without registering the scriptmap.&lt;br /&gt;Finished installing ASP.NET (1.1.4322.0) without registering the scriptmap.&lt;/span&gt;&lt;/pre&gt;Running the -lv again we'll se that we now have two frameworks registered in the IIS metabase.&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322&gt;aspnet_regiis.exe -lv&lt;br /&gt;1.1.4322.0      Valid           C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll&lt;br /&gt;2.0.50727.0     Valid (Root)    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;font-family:trebuchet ms;font-size:130%;"  &gt;3. Install the scriptmaps on the web application&lt;/span&gt;&lt;br /&gt;In addition to installing the framework in the IIS metabase we need to configure the web application to use the specific framework version.&lt;br /&gt;To see which mappings that are in effect use the -lk flag&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322&gt;aspnet_regiis.exe -lk&lt;br /&gt;W3SVC/  2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/   2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/Reports/   2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/ReportServer/      2.0.50727.832&lt;br /&gt;W3SVC/3/Root/   2.0.50727.832&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;To set the scriptsmaps for a specific application use the -s flag. (here my application is running on the path W3SVC/258083574/root/MyApplication)&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322&gt;aspnet_regiis.exe -s W3SVC/258083574/root/MyApplication&lt;br /&gt;Start registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/258083574/root/MyApplication.&lt;br /&gt;Finished registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/258083574/root/MyApplication.&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;When installation is successful use the -lk to see the updated mapping&lt;br /&gt;&lt;pre&gt;&lt;span style="font-size:85%;"&gt;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322&gt;aspnet_regiis.exe -lk&lt;br /&gt;W3SVC/  2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/   2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/Reports/   2.0.50727.832&lt;br /&gt;W3SVC/1/ROOT/ReportServer/      2.0.50727.832&lt;br /&gt;W3SVC/258083574/root/MyApplication/      1.1.4322.0&lt;br /&gt;W3SVC/3/Root/   2.0.50727.832&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;font-family:trebuchet ms;" &gt;4. Make sure each version uses separate Application pools&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;A common mistake is to use the same application pool for multiple applications running different versions of the framework. This is not recommended and will most certainly break in time.&lt;br /&gt;So... don't.&lt;br /&gt;Changing application pool settings and creating new ones is done in the mmc tool (Internet Information Services). You don't have to configure the pools, just don't mix applications running on different framework versions.&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:trebuchet ms;font-size:130%;"  &gt;&lt;span style="font-weight: bold;"&gt;5. Make sure that WebService extensions allows webpages of the specific version&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;If you now test your new application and tries to view an aspx page but the server only returns a 404 error, then you need to fix the WebService extension settings.&lt;br /&gt;Locate the Web Service Extensions folder in the mmc tool and Allow the ASP.NET version to execute.&lt;br /&gt;&lt;pre&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_BktCNuR9VXg/RvEW1imYX8I/AAAAAAAAAAw/-LJyGal10o0/s1600-h/wsext.gif"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; cursor: pointer;" src="http://2.bp.blogspot.com/_BktCNuR9VXg/RvEW1imYX8I/AAAAAAAAAAw/-LJyGal10o0/s400/wsext.gif" alt="" id="BLOGGER_PHOTO_ID_5111892161118887874" border="0" /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;Good luck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-8804047105673152330?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=VgROuhma2TA:wJJUhAIBrCc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=VgROuhma2TA:wJJUhAIBrCc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=VgROuhma2TA:wJJUhAIBrCc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/8804047105673152330/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/09/running-multiple-versions-of-aspnet-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8804047105673152330" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/8804047105673152330" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/VgROuhma2TA/running-multiple-versions-of-aspnet-on.html" title="Running multiple versions of ASP.NET on the same IIS" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_BktCNuR9VXg/RvEW1imYX8I/AAAAAAAAAAw/-LJyGal10o0/s72-c/wsext.gif" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/09/running-multiple-versions-of-aspnet-on.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-7084313480415124794</id><published>2007-09-10T13:42:00.000+02:00</published><updated>2007-09-19T14:40:08.625+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CCNET" /><category scheme="http://www.blogger.com/atom/ns#" term="Sandcastle" /><title type="text">Sandcastle crashes... code and pre tags</title><content type="html">Almost done with the current project release. Continuous server(&lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET"&gt;CCNET&lt;/a&gt;) is running,&lt;br /&gt;building - OK,&lt;br /&gt;unit tests - OK,&lt;br /&gt;analyzing - OK,&lt;br /&gt;compiling xml documentation -- Err&lt;br /&gt;&lt;br /&gt;Computer says:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Info: BuildAssembler: Building topic T:Sdo.Agent.TypeInstance`1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Unhandled Exception: System.Xml.XmlException: Unexpected end tag. Line 2, position 57.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlTextReaderImpl.Throw(Exception e)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlTextReaderImpl.Read()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlLoader.ParsePartialContent(XmlNode parentNode, String innerxmltext, XmlNodeType nt)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at System.Xml.XmlElement.set_InnerXml(String value)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at SandcastleBuilder.Components.CodeBlockComponent.Apply(XmlDocument document, String key)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at Microsoft.Ddue.Tools.BuildAssembler.Apply(IEnumerable`1 manifest)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at Microsoft.Ddue.Tools.BuildAssembler.Apply(String manifestFile)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;   at Microsoft.Ddue.Tools.BuildAssemblerConsole.Main(String[] args)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    Last step completed in 01:09:26.3530&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ok, so I checked the xml documentation for the class for mismatching tags, but couldn't find any.&lt;br /&gt;After a bit of searching I found the following post on the Sandcastle forums.&lt;br /&gt;&lt;a href="http://www.codeplex.com/SHFB/Thread/View.aspx?ThreadId=12084"&gt;http://www.codeplex.com/SHFB/Thread/View.aspx?ThreadId=12084&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A &amp;lt;pre&amp;gt; tag had snuck into the &amp;lt;code&amp;gt; xml documentation and thats not supported.&lt;br /&gt;&lt;br /&gt;Well you always learn something. =)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-7084313480415124794?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=aLTQ7XtyPX8:a4-xpyq27L8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=aLTQ7XtyPX8:a4-xpyq27L8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=aLTQ7XtyPX8:a4-xpyq27L8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/7084313480415124794/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/09/sandcastle-crashes-code-and-pre-tags.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7084313480415124794" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7084313480415124794" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/aLTQ7XtyPX8/sandcastle-crashes-code-and-pre-tags.html" title="Sandcastle crashes... code and pre tags" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/09/sandcastle-crashes-code-and-pre-tags.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-265870489349058059</id><published>2007-07-04T11:19:00.000+02:00</published><updated>2007-07-04T12:21:35.731+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Debugging" /><category scheme="http://www.blogger.com/atom/ns#" term="Oracle" /><category scheme="http://www.blogger.com/atom/ns#" term="Transaction" /><title type="text">AccessViolationException using Oracle and MTS</title><content type="html">I have been annoyed by a really irritating bug in my test environment for quite some time. I use oracle and enlists the connection in the MTS and when I try to open the connection I get different errors (and sometimes there isn't any errors).&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Oracle.DataAccess.Client.OracleException Data provider internal error(-3000)&lt;/li&gt;&lt;li&gt;Oracle.DataAccess.Client.OracleException : ORA-12514: TNS:listener does not currently know of service requested in connect descriptor&lt;/li&gt;&lt;/ul&gt;It has also crashed my nunit application and the nunit-console processes that our continuous integration server launches has also crashed.&lt;br /&gt;Searching for these errors have given several pointers where none was appropriate.&lt;br /&gt;&lt;br /&gt;Today I finally found the source of the error. I used adplus to get a crash dump of the nunit process.&lt;br /&gt;&lt;pre&gt;adplus -crash -pn nunit.exe&lt;/pre&gt;&lt;br /&gt;The adplus generated some dumps, log and a report. When I read the log I found a new error source. An AccessViolationError was thrown when oracle tried to enlist in the transaction.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Wed Jul  4 08:18:48.229 2007 (GMT+2): (c2c.9ec): Access violation - code c0000005 (first chance)&lt;br /&gt;---&lt;br /&gt;--- 1st chance AccessViolation exception ----&lt;br /&gt;---------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Occurrence happened at:&lt;br /&gt;Debug session time: Wed Jul  4 08:18:48.229 2007 (GMT+2)&lt;br /&gt;System Uptime: 0 days 16:37:08.859&lt;br /&gt;Process Uptime: 0 days 0:01:37.803&lt;br /&gt;Kernel time: 0 days 0:00:02.281&lt;br /&gt;User time: 0 days 0:00:05.093&lt;br /&gt;&lt;br /&gt;Faulting stack below ---&lt;br /&gt;*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\system32\msvcrt.dll -&lt;br /&gt;# ChildEBP RetAddr  Args to Child       &lt;br /&gt;WARNING: Stack unwind information not available. Following frames may be wrong.&lt;br /&gt;00 04cbdcdc 77bbcfdb 003f0000 00000000 000000e0 ntdll!RtlRestoreLastWin32Error+0x235&lt;br /&gt;01 04cbdcf0 77bba995 000000e0 00000000 0592a2f0 msvcrt!free+0x1a8&lt;br /&gt;02 04cbdd04 04d46612 000000e0 00000000 06e0b228 msvcrt!operator new+0x24&lt;br /&gt;03 04cbdd38 04ccc344 059468a0 0595e340 05918db0 ORAMTS10!kpntenlistctxget+0xe6&lt;br /&gt;04 00000000 00000000 00000000 00000000 00000000 OraOps10w!OpsConEnlist+0x3b4&lt;br /&gt;&lt;/pre&gt;Here we can see that the ORAMTS10.dll  is the source of the error. When I then googled on &lt;a href="http://www.google.se/search?q=access+violation+ORAMTS10&amp;ie=utf-8&amp;amp;amp;amp;amp;amp;amp;oe=utf-8&amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;client=firefox-a"&gt;access violation ORAMTS10&lt;/a&gt; I found the solution in the &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=548397&amp;amp;SiteID=1"&gt;Microsoft forum&lt;/a&gt; where Sahra Parra already had debugged the same issue from another source.&lt;br /&gt;&lt;br /&gt;The conclusion of the AccessViolation exception is that the ORAMTS10 contains a method that enlists the connection in the MTS. This method takes a parameter that contains the datasource name and when we pass a datasource longer than 40 characters, this results in that data in the heap is overwritten and resulted in a heap corruption.&lt;br /&gt;&lt;br /&gt;Heap corruptions are hard to debug since the error don't show up when the data is written. The error surfaces when the corrupted data is read which explains that the error messages differs (or not surfaces at all).&lt;br /&gt;In this case I got lucky and got an error in the ORAMTS10.dll that gave me a hint to the solution. To actually debug this issue and get error messages that occurs when the data is written, you have to use &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;286470"&gt;pageheap/gflag&lt;/a&gt; to let the error surface when the data is written.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To work around the bug in ORAMTS10 I only needed to change the Data Souce from the full (more than 40 characters) source name&lt;br /&gt;&lt;pre&gt;Data Source=(DESCRIPTION=(ADDRESS_LIST=&lt;br /&gt;(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.internal.com)(PORT=1521)))&lt;br /&gt;(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))&lt;/pre&gt;&lt;br /&gt;To the short version (requires a registration in tnsnames.ora)&lt;br /&gt;&lt;pre&gt;Data Source=oracle&lt;/pre&gt;&lt;br /&gt;When changed, the crashes went away and I'm so happy ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-265870489349058059?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=eUrMb77hJk8:0e2POddjf_M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=eUrMb77hJk8:0e2POddjf_M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=eUrMb77hJk8:0e2POddjf_M:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/265870489349058059/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/07/accessviolationexception-using-oracle.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/265870489349058059" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/265870489349058059" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/eUrMb77hJk8/accessviolationexception-using-oracle.html" title="AccessViolationException using Oracle and MTS" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/07/accessviolationexception-using-oracle.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-6161584797877159567</id><published>2007-06-28T16:04:00.000+02:00</published><updated>2007-06-28T16:12:50.473+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><category scheme="http://www.blogger.com/atom/ns#" term="Macros" /><title type="text">Documentator Macros version 2.5.1.0 released</title><content type="html">For you who are using Visual Studio 2005, the DocumentatorMacros is released in version 2.5.1. &lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;For more information about the macros, see &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;a style="font-style: italic;" href="http://www.codeproject.com/csharp/documentatormacros.asp"&gt;http://www.codeproject.com/csharp/documentatormacros.asp&lt;/a&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;The major reason for a new release is the support for restoring shortcuts after &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper 3.0&lt;/a&gt; has been installed. Apart from that, the new release only contains minor bugfixes and changes. See the included documentation for more information.&lt;br /&gt;&lt;br /&gt;Since I just posted the update to codeproject, the latest version is not available there yet.&lt;br /&gt;So in the meantime you can download it from &lt;a href="http://dan.meridium.se/DocumentatorMacros2.5.1.zip"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-6161584797877159567?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=xr_lBU_6b9c:Hl_Gg6XIKSE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=xr_lBU_6b9c:Hl_Gg6XIKSE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=xr_lBU_6b9c:Hl_Gg6XIKSE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/6161584797877159567/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/06/documentator-macros-version-2510.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6161584797877159567" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6161584797877159567" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/xr_lBU_6b9c/documentator-macros-version-2510.html" title="Documentator Macros version 2.5.1.0 released" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/06/documentator-macros-version-2510.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-5316163804360112136</id><published>2007-06-20T10:58:00.000+02:00</published><updated>2007-06-20T11:15:10.207+02:00</updated><title type="text">AdobeUpdater.exe hangs and cannot be killed</title><content type="html">&lt;p&gt;Today I have been experiencing a problem with adobes AdobeUpdater.exe. It takes 100% cpu usage and cannot be killed. The only way to get rid of it is to reboot and even  that don't always work. Sometimes a hard reset (a.k.a. da button) is the only effective solution.&lt;br /&gt;&lt;/p&gt;Searched a bit and found several others to have the same problem.&lt;br /&gt;&lt;br /&gt;Suggested solutions:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Rename&lt;br /&gt;&lt;pre&gt;c:\program files\Adobe\Updater5\AdobeUpdater.exe&lt;br /&gt;&lt;/pre&gt;to (for example)&lt;br /&gt;&lt;pre&gt;c:\program files\Adobe\Updater5\AdobeUpdater.exe.old&lt;br /&gt;&lt;/pre&gt;This will prevent the AdobeUpdater.exe from running.&lt;br /&gt;&lt;a href="http://www.nishv.com/2007/05/13/adobeupdaterexe-cpu-resource-hog/"&gt;( tip from Nish Vamadevans blog)&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Uninstall Adobe acrobat reader and use another software (like &lt;a href="http://www.foxitsoftware.com/pdf/rd_intro.php"&gt;Foxit&lt;/a&gt;)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Create an own Adobe installation package using the Adobe customization wizard 8 where you don't include the AdobeUpdater. See &lt;a href="http://blog.stealthpuppy.com/deployment/deploying-adobe-reader-81"&gt;Aaron Parker's stealthpuppy.com&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;Hopefully Adobe will release a patch for this, but so far (version 8.1) the issue has not been fixed.&lt;br /&gt;&lt;br /&gt;P.S. I went for solution 2, since I already had foxit installed. D.S.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-5316163804360112136?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=HsYWmPPRI1Y:6g6YDh6CzuA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=HsYWmPPRI1Y:6g6YDh6CzuA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=HsYWmPPRI1Y:6g6YDh6CzuA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/5316163804360112136/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/06/adobeupdaterexe-hangs-and-cannot-be.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5316163804360112136" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/5316163804360112136" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/HsYWmPPRI1Y/adobeupdaterexe-hangs-and-cannot-be.html" title="AdobeUpdater.exe hangs and cannot be killed" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/06/adobeupdaterexe-hangs-and-cannot-be.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-6009259152990413714</id><published>2007-06-12T07:45:00.001+02:00</published><updated>2007-06-12T16:33:52.794+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Generics" /><title type="text">Animals and Baboons explained</title><content type="html">I have been doing some research on the &lt;a href="http://dhvik.blogspot.com/2007/06/are-baboons-animals-in-generic-sense.html"&gt;Animal/Baboon generic issue&lt;/a&gt;.&lt;br /&gt;First I posted a &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282003"&gt;feedback&lt;/a&gt; on the Microsoft connect site and got some answers. This issue is referred as covariance.&lt;br /&gt;Covariance, &lt;a href="http://en.wikipedia.org/wiki/Covariance"&gt;in a mathematical definition&lt;/a&gt;, refers to how much two random variables varies together.&lt;br /&gt;Covariance, in this aspect, refers to on how you can assign two variables/types to each other. Normally (without covariance) we can only assign objects to variables that are part of their inheritance chain or cast up the inheritance chain.&lt;br /&gt;For instance&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;AccessViolationException ax = new AccessViolationException();&lt;br /&gt;//assign down the inheritance chain&lt;br /&gt;Exception ex = ax;&lt;br /&gt;//cast up the inheritance chain&lt;br /&gt;ax = ex as AccessViolationException;&lt;br /&gt;&lt;/pre&gt;We can also cast/assign to other types, but then it is up to the object to handle the cast/assignment by implementing the &lt;a href="http://msdn2.microsoft.com/en-us/library/xhbhezf4%28VS.80%29.aspx"&gt;explicit&lt;/a&gt; or &lt;a href="http://msdn2.microsoft.com/en-us/library/z5z9kes2%28VS.80%29.aspx"&gt;implicit&lt;/a&gt; operators for each type that it should support.&lt;br /&gt;&lt;br /&gt;When it comes to covariance, this is already implemented in the CLR and C# (like Java) uses covariance for its support on Arrays.&lt;br /&gt;To illustrate this we can use our Animal/Baboon/List&amp;lt;T&amp;gt; example.&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;List&amp;lt;Animal&amp;gt; myAnimalList;&lt;br /&gt;List&amp;lt;Baboon&amp;gt; myBaboonList;&lt;br /&gt;myAnimalList = myBaboonList; //gives a compiler error&lt;br /&gt;&lt;/pre&gt;The code above gererated a compiler error since we cannot convert the Baboon List to an Animal List. Baboon inherits Animal but List&amp;lt;Baboon&amp;gt; does not inherit List&amp;lt;Animal&amp;gt; and thus cannot  be assigned to each others. But what happens if we do the same with arrays?&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;Baboon[] myBaboons = null;&lt;br /&gt;Animal[] myAnimals;&lt;br /&gt;myAnimals = myBaboons; //this works!?&lt;br /&gt;&lt;/pre&gt;How is this possible? Baboon[] does not inherit Animal[]. All arrays inherits System.Array.&lt;br /&gt;This is because System.Array uses Covariance in the CLR to allow such a structure. Observe that the opposite is not possible&lt;br /&gt;&lt;pre name="code" class="c-sharp:nocontrols:nogutter"&gt;myBaboons = myAnimals; //gives a compiler error&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is called Contravariant and is not used by Arrays.&lt;br /&gt;&lt;br /&gt;For now there is no other object or class that uses co/contra-variance in C# but since the feature is included in the CLI, you could build an own C# compiler that supports it.&lt;br /&gt;Microsoft will not include the support in C# v3 but according to Mads Torgersen they are "actively looking at supporting it in the next version of the language after that".&lt;br /&gt;If you would like more reading on the subject, I can recommend the following sources that have given me much input.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/rmbyers/archive/2005/02/16/375079.aspx"&gt;Rick Byers: Generic type parameter variance in the CLR&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/rmbyers/archive/2006/06/01/613690.aspx"&gt;Rick Byers: More on generic variance&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://wesnerm.blogs.com/net_undocumented/2005/07/array_covarianc.html"&gt;Smart software: Array Covariance Among Enums&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://chrisdonnan.com/blog/2007/02/03/generics-lack-covariance-contravariance/"&gt;Cris Donnan: Generics lack covariance/ contravariance&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-6009259152990413714?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=ozP_kDTRfvc:vIuLCZLA4Ko:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=ozP_kDTRfvc:vIuLCZLA4Ko:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=ozP_kDTRfvc:vIuLCZLA4Ko:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/6009259152990413714/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/06/animals-and-baboons-explained.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6009259152990413714" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/6009259152990413714" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/ozP_kDTRfvc/animals-and-baboons-explained.html" title="Animals and Baboons explained" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/06/animals-and-baboons-explained.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-6908201609754153877.post-7055475211959046424</id><published>2007-06-08T10:03:00.001+02:00</published><updated>2007-06-08T10:17:01.257+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Swedish" /><category scheme="http://www.blogger.com/atom/ns#" term="fun" /><title type="text">Why I ever left Unix (swedish only, sorry)</title><content type="html">När man kör sin playlist på shuffle så vet man aldrig var man får tag på, speciellt om man aldrig rensar bland sina filer.&lt;br /&gt;Lyssna på denna för att få svar på frågan...&lt;br /&gt;&lt;embed  src="http://dan.meridium.se/files/audio/unix.mp3" autostart="false" height="24" width="250"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;a href="http://dan.meridium.se/files/audio/unix.mp3"&gt;Download&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6908201609754153877-7055475211959046424?l=dhvik.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=PlkRF-JLIEo:NSzQhWRMwZc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?a=PlkRF-JLIEo:NSzQhWRMwZc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/DevelopingDotnetArchitect?i=PlkRF-JLIEo:NSzQhWRMwZc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://dhvik.blogspot.com/feeds/7055475211959046424/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://dhvik.blogspot.com/2007/06/why-i-ever-left-unix-swedish-only-sorry.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7055475211959046424" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6908201609754153877/posts/default/7055475211959046424" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DevelopingDotnetArchitect/~3/PlkRF-JLIEo/why-i-ever-left-unix-swedish-only-sorry.html" title="Why I ever left Unix (swedish only, sorry)" /><author><name>Dan</name><uri>http://www.blogger.com/profile/14787263872119403136</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="07227970014261223640" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dhvik.blogspot.com/2007/06/why-i-ever-left-unix-swedish-only-sorry.html</feedburner:origLink></entry></feed>
