<?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>Alkampfer&#039;s Place&#187; .NET framework</title>
	<atom:link href="http://www.codewrecks.com/blog/index.php/category/net-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codewrecks.com/blog</link>
	<description>Wrecks of code floating in the sea of Internet By Ricci Gian Maria</description>
	<lastBuildDate>Wed, 08 Feb 2012 17:49:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Entity Framework error 3002 on views when model updated</title>
		<link>http://www.codewrecks.com/blog/index.php/2012/01/25/entity-framework-error-3002-on-views-when-model-updated/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2012/01/25/entity-framework-error-3002-on-views-when-model-updated/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 09:35:00 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2012/01/25/entity-framework-error-3002-on-views-when-model-updated/</guid>
		<description><![CDATA[One of the most annoying problem with the first version of entity Framework is that you have barely no option other than go with “Database First approach”, and when you start mapping database views your life started to become difficult. The first obvious problem is that the designer, during the import phase from database, try [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2012%2F01%2F25%2Fentity-framework-error-3002-on-views-when-model-updated%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2012%2F01%2F25%2Fentity-framework-error-3002-on-views-when-model-updated%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Entity+Framework&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the most annoying problem with the first version of <a target="_blank" title="entity" href="http://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks_of_DDD">entity</a> Framework is that you have barely no option other than go with “Database First approach”, and when you start mapping database views your life started to become difficult. </p>
<p>The first obvious problem is that the designer, during the import phase from database, try to detect in the view any not-null column and make it part of the primary key of the <a target="_blank" title="entity" href="http://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks_of_DDD">entity</a>. If you decide to live with it (and having entities with lot of field used as primary keys), you probably will incur in the error 3002 when you update a view and then update the model from database.</p>
<p>The problem happens if you change the definition of the view, and a column that was not null, became nullable by the modification. What it happens is usually that the designer still mark the corresponding property of the entity as primary key a situation that is not admitted if the field in the database is NULL. If this is your situation you can usually fix it going to “mapping details” of the view that raise the error.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image7.png"><img style="border: 0px currentcolor; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image_thumb7.png" width="663" height="272" /></a></p>
<p><strong>Figure 1: </strong><em>A view with error, the StartDate becomes nullable in the view, but the entity still uses it at key</em></p>
<p>The problem is depicted in <strong>Figure 1</strong>, you can see in the left that StartDate is not a key of the database model, because I changed the view and now the StartDate admit NULL value, but in the right part, the model still uses that property as a key.</p>
<p>The fix is easy, just select the StartDate property in the model, then in properties windows set to false the <strong>EntityKey</strong> property, set the <strong>Nullable</strong> property to true and the error should go away.</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2012/01/25/entity-framework-error-3002-on-views-when-model-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Design time data in WPF and Blend with little effort</title>
		<link>http://www.codewrecks.com/blog/index.php/2012/01/20/design-time-data-in-wpf-and-blend-with-little-effort/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2012/01/20/design-time-data-in-wpf-and-blend-with-little-effort/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 18:57:30 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Blend]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2012/01/20/design-time-data-in-wpf-and-blend-with-little-effort/</guid>
		<description><![CDATA[The power of WPF binding really shines when you use design time data to have a live preview of the aspect of your UI without the need to press F5 to load actual data. Design time data is a cool feature you can have with little effort, suppose you have a simple windows and you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2012%2F01%2F20%2Fdesign-time-data-in-wpf-and-blend-with-little-effort%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2012%2F01%2F20%2Fdesign-time-data-in-wpf-and-blend-with-little-effort%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=Blend,WPF&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The power of WPF binding really shines when you use design time data to have a live preview of the aspect of your UI without the need to press F5 to load actual data. Design time data is a cool feature you can have with little effort, suppose you have a simple windows and you want to show a list of customers, taken from the northwind datadabase inside a Listbox, personlizing the DataTemplate.</p>
<p>I start with&#160; simple ViewModelBase, that is really far to be a real Base View Model to implement a full <a title="MVVM" href="http://www.codewrecks.com/blog/index.php/tag/mvvm/">MVVM</a> solution, but it serves me to show how to use design time data without scare people telling them to implement complex <a title="patterns" href="http://www.codewrecks.com/blog/index.php/tag/patterns/">patterns</a> or similar stuff.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">abstract</span> <span style="color: rgb(0, 0, 255);">class</span> ViewModelBase : MarkupExtension, INotifyPropertyChanged</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>     <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">event</span> PropertyChangedEventHandler PropertyChanged;</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum5">   5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum6">   6:</span>     <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">virtual</span> <span style="color: rgb(0, 0, 255);">void</span> OnPropertyChanged(String propertyName)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum7">   7:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum8">   8:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum9">   9:</span>         var temp = PropertyChanged;</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum10">  10:</span>         <span style="color: rgb(0, 0, 255);">if</span> (temp != <span style="color: rgb(0, 0, 255);">null</span>)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum11">  11:</span>         {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum12">  12:</span>             temp(<span style="color: rgb(0, 0, 255);">this</span>, <span style="color: rgb(0, 0, 255);">new</span> PropertyChangedEventArgs(propertyName));</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum13">  13:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum14">  14:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum15">  15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum16">  16:</span>     <span style="color: rgb(0, 0, 255);">private</span> DependencyObject syncRoot = <span style="color: rgb(0, 0, 255);">new</span> DependencyObject();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum17">  17:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum18">  18:</span>     <span style="color: rgb(0, 0, 255);">protected</span> Boolean IsInDesignMode</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum19">  19:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum20">  20:</span>         get { <span style="color: rgb(0, 0, 255);">return</span> DesignerProperties.GetIsInDesignMode(syncRoot); }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum21">  21:</span>     }</pre>
<p><!--CRLF--></div>
</div>
<p>This is really simple base class that implements INotifyPropertyChanged and inherits from MarkupExtension, it has also an IsInDesign mode property to detect if the code is running inside a designer.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">abstract</span> <span style="color: rgb(0, 0, 255);">void</span> CommonInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span> <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">abstract</span> <span style="color: rgb(0, 0, 255);">void</span> RuntimeInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum5">   5:</span> <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">abstract</span> <span style="color: rgb(0, 0, 255);">void</span> DesignTimeInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum7">   7:</span> <span style="color: rgb(0, 0, 255);">protected</span> ViewModelBase()</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum8">   8:</span> {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum9">   9:</span>     <span style="color: rgb(0, 0, 255);">this</span>.CommonInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum10">  10:</span>     <span style="color: rgb(0, 0, 255);">if</span> (!IsInDesignMode)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum11">  11:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum12">  12:</span>         <span style="color: rgb(0, 0, 255);">this</span>.RuntimeInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum13">  13:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum14">  14:</span> }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum15">  15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum16">  16:</span> <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">object</span> ProvideValue(IServiceProvider serviceProvider)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum17">  17:</span> {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum18">  18:</span>     <span style="color: rgb(0, 0, 255);">this</span>.DesignTimeInit();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum19">  19:</span>     <span style="color: rgb(0, 0, 255);">return</span> <span style="color: rgb(0, 0, 255);">this</span>;</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum20">  20:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Then I defined three abstract methods, the first is called CommonInit() and is used to do common initialization, then the RuntimeInit() is called to do all initialization I do not want to do when the viewmodel is used inside the designer, finally the DesignTimeInit() is called when the object is constructed inside the Designer. The trick is that the constructor call the RuntimeInit() only when we are outside the designer and the DesignTimeInit() is simply called inside the ProvideValue() virtual method of the base MarkupExtension class</p>
<p>Then I create a MainWindowViewModel inheriting from this class, add an ObservableCollection&lt;Customers&gt; to show data and implemented the initialization methods, the RuntimeInit() loads data from database.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> RuntimeInit()</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span>  {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span>      <span style="color: rgb(0, 0, 255);">using</span> (NorthWind context = <span style="color: rgb(0, 0, 255);">new</span> NorthWind())</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>      {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum5">   5:</span>          <span style="color: rgb(0, 0, 255);">foreach</span> (var customer <span style="color: rgb(0, 0, 255);">in</span> context.Customers)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum6">   6:</span>          {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum7">   7:</span>              LoadedCustomers.Add(customer);</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum8">   8:</span>          }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum9">   9:</span>      }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum10">  10:</span>  }</pre>
<p><!--CRLF--></div>
</div>
<p>Then in the DesignTimeInit() I create some fake objects that will be used by the designer, you can do it simple using Fizzware NBuilder library.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> DesignTimeInit()</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span>     <span style="color: rgb(0, 0, 255);">for</span> (<span style="color: rgb(0, 0, 255);">int</span> i = 0; i &lt; 10; i++)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum5">   5:</span>         Customers customerDummy = FizzWare.NBuilder.Builder&lt;Customers&gt;.CreateNew().Build();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum6">   6:</span>         LoadedCustomers.Add(customerDummy);</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum7">   7:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum8">   8:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>Now I fire <a title="blend" href="http://www.codewrecks.com/blog/index.php/tag/blend/">blend</a> and open the solution, create a windows then add the design time data context to the first Grid control</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">Grid</span> <span style="color: rgb(255, 0, 0);">d:DataContext</span><span style="color: rgb(0, 0, 255);">=&quot;{sampleproject:MainWindowViewModel}&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>This will call the ProvideValue of the MarkupExtension class, so the object will be constructed with some dummy design data, then I drop a ListBox inside the window and bind its ItemsSource property with designer</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image3.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image_thumb3.png" width="778" height="551" /></a></p>
<p><strong>Figure 1: </strong><em>Bind with designer</em></p>
<p>The cool part is that the designer correctly recognize the ViewModel inside the DataContext and shows me the list of properties that can be bound to the ItemsControl property. Now I right click the ListBox and ask <a title="blend" href="http://www.codewrecks.com/blog/index.php/tag/blend/">blend</a> to edit the ItemTemplate, then create a simple layout with a border and a 2&#215;2 grid.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image4.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image_thumb4.png" width="607" height="309" /></a></p>
<p><strong>Figure 2: </strong><em>The layout for the DataTemplate of the ListBox</em></p>
<p>Now that I created the grid with four cells, I need to bind the label of the second column to the right properties of the Customers object, so I simply select the label, then ask to DataBind the Content:</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image5.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image_thumb5.png" width="830" height="528" /></a></p>
<p><strong>Figure 3: </strong><em>Thanks to Design Time Data, blend designer can use reflection to understand the properties of the Customers Object, so we can easily choose the property to bind</em></p>
<p>The cool part is that the interface in the designer immediately reflects the result with the Design Time Data</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image6.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2012/01/image_thumb6.png" width="438" height="225" /></a></p>
<p><strong>Figure 4: </strong><em>Designer uses design time data to render the interface directly inside the designer</em></p>
<p>This is a killer feature because permits you to have a real look at how the UI will be rendered with data. </p>
<p><a href="http://www.codewrecks.com/Files/DesignDataTemplate.zip">Code sample is here</a>.</p>
<p>Gian Maria</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2012/01/20/design-time-data-in-wpf-and-blend-with-little-effort/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to test SSL based WCF services</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/11/21/how-to-test-ssl-based-wcf-services/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/11/21/how-to-test-ssl-based-wcf-services/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 11:35:49 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[Wcf]]></category>
		<category><![CDATA[WCF IIS7]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/11/21/how-to-test-ssl-based-wcf-services/</guid>
		<description><![CDATA[I usually work with WCF service that needs to be secured with Certificates or simply using HTTPS. The usual question from other dev in the team is “how can I simulate HTTPS to work with WCF?” The problem arise that to test https sites, people usually work with IIS self issued certificates. Figure 1: Self-Signed [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F21%2Fhow-to-test-ssl-based-wcf-services%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F21%2Fhow-to-test-ssl-based-wcf-services%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=IIS,SSL,Wcf,WCF+IIS7&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I usually work with WCF service that needs to be secured with Certificates or simply using HTTPS. The usual question from other dev in the team is “how can I simulate HTTPS to work with WCF?”</p>
<p>The problem arise that to <a title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a> https sites, people usually work with IIS self issued certificates.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLa82f3d.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="SNAGHTMLa82f3d" border="0" alt="SNAGHTMLa82f3d" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLa82f3d_thumb.png" width="529" height="233" /></a></p>
<p><strong>Figure 1: </strong><em>Self-Signed certificate in IIS</em></p>
<p>This works great for sites, you can use the auto signed certificate in your sites in https binding, then when you navigate to the site you usually got an error because the certificate is not issued for the right site. What I need is usually to modifiy the hosts file in windows, creating an alias of <a target="_blank" href="http://www.mydomain.com">www.mydomain.com</a> to 127.0.0.1, so I can directly point to the right address with WCF client application and can simply manage to use the local or remote service simply modifying the hosts file.</p>
<p>Sadly enough, WCF does not tolerate problem in certificates and this makes useless working with Self-Signed Certificate. To be able to use a WCF Service secured with SSL in your dev machine you should issue yourself a valid certificate. The solution is using the SelfSSL.exe tool that comes with the <a target="_blank" href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=17275">IIS6 Resource Kit Tools</a>.</p>
<p>Once installed you can simply go to installation folder with Administrator Command Prompt (you need to launch the command prompt as administrator or it wont work) and simply create a valid certificate with this command line   </p>
<p><strong><em>Selfssl /N:CN=www.codewrecks.com /V :2000 /S:3</em></strong></p>
<p>as you can see with the option /N:CN you are able to specify the Common Name you want to use, the /V option is used to specify the duraction in years of the certificate, and the /S: is used to specify the Id of the site you want to change, just select the “site” node on IIS7 administration console to see the ID assigned to each site.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image4.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image_thumb4.png" width="577" height="129" /></a></p>
<p><strong>Figure 2: </strong><em>How to find Site ID from IIS administration console</em></p>
<p>Now your site should have https binding enabled and it should use the autogenerated certificate, but if you browse the site your browser is still telling you that the certificate is not valid. If you open your certificate from the IIS administration console (just select the root node with your computer name and select <em>Server Certificates</em> from the IIS section on the right and double click on the desidered certificate) you can verify the error.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLb106f5.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="SNAGHTMLb106f5" border="0" alt="SNAGHTMLb106f5" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLb106f5_thumb.png" width="419" height="521" /></a></p>
<p><strong>Figure 3: </strong><em>The certificate is not valid because the certification authority is not trusted</em></p>
<p>The problem is that the Certification Authority of this certificate is not trusted, so you need to export this certificate to a file, just right-click the certificate and choose “Export”. (remember that you should choose a password to export the certificate)</p>
<p>Now open the mmc certification snap in (just Start-&gt;Run-&gt;<strong>mmc.exe certmgr.msc</strong>) and choose to import the certificate you just exported</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image5.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image_thumb5.png" width="384" height="239" /></a></p>
<p><strong>Figure 4: </strong><em>Import the certificate from the Certificates manager.</em></p>
<p>Choose the file you previously exported, insert the password you used for the export, then proceed to import the certificates. At the end of the operation, if you open again the certificate from the IIS administration console, everything should be ok.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image6.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image_thumb6.png" width="415" height="237" /></a></p>
<p><strong>Figure 5: </strong><em>The certificate is now ok and can be used to secure your sites</em></p>
<p>If this does not works, and you still got errors when you browse your local site through Https, probably the certificate was imported in the wrong path, just import the exported certificate again as shown in <strong>figure 4, </strong>but when you are asked for the location where you want to import the certificate press the button browse (<strong>Figure 6</strong>)</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image7.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/image_thumb7.png" width="497" height="259" /></a></p>
<p><strong>Figure 6: </strong><em>Import the certificate to a specified location.</em></p>
<p>Now choose the location as shown in <strong>Figure 7 </strong>and everything should work ok.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLbcf691.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="SNAGHTMLbcf691" border="0" alt="SNAGHTMLbcf691" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/11/SNAGHTMLbcf691_thumb.png" width="295" height="269" /></a></p>
<p><strong>Figure 7:</strong><em> Choose the exact location where to import the certificate.</em></p>
<p>Now modify the hosts file, mount your WCF service and verify with WCF <a title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a> client that everything is ok.</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/11/21/how-to-test-ssl-based-wcf-services/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Disable Javascript errors in WPF Web Browser Control take2</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/11/17/disable-javascript-errors-in-wpf-web-browser-control-take2/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/11/17/disable-javascript-errors-in-wpf-web-browser-control-take2/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 15:59:08 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/11/17/disable-javascript-errors-in-wpf-web-browser-control-take2/</guid>
		<description><![CDATA[I’ve dealt with this problem some time ago and the solution I posted worked well, but requires you to manipulate the content of the page, injecting script on the DOM. If you want to get rid of annoying messagebox with javascript error, there is another solution based on simply setting the Silent property on the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F17%2Fdisable-javascript-errors-in-wpf-web-browser-control-take2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F11%2F17%2Fdisable-javascript-errors-in-wpf-web-browser-control-take2%2F&amp;source=alkampfer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I’ve dealt with this problem <a href="http://www.codewrecks.com/blog/index.php/2010/08/31/disable-javascript-error-in-wpf-webbrowser-control/">some time ago</a> and the solution I posted worked well, but requires you to manipulate the content of the page, injecting script on the DOM. If you want to get rid of annoying messagebox with <a title="javascript" href="http://www.codewrecks.com/blog/index.php/tag/javascript/">javascript</a> error, there is another solution based on simply setting the Silent property on the AXIWebBrowser2 COM control. </p>
<p>The full solution <a target="_blank" href="http://www.brentlamborn.com/post/WPF-Web-Browser-ScriptErrorsSupressed.aspx">was described here</a> by Brent Lamborn and is a pretty good solution that does not require you to manipulate the content of the DOM. The Silent property of the AXIWebBrowser2 control is probably the same Property that you can set through the <em>ScriptErrorSuppressed </em>property of the winform version of <a title="WebBrowser" href="http://www.codewrecks.com/blog/index.php/tag/webbrowser/">WebBrowser</a> control. </p>
<p>I wonder why this property was not ported to the WPF version of the control.</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/11/17/disable-javascript-errors-in-wpf-web-browser-control-take2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The strangest bug of IE I&#8217;ve ever seen</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/09/07/the-strangest-bug-of-ie-ive-ever-seen/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/09/07/the-strangest-bug-of-ie-ive-ever-seen/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 15:57:51 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/09/07/the-strangest-bug-of-ie-ive-ever-seen/</guid>
		<description><![CDATA[We have a web application written in asp.net and we experienced really strange problem after recent modification. We have a strange behavior in IE9 with redirects and after some inspection we found a really strange fact (that almost make us lost 2 hours of work). To recreate this situation simply create a new page in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F07%2Fthe-strangest-bug-of-ie-ive-ever-seen%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F09%2F07%2Fthe-strangest-bug-of-ie-ive-ever-seen%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=ASP.NET&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We have a web application written in <a title="asp.net" href="http://www.codewrecks.com/blog/index.php/category/net-framework/aspnet/">asp.net</a> and we experienced really strange problem after recent modification. We have a strange behavior in IE9 with redirects and after some inspection we found a really strange fact (that almost make us lost 2 hours of work). To recreate this situation simply create a new page in an <a title="asp.net" href="http://www.codewrecks.com/blog/index.php/category/net-framework/aspnet/">asp.net</a> site, and put this code in it.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">form</span> <span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">=&quot;form1&quot;</span> <span style="color: rgb(255, 0, 0);">runat</span><span style="color: rgb(0, 0, 255);">=&quot;server&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span> <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span>     <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">label</span> <span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">=&quot;queuecount&quot;</span>  <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>     <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">asp:ImageButton</span> <span style="color: rgb(255, 0, 0);">ID</span><span style="color: rgb(0, 0, 255);">=&quot;ImageButton1&quot;</span> <span style="color: rgb(255, 0, 0);">runat</span><span style="color: rgb(0, 0, 255);">=&quot;server&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum5">   5:</span>     <span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">a</span> <span style="color: rgb(255, 0, 0);">href</span><span style="color: rgb(0, 0, 255);">=&quot;http://www.microsoft.com&quot;</span><span style="color: rgb(0, 0, 255);">&gt;</span>microsoft<span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">a</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum6">   6:</span> <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">div</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum7">   7:</span> <span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">form</span><span style="color: rgb(0, 0, 255);">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>Now simply run this page with fiddler opened, you should see a simple broken image and a standard anchor tag. Now click on the link and look at what happened with fiddler.</p>
<p><a href="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/image.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image" border="0" alt="image" src="http://www.codewrecks.com/blog/wp-content/uploads/2011/09/image_thumb.png" width="480" height="106" /></a></p>
<p>Internet explorer issue the request to <a target="_blank" href="http://www.microsoft.com">www.microsoft.com</a>, but immediately after he request the original asp.ner page in POST. The order of the two requests varies, sometimes the <a target="_blank" title="test" href="http://www.codewrecks.com/blog/index.php/2007/09/03/test/">test</a>.aspx POST is done before requesting the link, and the user navigates to <a href="http://www.microsoft.com">www.microsoft.com</a>, but if the order is reversed (as appears in the above image) the user remains on the original page wondering on what is happening.</p>
<p>Using <a title="Firefox" href="http://www.codewrecks.com/blog/index.php/tag/firefox/">Firefox</a>, Opera or Chrome do not produce any strange result, it seems only a bug of Internet Explorer. If you remove the HTML label tag or the image button everything works correctly, but it seems that if you have a label and an imagebutton, a simple anchor link in the page causes an unnecessary postback to the same page. </p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/09/07/the-strangest-bug-of-ie-ive-ever-seen/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Wcf, IXmlSerializable and The XmlReader state should be EndOfFile after this operation.</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/08/23/wcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/08/23/wcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 17:00:02 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[.NET framework]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[XmlElement]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/08/23/wcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation/</guid>
		<description><![CDATA[Iâ€™ve a simple class that contains Properties metadata and I need to pass instances of that class with WCF. Since it contains Dictionary of objects I decided to implement IXmlSerializable to decide the exact format of serialization and make it usable with WCF. Since I really hate reading XML stream with XmlReader, I decided to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F08%2F23%2Fwcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F08%2F23%2Fwcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=LINQ,XmlElement&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Iâ€™ve a simple class that contains Properties metadata and I need to pass instances of that class with WCF. Since it contains Dictionary of objects I decided to implement IXmlSerializable to decide the exact format of serialization and make it usable with WCF. Since I really hate reading XML stream with <a target="_blank" href="http://msdn.microsoft.com/en-us/library/b8a5e1s5(v=VS.90).aspx">XmlReader</a>, I decided to implement the ReadXml method using an XElement, thanks to the fact that I can create an XElement from a XmlReader thanks to the Load method.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> <span style="color: rgb(0, 0, 255);">public</span> <span style="color: rgb(0, 0, 255);">void</span> ReadXml(System.Xml.XmlReader reader)</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum3">   3:</span>     XElement element = XElement.Load(wholeContent);</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum4">   4:</span>     <span style="color: rgb(0, 0, 255);">foreach</span> (var xElement <span style="color: rgb(0, 0, 255);">in</span> element.Elements())</pre>
<p><!--CRLF--></div>
</div>
<p>Using an XElement is really better than using the Raw <a target="_blank" href="http://msdn.microsoft.com/en-us/library/b8a5e1s5(v=VS.90).aspx">XmlReader</a> interface. I wrote a couple of tests to verify that everything work, then I use this class in a DataContract and sent over the wire with WCF. When I call the WCF function I got a strange error â€œ<strong>The XmlReader state should be EndOfFile after this operation</strong>.â€ error. This happens because the serialized XML content sent by WCF is somewhat manipulated and when the XElement read the content of the XmlReader after he finished reading the content the reader is not at the end. This check is somewhat annoying but you can do a dirty trick to avoid this problem.</p>
<div style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);" id="codeSnippetWrapper">
<div style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);" id="codeSnippet">
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(96, 96, 96);" id="lnum1">   1:</span> String wholeContent = reader.ReadInnerXml();</pre>
<p><!--CRLF--></p>
<pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(96, 96, 96);" id="lnum2">   2:</span> XElement element = XElement.Parse(wholeContent);</pre>
<p><!--CRLF--></div>
</div>
<p>Iâ€™ve changed the ReadXml function only a little, I read all the content of the XmlReader in a String thanks to the <a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readouterxml(v=VS.90).aspx">ReadInnerXml</a>() method, then I use the standard XElement.Parse() method to create an XElement from a string. Everything works as expected, but I still wonder why the XmlReader that comes from a WCF serialization cannot be read directly in an XElement. o_O</p>
<p>Gian Maria.</p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/08/23/wcf-ixmlserializable-and-the-xmlreader-state-should-be-endoffile-after-this-operation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASp.NEt handlers locked down in Windows 7 IIS</title>
		<link>http://www.codewrecks.com/blog/index.php/2011/08/04/asp-net-handlers-locked-down-in-windows-7-iis/</link>
		<comments>http://www.codewrecks.com/blog/index.php/2011/08/04/asp-net-handlers-locked-down-in-windows-7-iis/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 16:12:09 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2011/08/04/asp-net-handlers-locked-down-in-windows-7-iis/</guid>
		<description><![CDATA[Iâ€™m configuring a site on a new virtual machine and when I browse to a site, IIS gives me this error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=&#34;Deny&#34;), or set explicitly by a location tag with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F08%2F04%2Fasp-net-handlers-locked-down-in-windows-7-iis%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codewrecks.com%2Fblog%2Findex.php%2F2011%2F08%2F04%2Fasp-net-handlers-locked-down-in-windows-7-iis%2F&amp;source=alkampfer&amp;style=normal&amp;hashtags=ASP.NET,IIS&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Iâ€™m configuring a site on a new <a title="virtual machine" href="http://www.codewrecks.com/blog/index.php/tag/virtual-machine/">virtual machine</a> and when I browse to a site, IIS gives me this error</p>
<blockquote><p>This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=&quot;Deny&quot;), or set explicitly by a location tag with overrideMode=&quot;Deny&quot; or the legacy allowOverride=&quot;false&quot;.</p>
</blockquote>
<p>I donâ€™t know why, but on this Windows 7 <a title="virtual machine" href="http://www.codewrecks.com/blog/index.php/tag/virtual-machine/">virtual machine</a> it seems that this section of the configuration is locked. If you find this error you can simply open an elevated permission command prompt, go to the <em>C:WindowsSystem32inetsrv</em> directory and type the commands</p>
<p><em>appcmd unlock config -section:system.webServer/handlers     <br />appcmd unlock config -section:system.webServer/modules</em></p>
<p>and everything works again <img src='http://www.codewrecks.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Alk.   </p>]]></content:encoded>
			<wfw:commentRss>http://www.codewrecks.com/blog/index.php/2011/08/04/asp-net-handlers-locked-down-in-windows-7-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

