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

<channel>
	<title>Sander van Vliet &#187; C# 4.0</title>
	<atom:link href="http://barad-dur.nl/category/net/c-4-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://barad-dur.nl</link>
	<description>Land Rovers, .Net en meer!</description>
	<lastBuildDate>Fri, 11 Nov 2011 07:46:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>TFDP &#8211; T4 For Database Projects</title>
		<link>http://barad-dur.nl/net/c-4-0/tfdp-t4-for-database-projects/</link>
		<comments>http://barad-dur.nl/net/c-4-0/tfdp-t4-for-database-projects/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 16:16:12 +0000</pubDate>
		<dc:creator>Sander</dc:creator>
				<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[T4]]></category>
		<category><![CDATA[TFDP]]></category>
		<category><![CDATA[VS2010]]></category>
		<category><![CDATA[VSTDB]]></category>

		<guid isPermaLink="false">http://barad-dur.nl/?p=191</guid>
		<description><![CDATA[After working on this for some time, I&#8217;ve decided that it was time to publish TFDP to a wider audience. TFDP provides T4 template processing in Visual Studio 2010 database projects. Something that isn&#8217;t possible in the current versions. The extension can be found in the Visual Studio Gallery and on Codeplex.]]></description>
			<content:encoded><![CDATA[<p>After working on this for some time, I&#8217;ve decided that it was time to publish TFDP to a wider audience. TFDP provides T4 template processing in Visual Studio 2010 database projects. Something that isn&#8217;t possible in the current versions.</p>
<p>The extension can be found in the <a title="TFDP on the Visual Studio Gallery" href="http://visualstudiogallery.msdn.microsoft.com/c7ae9467-b464-405f-b01d-f6f97a595782" target="_blank">Visual Studio Gallery</a> and on <a title="TFDP on Codeplex" href="http://tfdp.codeplex.com/" target="_blank">Codeplex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://barad-dur.nl/net/c-4-0/tfdp-t4-for-database-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Export Locals</title>
		<link>http://barad-dur.nl/net/export-locals/</link>
		<comments>http://barad-dur.nl/net/export-locals/#comments</comments>
		<pubDate>Wed, 11 May 2011 06:00:09 +0000</pubDate>
		<dc:creator>Sander</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://barad-dur.nl/?p=174</guid>
		<description><![CDATA[Introduction: In this forum thread (warning: Dutch) someone was complaining that it&#8217;s not really easy to export the contents of the Locals debug window to a XML file. I&#8217;ve neved had the need for that myself but I thought, it can&#8217;t be that hard. Turns out it isn&#8217;t. I&#8217;ve written a VS2010 add-in that adds <a href="http://barad-dur.nl/net/export-locals/" class="more-link">Meer &#62;</a>]]></description>
			<content:encoded><![CDATA[<h2>Introduction:</h2>
<p>In this <a href="http://gathering.tweakers.net/forum/list_message/36005948#36005948" target="_blank">forum thread</a> (warning: Dutch) someone was complaining that it&#8217;s not really easy to export the contents of the Locals debug window to a XML file. I&#8217;ve neved had the need for that myself but I thought, it can&#8217;t be that hard. Turns out it isn&#8217;t.</p>
<p>I&#8217;ve written a VS2010 add-in that adds a menu item to the Tools menu in Visual Studio that will export all the locals for the current stack frame and open the XML file in Visual Studio. As always a picture says more than a thousand words so see for yourself:</p>
<p>A program in debug mode, notice the Locals window in the left bottom:</p>
<p><a href="http://barad-dur.nl/wp-content/uploads/2011/05/debug1.png" rel="lightbox[174]"><img class="alignnone size-medium wp-image-175" title="debug1" src="http://barad-dur.nl/wp-content/uploads/2011/05/debug1-300x204.png" alt="" width="300" height="204" /></a></p>
<p>Export the locals via the menu option:</p>
<p><a href="http://barad-dur.nl/wp-content/uploads/2011/05/debug2.png" rel="lightbox[174]"><img class="alignnone size-medium wp-image-176" title="debug2" src="http://barad-dur.nl/wp-content/uploads/2011/05/debug2-300x204.png" alt="" width="300" height="204" /></a></p>
<p>The exported XML document is opened in Visual Studio:</p>
<p><a href="http://barad-dur.nl/wp-content/uploads/2011/05/debug3.png" rel="lightbox[174]"><img class="alignnone size-medium wp-image-177" title="debug3" src="http://barad-dur.nl/wp-content/uploads/2011/05/debug3-300x204.png" alt="" width="300" height="204" /></a></p>
<p>For now it will export to 2 levels deep, any more than that will make it incredibly slow.</p>
<h2>Downloads:</h2>
<p>The VSIX can be downloaded here: <a href="http://barad-dur.nl/wp-content/uploads/2011/05/ExportLocals.vsix">ExportLocals.vsix</a></p>
<p>The sources can be downloaded here: <a href="http://barad-dur.nl/wp-content/uploads/2011/05/ExportLocals.zip">ExportLocals.zip</a></p>
<p>Or you can install the add in via the <a href="http://visualstudiogallery.msdn.microsoft.com/4f15c2aa-58f1-4323-b0f5-a2663142cd51" target="_blank">Visual Studio Gallery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://barad-dur.nl/net/export-locals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom WSDL for WCF Workflow Service</title>
		<link>http://barad-dur.nl/net/wcf-workflow-service/</link>
		<comments>http://barad-dur.nl/net/wcf-workflow-service/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 09:17:52 +0000</pubDate>
		<dc:creator>Sander</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WF]]></category>

		<guid isPermaLink="false">http://barad-dur.nl/?p=165</guid>
		<description><![CDATA[I&#8217;m currently working on a webservice layer for our main application so we can interface with our existing BizTalk applications. Because I like using new technologies I&#8217;ve decided to use WCF Workflow services to implement the logic of these services. With WF4 and the FlowDiagram features it&#8217;s very easy to do this and really, really <a href="http://barad-dur.nl/net/wcf-workflow-service/" class="more-link">Meer &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a webservice layer for our main application so we can interface with our existing BizTalk applications. Because I like using new technologies I&#8217;ve decided to use WCF Workflow services to implement the logic of these services. With WF4 and the FlowDiagram features it&#8217;s very easy to do this and really, really quick to build the services.</p>
<p>One slight problem I&#8217;ve discovered is that the C# types we use in the ReceiveRequest activity are generated from a custom XSD and the WSDL generated by the workflow service doesn&#8217;t reference that schema but generates a new one. Normally this isn&#8217;t that much of a problem, simply create a custom WSDL and set the externalMetadataLocation option in the web.config:</p>
<pre>&lt;behavior name="MyServiceBehavior"&gt;
   &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
   &lt;serviceMetadata httpGetEnabled="true" externalMetadataLocation="../MyService.wsdl" /&gt;
&lt;/behavior&gt;</pre>
<p>Contrary to popular belief, this doesn&#8217;t work! The workflow service still gives it&#8217;s WSDL as being MyService.xamlx?wsdl instead of the custom WSDL. After some Google-ing (is that a word?) I found that there was something missing: a binding. More specific: a mexHttpBinding. It seems that without specifying the Metadata Exchange the workflow service will continue to provide it&#8217;s own idea of the WSDL and ignores the WSDL specified in the externalMetadataLocation.</p>
<p>Fortunately the fix is easy. Add a new endpoint to the service configuration that uses the mexHttpBinding:</p>
<pre>&lt;service name="MyService" behaviorConfiguration="MyServiceBehavior"&gt;
   &lt;endpoint binding="mexHttpBinding" contract="IMetadataExchange" address="mex" /&gt;
&lt;/service&gt;</pre>
<p>After adding this and refreshing the workflow service in the browser it now correctly shows the custom WSDL!</p>
]]></content:encoded>
			<wfw:commentRss>http://barad-dur.nl/net/wcf-workflow-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net 4.0 WinForm Data Binding bug</title>
		<link>http://barad-dur.nl/net/net-4-0-winform-data-binding-bug/</link>
		<comments>http://barad-dur.nl/net/net-4-0-winform-data-binding-bug/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 09:37:35 +0000</pubDate>
		<dc:creator>Sander</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C# 4.0]]></category>

		<guid isPermaLink="false">http://barad-dur.nl/?p=158</guid>
		<description><![CDATA[Currently I&#8217;m busy with converting a .Net 2.0 WinForms application to .Net 4.0 in VS2010. Seemed to work pretty smooth but when testing one of the more complex windows in the application I hit a snag. Upon opening the window I got a &#8220;TargetException: Object does not match target type.&#8221; thrown in my face. After <a href="http://barad-dur.nl/net/net-4-0-winform-data-binding-bug/" class="more-link">Meer &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Currently I&#8217;m busy with converting a .Net 2.0 WinForms application to .Net 4.0 in VS2010. Seemed to work pretty smooth but when testing one of the more complex windows in the application I hit a snag. Upon opening the window I got a &#8220;TargetException: Object does not match target type.&#8221; thrown in my face. After a quick tour with the debugger I found the problem: data binding didn&#8217;t work anymore!</p>
<p>To find out what the real problem was I&#8217;ve built a test application that basically does the same thing as the complex window that is giving me such a headache.<span id="more-158"></span> So here goes:</p>
<p>I have a class like this:</p>
<pre>public class Base {
    public string Property1 { get; set; }
    public Sub SubItem { get; set; }

    public Base() {
        Property1 = "Base Property1";
        SubItem = new Sub();
}
public class Sub {
    public string Property1 { get; set; }

    public Sub() {
        Property1 = "Sub Property1";
    }
}
</pre>
<p>Which is bound to a TextBox:</p>
<pre>private void buttonBind_Click(object sender, EventArgs e) {
    Base b = new Base();

    // This works
    textBox1.DataBindings.Add("Text", b.SubItem, "Property1");

    // This doesn't work
    textBox2.DataBindings.Add("Text", b, "SubItem.Property1");
}
</pre>
<p>Now the first binding will work but the second one will throw a TargetException. I have no clue why this happens but the message of the exception and the stack trace give some hints that this is a reflection problem. However the binding specifies to bind a string property to a string property so that shouldn&#8217;t be a problem.</p>
<p>A workaround for this problem is to use a BindingSource:</p>
<pre>private void buttonBind_Click(object sender, EventArgs e) {
    Base b = new Base();
    BindingSource bs = new BindingSource(b, null); // Use a empty datamember

    // Now it will work
    textBox2.DataBindings.Add("Text", bs, "SubItem.Property1");
}</pre>
<p>But it&#8217;s quite a lot of work to replace this in the current application so I hope this gets fixed soon.</p>
<p>In the meanwhile I&#8217;ve filed a bug report at Microsoft Connect (see <a href="https://connect.microsoft.com/VisualStudio/feedback/details/552853/net-4-0-simple-binding-issue?wa=wsignin1.0" target="_blank">here</a>) with sample code that demonstrates the behavior so you can test for yourself. If you do, please vote on Microsoft Connect to get it under their attention!</p>
]]></content:encoded>
			<wfw:commentRss>http://barad-dur.nl/net/net-4-0-winform-data-binding-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

