<?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>Avivo Tech Blog &#187; silverlight</title>
	<atom:link href="http://tech.avivo.si/tag/silverlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.avivo.si</link>
	<description>Solving problems</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:46:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Silverlight: Equidistant items in a stack panel</title>
		<link>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-xaml-equidistant-items-in-a-stack-panel</link>
		<comments>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 13:00:28 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[axis]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[coordinates]]></category>
		<category><![CDATA[equidistant]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[stackpanel]]></category>
		<category><![CDATA[wpf]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1164</guid>
		<description><![CDATA[This post describes how to align items in a container so the two neighbour items are always aligned with equal distance. Solution should be flexible, meaning that when items are changed or when container is resized items should keep equal distance in between. Reader should have some basic knowledge about C# and XAML for Silverlight. [...]]]></description>
			<content:encoded><![CDATA[<p>This post describes how to align items in a container so the two neighbour items are always aligned with equal distance. Solution should be flexible, meaning that when items are changed or when container is resized items should keep equal distance in between. Reader should have some basic knowledge about C# and XAML for Silverlight.</p>
<h2>Ideas</h2>
<ul>
<li>using Canvas and positioning items with <strong>absolute coordinates</strong> &#8211; items are always fixed, coordinates need to be calculated, so it is the least flexible approach, no</li>
<li>using <strong>StackPanel</strong> with items that have margin &#8211; margins need to be recalculated when an item is added or removed or when container is resized, maybe</li>
<li>using Grid with <strong>predefined rows and columns</strong> &#8211; notice <em>predefined</em>, means less flexibility, but offers equal size rows/columns, maybe</li>
<li>using a <strong>custom control</strong> &#8211; making Grid more dynamic but extending number of rows/columns when items are added, yes</li>
</ul>
<h2>Custom Control: EqualDistanceStackPanel</h2>
<p>As written before, custom control should extend Grid to become more flexible</p>
<pre style="background: #eeeeee; padding: 15px;">public class EqualDistanceStackPanel : Grid
{
}</pre>
<p>&nbsp;</p>
<p><em>EqualDistanceStackPanel</em> should implement <em>ItemsSource</em> and <em>ItemTemplate</em> just like <em><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol%28v=vs.95%29.aspx" target="_blank">ItemsControl</a></em></p>
<pre style="background: #eeeeee; padding: 15px;">#region ItemsSource
public IEnumerable ItemsSource
{
  get { return (IEnumerable)GetValue(ItemsSourceProperty); }
  set { SetValue(ItemsSourceProperty, value); }
}

public static readonly DependencyProperty ItemsSourceProperty =
  DependencyProperty.Register("ItemsSource", typeof(IEnumerable),
  typeof(EqualDistanceStackPanel), new PropertyMetadata(ItemsSourceChanged));

private static void ItemsSourceChanged(DependencyObject d,
  DependencyPropertyChangedEventArgs e)
{
  var panel = d as EqualDistanceStackPanel;
  if (panel != null)
  {
    if (e.OldValue != null)
    {
      panel.ClearItems();
    }
    if (e.NewValue != null)
    {
      panel.BindItems(e.NewValue as IEnumerable);
    }
  }
}
#endregion

public DataTemplate ItemTemplate
{
  get;
  set;
}</pre>
<p>&nbsp;</p>
<p><em>ClearItems</em> method deletes all previous elements from the panel and <em>BindItems</em> attaches fresh controls from item template.</p>
<pre style="background: #eeeeee; padding: 15px;">protected void ClearItems()
{
  this.Children.Clear();
}

protected void BindItems(IEnumerable items)
{
  if (this.ItemTemplate == null)
  {
    return;
  }

  //Create and attach children
  foreach (var item in items)
  {
    var element = this.ItemTemplate.LoadContent() as FrameworkElement;
    element.DataContext = item;
    this.Children.Add(element);
  }

  //Realign in container
  Refresh();
}</pre>
<p>&nbsp;</p>
<p>How should the custom control look in XAML? <em>EqualDistanceStackPanel</em> gets a collection of items, e.g. of UIElement type.</p>
<pre style="background: #eeeeee; padding: 15px;">&lt;Grid xmlns:c="clr-namespace:Avivo.Controls"&gt;
  &lt;c:EqualDistanceStackPanel ItemsSource="{Binding Items}" Orientation="Vertical"&gt;
    &lt;c:EqualDistanceStackPanel.ItemTemplate&gt;
      &lt;DataTemplate&gt;
        &lt;ContentPresenter Content="{Binding}" /&gt;
      &lt;/DataTemplate&gt;
    &lt;/c:EqualDistanceStackPanel.ItemTemplate&gt;
  &lt;/c:EqualDistanceStackPanel&gt;
&lt;/Grid&gt;</pre>
<p>&nbsp;</p>
<h2>Example</h2>
<p>Ruler has been made to demonstrate the usage of EqualDistanceStackPanel. Numbers are bound to the control and ticks are bound to another control using the same binding collection. Left image represents container height 300px and right when resized to 460px &#8211; elements are automatically aligned with equal distance.<br />
<img class="alignnone size-full wp-image-1177" title="Example of a ruler" src="http://tech.avivo.si/wp-content/uploads/2011/01/equidistant-stack-panel.jpg" alt="" width="414" height="734" /></p>
<p><a href="http://labs.avivo.si/equidistant/" target="_blank">Try demo</a>, resize browser to see the effect. This control has been originally developed for custom chart axes in <a href="http://qrcode.good-survey.com/" target="_blank">QR Code Statistics</a> application. <em>EqualDistanceStackPanel</em> control is lightweight, works for the statistics application and should be improved for general usage.</p>
<h2>Source code</h2>
<ul>
<li><a href="http://labs.avivo.si/equidistant/EqualDistanceStackPanel.zip">Source code</a>, Visual Studio sample Silverlight and web project</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://chris.59north.com/post/Using-DataTemplates-in-custom-controls.aspx" target="_blank">Using DataTemplates in custom controls</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2011/03/silverlight-xaml-equidistant-items-in-a-stack-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash vs Silverlight</title>
		<link>http://tech.avivo.si/2010/12/flash-vs-silverlight/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flash-vs-silverlight</link>
		<comments>http://tech.avivo.si/2010/12/flash-vs-silverlight/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 16:51:32 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[superia]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=1018</guid>
		<description><![CDATA[We at Avivo thought that we should post something about Silverlight vs. Flash as we use both technologies at our work. We always want to explore different techniques in production to bring out innovative approach for each project and to inspire our clients. This post is about choosing right technologies when dealing with interactive or [...]]]></description>
			<content:encoded><![CDATA[<table bgcolor="#efeded">
<tbody>
<tr>
<td style="padding: 7px; padding-bottom: 7px; font-family: Georgia; font-size: 15px; line-height: 21px;">We at Avivo thought that we should post something about Silverlight vs. Flash as we use both technologies  at our work. We always want to explore different techniques in production to bring out innovative approach for each project and to inspire our clients.</td>
</tr>
</tbody>
</table>
<div style="padding-top: 10px;"><img class="alignnone size-large wp-image-1025" title="flash-vs-silverlight" src="http://tech.avivo.si/wp-content/uploads/2010/12/flash-vs-silverlight-700x301.jpg" alt="" width="700" height="301" /></div>
<p>This post is about choosing right technologies when dealing with interactive or animated content on the web. It is a our test of Silverlight and Flash technology and we will describe our experience working with both of them. For the record: »HTML5 is not being part of experiment«.</p>
<h2>Adobe Flash</h2>
<p>Flash is well known as being the tool for animations and able to bring all kind of interactive content on web. Flash golden era of  last decade is coming to an end. Currently web site trends are banning Flash out for many different reasons. First was <a href="http://jquery.com/">jQuery</a> that started to replace Flash in many simple tasks and HTML5 will probably be the final executor. Then, also <a href="http://www.apple.com" target="_blank">Apple </a>announced that it will not support Flash on iPhone/iPad. Nevertheless Flash will stay around long time especially when you want to bring extremely good interactivity inside browser for smaller parts like games or banners and for such specifics tasks Flash is still without competition.</p>
<h2>Microsoft Silverlight</h2>
<p>On the other side Silverlight was many times quoted as <a href="http://www.lynnfredricks.com/2010/11/01/microsofts-silverlight-no-longer-a-flash-competitor/">Flash competitor but not any more</a> and lately is obvious that has many other advantages like delivering best video quality/performance and out of browser experience. And developing in C#/VB/other dynamic languages and reusing the code naturally with the project and through the projects. Speed, frame rate accuracy and low CPU usage give few good strengths to the Silverlight down the road. Nowadays that Silverlight is used also as platform for <a href="http://www.microsoft.com/windowsphone/en-gb/default.aspx">Windows Phone</a> we think Silverligt is more attractive then ever.</p>
<h2>Both are RIA</h2>
<p>We need to mentioned that also many Flash developers didn&#8217;t want to switch to Silverligt and many reasons why they didn&#8217;t are very clear to us. To say it in short: Silverlight demands new approach that Flash developers just can&#8217;t or not willing to adopt. When you converting you have to convert fully to have chance for success. Only then you are comfortable enough to work with Silverlight and you are on better position to decide what would be the best technology for specific given task.</p>
<p>Nice example is <a href="http://www.shinedraw.com/flash-vs-silverlight-gallery/ ">Shine Draw web site</a> where each animated example is done in both technologies.  Our task was to bring out animated effect as good as it is possible to be smooth and visual attractive. We decided that this can be good example to try both technologies out and at the same time we was also eager to test them both.</p>
<p><!-- Silverlight vs. Flash: Which technology are you using at your work?  --><br />
<!--<script src="http://www.good-survey.com/poll/e35aq46sw25r.js" type="text/javascript"></script>--></p>
<h2>Our project</h2>
<p>We wanted to create appealing visual effect of  changing triangular pattern animation as best as it gets with bit of 3D look and feel. We made grid out of triangles and we wanted to transform grid while changing images with seamless transitions.</p>
<div style="padding: 10px 0 3px 0;"><img class="alignnone size-large wp-image-1026" title="pattern" src="http://tech.avivo.si/wp-content/uploads/2010/12/pattern1-700x178.jpg" alt="" width="700" height="178" /></div>
<p><span style="color: #7f7f7f; font-size: 12px;">Design ready to animate. Skip reading and see final result <a title="Flash vs Silverlight - Superia pattern" href="http://labs.avivo.si/flash-vs-silverlight/" target="_blank">here</a>.<span> </span></span></p>
<h2>Pattern design ready to animate</h2>
<p>The goal was to animate 6 different pattern designs with seamless transformations with use of 3D on each triangular element.</p>
<div style="padding: 10px 0 3px 0;"><img class="alignnone size-large wp-image-1027" title="patterns" src="http://tech.avivo.si/wp-content/uploads/2010/12/patterns-700x397.jpg" alt="" width="700" height="397" /></div>
<h2>First try with Silverlight</h2>
<p>We had experience with Silverlight transitions while working on <a href="http://www.youtube.com/avivotube#p/u/7/-Mltdr75ecQ">Superia Player</a> and process was very natural and very quick from start to finished.  When we wanted to bring even more interesting 3D transformation on irregular triangles positioned grid parts we encounter issues and we decide is time to switch to Flash and repeat the process.</p>
<h3>Input parameters</h3>
<p>Using 'initParams' in HTML input parameters are passed to Silverlight application. Application collects the parameters on load and requests the specified pattern XML file and initial image from the hosting server. Each other image is loaded once on demanded and cached by browser.</p>
<h3>Mapping images to triangles</h3>
<p>Triangle vector objects were created dynamically by the pattern defined in XML and they fit to the container size. Application has been developed in Silverlight 3 which has no native 3D support but already supports graphic acceleration. So triangles are drawn in 2D space faking the 3D look, 2D is also used because of better performance. Images are mapped to triangles by calculating rotation and offset using ImageBrush that could be later replaced by VideoBrush allowing to map video frames. Lot of geometrical math was done to do this job.</p>
<h3>Flip animations</h3>
<p>Triangle flip animation was done in two ways: transforming around diagonal centre point or transforming vertically/horizontally. In either way front side hides and back side shows or vice versa resulting in image change. Since the triangles are drawn on 2D spaces animations are faking 3D transitions by scaling, skewing, rotating, translating and remapping image. Animation can flip triangles progressively from the top left corner towards the bottom right. Another more appropriate animation starts flipping random triangles progressively with short delays between phases.</p>
<h3>Hosting Silverlight</h3>
<p>Silverlight is embedded in HTML using 'object' tag and 'params'. Setting parameters is straightforward, no tricks or work-arounds. Additionally HTML content can be inserted into 'object' allowing user to view the alternative content in case Silverlight is not installed or plug-in not enabled in browser.</p>
<h3>The catch</h3>
<p>Working with 2D, drawing triangles and mapping parts of image may seem easy at the beginning but when it goes towards fake 3D rotations it can get complex. Having multiple layers, calculating offsets and transitions, mapping images, switching images (front/back) during animation, generating animations, generating delays between flip... Finally algorithms get too complex to continue in 2D space without real 3D engine.</p>
<h2>Making Flash pattern</h2>
<p>We knew that flash might be better shaping irregular transformation but one thing we need to know is that Flash until recently didn't have direct 3D support. Sure, you could make it your own 3D effect by using math to calculate 2D movement and rotation in such way that would resembles 3D feeling, also we need to mentioned that out there are many excellent package of 3D utilities and one is called <a href="http://blog.papervision3d.org/" target="_blank">Paper Vision 3D</a> that was and is still used to produce nice 3D effects in Flash. But we were up to try something (relatively) new and besides that, we wanted to see what can be done with Flash-only 3D in Flash CS4 version.     </p>
<p><strong>Creating our triangular pattern animation required a few critical parts of AS3 code:</strong></p>
<ul>
<li>Loading XML data for pattern definition</li>
<li>Loading images used to create pattern</li>
<li>Mapping images to triangles</li>
<li>Animating the actual transitions</li>
</ul>
<h3>Pattern XML data</h3>
<p>Since introduction of AS3, handling XML data in Flash has become much, much, less complicated, thanks to the adoption of ECMAScript for XML (E4X). Now XML acts as native data type, you don't need to create special objects to copy data from XML.   Now data from XML is directly accessible from XML object, using actual element and attribute names to select appropriate data form XML. Picture preloading is also now much more simple, although the "art-of-preloading" was conquered long ago, classes used to load external content are now better organized, and callback functions for various events that can happen during load are now handled by proper event listeners.</p>
<p>Another good thing in AS3 is that every DisplayObject is by default invisible until you explicitly add it to some other, visible or DisplayObject as it's child. So you can do any kind of manipulation of size, position, alpha, and so on, until you decide that your object is finally in a state you want it to appear on stage.  Sticking images on triangle parts Applying pictures to triangles was another task to perform even before we could use 3d effects. Although it takes a bit of math to draw triangles on proper locations, it is still a combination of well-known lineTo, moveTo, curveTo methods (if you want triangles with rounded corners) and even better in newer version of Flash, you can now use drawPath method. Performance in drawing should be better as well as precision.</p>
<h3>Using 3D in Flash</h3>
<p>With all this we had the basic setup completed, and we came to the funny parts, exploring 3d effects. Using 3d in Flash has become quite easy, you can set rotationX, rotationY, rotationZ, and x, y, z values for any visible objects. Tweening any of these properties will create 3d animation effect. Nice and easy.   Of course, some experimentation was needed, to get some idea how change z value effects the object, its appearance in the stack of objects. Any sudden and extreme change of z value will produce quite unnatural effect.     </p>
<p>Unfortunately, there must be a glitch, when 3d engine is activated (that is when you change any property that directly or indirectly changes z property of an object) the object itself is immediately blurred and this is bad for display animation. In fact, the object is bitmap-cached (to make animation easily to compute) with smoothing. Usually that is not a big deal, unless, as it was the case with our pattern, you need very precise positioning of some elements and crystal sharp edges.</p>
<p><img src="http://tech.avivo.si/wp-content/uploads/2010/12/patter-blur-edges-and-fixing-timers-700x220.jpg" alt="" title="patter-blur-edges-and-fixing-timers" width="700" height="220" class="alignnone size-large wp-image-1107" /><br />
<span style="color: #7f7f7f; font-size: 12px;">Blur edges and timers were pian in the ass.</span></p>
<h3>Solving problems with 3D to 2D world</h3>
<p>This has becomes a first major problem with our pattern project and solution isn't easily at least not in all circumstances. Luckily for our pattern, we struck such a layout that we could overcome this. To make elements clear, once you used 3d effect on an object it will be bitmap cached and blurred, and there's nothing you can do about it. But if your animation is such that in the end your object is in such position that any z-axes related property is zero-ed, you can bring you object back to the 2d world.</p>
<h3>How Flash is transforming</h3>
<p>The thing is, Flash uses two different transformation matrices to track 2d and 3d properties of an object. If 3d transformation matrix exist - than your object is blurred. But if you can get rid of it, your object will be returned to the crystal sharp realm of 2d transformations. All you need to do is to copy 2d properties (x, y position and xscale, yscale) from 3d transformation matrix, remove the 3d transformation matrix, and apply those x, y, xscale, yscale to your object. The only backdraw of this method is that you can not use it on objects that needs z-axes related properties to display themselves correctly.</p>
<h3>Timers and fine tuning</h3>
<p>One thing we've noticed after the pattern was created is that timers we've used to control the timing of the rotations are performing somewhat strange if the HTML page containing the Flash embedded object looses focus. For some reason, when Flash page looses focus, background priority obviously doesn't have not enough memory for Flash timers to work correctly. Flash timers do not guarantee perfect timing anyway, but in the background window it will probably drop out of sync completely. So we needed some quick fix, to detect when the page containing our Flash is loosing focus. Again AS3 have come to the rescue, with it's External interface, and ability to easy communicate with JavaScript, that is, on the other hand capable of detecting when the page has lost the focus. <!-- Silverlight vs. Flash: How would you rate final patterns. --><br />
<!--<script src="http://www.good-survey.com/poll/e35aq46st30o.js" type="text/javascript"></script>--></p>
<p>View final comparison solution between <a title="Flash vs Silverlight - Superia pattern" href="http://labs.avivo.si/flash-vs-silverlight/" target="_blank"> Flash and Silverlight pattern</a>.</p>
<h2>Conclusion</h2>
<p> We found that with Flash we succeed to create pattern transformation as we wanted with smooth transitions and nice 3d effect. Working with Silverlight was very quick and we might even explore it further but we run out of time and beside that we where happy with Flash result. When looking closely you will see that when you embed Silverlight object and Flash object to HTML site, Silverlight need little more time to appears in browser than Flash and this is something we don't know the answer yet.</p>
<p>What have we learned:</p>
<ul>
<li>Flash has "dirty" history and uses bad mix of 'object' and 'embed' tags.</li>
<li>Flash cannot display HTML content reliably if plug-in is missing while Silverlight can do that easily. If plug-in is missing we just display static content.</li>
<li>Flash has native 3D support while Silverlight has no native support for 3D at the time. Silverlight has some experimental libraries which are heavily under development and not for production use.</li>
<li>Calculating 2D to look like 3D is overkill for developers. Too much effort, too small output. Use 3D engine for serious 3D development.</li>
</ul>
<p>Share your thoughts in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/12/flash-vs-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The service cannot be activated due to an exception during compilation. The exception message is: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.</title>
		<link>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch</link>
		<comments>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 14:38:51 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[The service cannot be activated due to an exception during compilation]]></category>
		<category><![CDATA[There can be at most one address per scheme in this collection]]></category>
		<category><![CDATA[This collection already contains an address with scheme http]]></category>
		<category><![CDATA[wcf]]></category>
		<category><![CDATA[wcf service error]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=825</guid>
		<description><![CDATA[You can solve this issue by adding the following code to your web.config: &#60;system.serviceModel&#62; ... &#60;serviceHostingEnvironment&#62; &#60;baseAddressPrefixFilters&#62; &#60;add prefix="http://sample.domain.tld/Sample/"/&#62; &#60;/baseAddressPrefixFilters&#62; &#60;/serviceHostingEnvironment&#62; ... &#60;/system.serviceModel&#62;]]></description>
			<content:encoded><![CDATA[<p>You can solve this issue by adding the following code to your web.config: </p>
<pre class=xml>
&lt;system.serviceModel&gt;
	...
	&lt;serviceHostingEnvironment&gt;
	  &lt;baseAddressPrefixFilters&gt;
	  	&lt;add prefix="http://sample.domain.tld/Sample/"/&gt;
	  &lt;/baseAddressPrefixFilters&gt;
	&lt;/serviceHostingEnvironment&gt;
	...
&lt;/system.serviceModel&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2010/11/the-service-cannot-be-activated-due-to-an-exception-during-compilation-the-exception-message-is-this-collection-already-contains-an-address-with-scheme-http-there-can-be-at-most-one-address-per-sch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WriteableBitmap does not Render()?!</title>
		<link>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=writeablebitmap-does-not-render</link>
		<comments>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 16:36:32 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Warnings]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[not]]></category>
		<category><![CDATA[raster]]></category>
		<category><![CDATA[Render]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[vector]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[WriteableBitmap]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=223</guid>
		<description><![CDATA[We spent quite some time working on a Silverlight deep zoom application. Like in other projects, a problem appears sooner or later. This time with the WriteableBitmap that couldn&#8217;t take screenshot of a basic shape. //Simple ellipse (green circle) Ellipse element = new Ellipse() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Green) [...]]]></description>
			<content:encoded><![CDATA[<p>We spent quite some time working on a Silverlight deep zoom application. Like in other projects, a problem appears sooner or later. This time with the <strong>WriteableBitmap</strong> that couldn&#8217;t take screenshot of a basic shape.</p>
<pre class="c-sharp">//Simple ellipse (green circle)
Ellipse element = new Ellipse()
{
	Width = 50,
	Height = 50,
	Fill = new SolidColorBrush(Colors.Green)
};

//WriteableBitmap current = new WriteableBitmap(50, 50);
//current.Render(element, new MatrixTransform()); //DOES NOT WORK!!! - renders blank transparent image

//But with the constructor works fine
WriteableBitmap bitmap = new WriteableBitmap(element, new MatrixTransform());

//Ellipse captured as raster image painted on a panel's background
Grid grid = new Grid()
{
	Width = 50,
	Height = 50,
	Background = new ImageBrush() { ImageSource = bitmap }
};</pre>
<p>Summary for the Render() method says: <em>&#8220;Renders an element within the bitmap.&#8221;</em><br />
<strong>Render()</strong> method didn&#8217;t output required result but <strong>using constructor instead</strong> of the method did do the job. Input parameters were the same.</p>
<p>Maybe Render() method do something else, maybe it is a problem with Vista 64-bit&#8230;</p>
<p>Anyway, WriteableBitmap is very useful in Silverlight 3, luckily it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/12/writeablebitmap-does-not-render/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight: inherit a generic class from UserControl</title>
		<link>http://tech.avivo.si/2009/11/silverlight-inherit-a-generic-class-from-usercontrol/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-inherit-a-generic-class-from-usercontrol</link>
		<comments>http://tech.avivo.si/2009/11/silverlight-inherit-a-generic-class-from-usercontrol/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 17:57:49 +0000</pubDate>
		<dc:creator>developer</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[derive]]></category>
		<category><![CDATA[generic]]></category>
		<category><![CDATA[inherit]]></category>
		<category><![CDATA[mvvm]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[UserControl]]></category>
		<category><![CDATA[view]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://tech.avivo.si/?p=208</guid>
		<description><![CDATA[Note! This blog post is just an idea than well tested solution, more a review that detailed description. In Silverlight UserControl and Page classes are usually used with xaml. Root tags in xaml define the type, like so: xaml &#60;UserControl x:Class="MyView"&#62; ... &#60;/UserControl&#62; code-behind namespace MyNamespace { class MyView : UserControl } Sometimes, developers want [...]]]></description>
			<content:encoded><![CDATA[<p>Note! This blog post is just an idea than well tested solution, more a review that detailed description.<br />
In Silverlight UserControl and Page classes are usually used with xaml. Root tags in xaml define the type, like so:</p>
<pre class="c-sharp">xaml
&lt;UserControl x:Class="MyView"&gt;
...
&lt;/UserControl&gt;

code-behind
namespace MyNamespace
{
  class MyView : UserControl
}</pre>
<p>Sometimes, developers want to extend UserControl, i.e. as View by MVVM pattern.</p>
<pre class="c-sharp">xaml
&lt;v:ViewBase x:Class="MyNamespace.MyView" xmlns:v="clr-namespace:MyNamespace"&gt;
...
&lt;/v:ViewBase&gt;

code-behind
namespace MyNamespace
{
  class MyView : ViewBase /* ViewBase is a custom class */
}</pre>
<p>Step further, every View should have it&#8217;s specialized model (ViewModel), thus base class could integrate a Model property. To avoid casting one should use generics, like ViewBase&lt;MyViewModel&gt;.</p>
<pre class="c-sharp">xaml
&lt;!-- There's a problem, generics cannot be written in xaml. --&gt;

code-behind
namespace MyNamespace
{
  class MyView : ViewBase&lt;MyViewModel&gt; /* ViewBase is a custom class */
}</pre>
<p>Generics cannot be written directly in xaml? There is a workaround:<br />
1. Use a wrapper, described <a href="http://www.lab101.be/2008/07/silverlight-usercontrol-inheritance/">here</a><br />
2. Create a new non-generic class, like in this sample:</p>
<pre class="c-sharp">xaml
&lt;v:MyViewBase x:Class="MyNamespace.MyView" xmlns:v="clr-namespace:MyNamespace"&gt;
...
&lt;/v:MyViewBase&gt;

code-behind
namespace MyNamespace
{
  class MyView : MyViewBase
}

public abstract class MyViewBase : ViewBase&lt;MyViewModel&gt;
{
  /* non-generic class */
}</pre>
<p><strong>Appendix: ViewBase&lt;TViewModel&gt; class</strong></p>
<pre class="c-sharp">public abstract class ViewBase&lt;TViewModel&gt; : UserControl, INotifyPropertyChanged where TViewModel : ViewModelBase, new()
{
	private TViewModel model;
	public TViewModel Model
	{
		get
		{
			if (this.model == null)
			{
				this.model = new TViewModel();
				base.DataContext = this.model;
			}
			return this.model;
		}
		set
		{
			if (this.model != value)
			{
				this.model = value;
				base.DataContext = this.model;
				OnPropertyChanged("Model");
			}
		}
	}
}</pre>
<p>References:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/400778/usercontrol-that-has-a-generic-class-in-its-inheritance-tree">StackOverflow: UserControl that has a generic class in its inheritance tree</a></li>
<li><a href="http://stackoverflow.com/questions/225878/how-to-correctly-inherit-from-a-usercontrol-defined-in-xaml-in-silverlight">StackOverflow: How to correctly inherit from a UserControl defined in xaml in Silverlight</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/11/silverlight-inherit-a-generic-class-from-usercontrol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 2.0 &#8211; Invoke method with Reflection</title>
		<link>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-20-invoke-method-with-reflection</link>
		<comments>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 13:45:39 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Programming Techniques]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[run-time]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=123</guid>
		<description><![CDATA[When deciding whether to create a rich graphical web application with lots of animations either with Silverlight or ASP .NET, Silverlight definitely wins. But when deciding whether put a database in first place then server side scripts (i.e. ASP .NET) have the advantage. Anyway, if you are accessing database from Silverlight you&#8217;ve probably came across [...]]]></description>
			<content:encoded><![CDATA[<p>When deciding whether to create a rich graphical web application with lots of animations either with Silverlight or ASP .NET, Silverlight definitely wins. But when deciding whether put a database in first place then server side scripts (i.e. ASP .NET) have the advantage.</p>
<p>Anyway, if you are <strong>accessing database from Silverlight</strong> you&#8217;ve probably came across WCF or other  web services. Let&#8217;s say you have <strong>100 tables</strong> and want to use <strong>WCF</strong>. Each table has <strong>Select</strong>, <strong>Insert</strong>, <strong>Update </strong>and <strong>Delete </strong>methods generated like <strong>InsertUser(User item)</strong>. Visual Studio 2008 can automatically generated WCF proxy classes in Silverlight which are asynchronous. Suddenly, handling application logic and database becomes complex for development.</p>
<p>Those methods have <strong>similarities </strong>- Select, Insert, Update and Delete are repeated but for <strong>different table names</strong>. Idea is to use <strong>System.Reflection</strong> to simply and minimize development time. What the Reflection classes do is they use run time variables (i.e. string, int, etc.) to dynamically invoke methods according to situation in run time (cannot be determined in design time while developing).</p>
<p>Let&#8217;s say you have a method <strong>InsertCustomer(Customer item) in WCF</strong> and Visual Studio generates <strong>InsertCustomerAsync(Customer item) for Silverlight</strong>. Application can generate &#8220;InsertCustomerAsync&#8221; as string on demand. Then a method invoke by string is needed:</p>
<blockquote><p>using System.Reflection;</p>
<p>&#8230;</p>
<p>//MyWebService is WCF proxy class and Customer is data entity</p>
<p>MethodInfo methodInfo = typeof(MyWebService).GetMethod(&#8220;InsertCustomerAsync&#8221;, new Type[] { typeof(Customer) });</p>
<p>methodInfo.Invoke(con, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this.item, }, null);</p></blockquote>
<p>Then a &#8220;completed&#8221; event needs to be caught:</p>
<blockquote><p>MethodInfo handlerInfo = typeof(ReflectionDemo&lt;T&gt;).GetMethod(&#8220;SaveHandler&#8221;, BindingFlags.NonPublic | BindingFlags.Instance);<br />
EventInfo eventInfo = typeof(MyWebService).GetEvent(eventName);<br />
eventInfo.AddEventHandler(con, Delegate.CreateDelegate(eventInfo.EventHandlerType, this, handlerInfo));</p></blockquote>
<p>Putting all code together:</p>
<blockquote><p>public class ReflectionDemo&lt;T&gt; where T : new()<br />
{<br />
private T item;</p>
<p>public bool IsUpdate<br />
{<br />
get;<br />
set;<br />
}</p>
<p>public void Save()<br />
{<br />
try<br />
{<br />
if (this.item != null)<br />
{<br />
//Get names<br />
string methodName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;Async&#8221;; //e.g. UpdateCustomerAsync<br />
string eventName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;Completed&#8221;; //e.g. UpdateCustomerCompleted<br />
string eventArgsName = (this.IsUpdate ? &#8220;Update&#8221; : &#8220;Insert&#8221;) + typeof(T).Name + &#8220;CompletedEventArgs&#8221;; //e.g. UpdateCustomerCompletedEventArgs</p>
<p>//Create a connection<br />
MyWebService con = new MyWebService();</p>
<p>//Attach an event handler in run time retrieved event (e.g. something like &#8220;con.UpdateCustomerCompleted += &#8230;&#8221; at design time)<br />
MethodInfo handlerInfo = typeof(ReflectionDemo&lt;T&gt;).GetMethod(&#8220;SaveHandler&#8221;, BindingFlags.NonPublic | BindingFlags.Instance);<br />
EventInfo eventInfo = typeof(MyWebService).GetEvent(eventName);<br />
eventInfo.AddEventHandler(con, Delegate.CreateDelegate(eventInfo.EventHandlerType, this, handlerInfo));</p>
<p>//Invoke method in run time (e.g. something like &#8220;con.UpdateCustomerAsync(this.item);&#8221; at design time)<br />
MethodInfo methodInfo = typeof(MyWebService).GetMethod(methodName, new Type[] { typeof(T) }); //From overloaded methods get the one with single parameter<br />
methodInfo.Invoke(con, BindingFlags.Public | BindingFlags.Instance, null, new object[] { this.item, }, null); //Invoke the method immediately<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
//Exception may be thrown in various situations (e.g. method cannot be found)<br />
//Insert breakpoint here while debugging<br />
}<br />
}</p>
<p>protected void SaveHandler(object sender, EventArgs args)<br />
{</p>
<p>//Handle event logic here<br />
//Sample how to cast to a derived EventArgs with known properties:</p>
<p>Type type = args.GetType();<br />
Exception ex = type.GetProperty(&#8220;Error&#8221;).GetValue(args, null) as Exception ?? null;<br />
Customer item = (Customer)type.GetProperty(&#8220;Customer&#8221;).GetValue(args, null);<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/07/silverlight-20-invoke-method-with-reflection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight 2.0 &#8211; Resolved issue: InitializeError #2103 &#8211; Invalid or malformed application</title>
		<link>http://tech.avivo.si/2009/06/silverlight-20-resolved-issue-initializeerror-2103-invalid-or-malformed-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-20-resolved-issue-initializeerror-2103-invalid-or-malformed-application</link>
		<comments>http://tech.avivo.si/2009/06/silverlight-20-resolved-issue-initializeerror-2103-invalid-or-malformed-application/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 08:59:54 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[2103]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[InitializeError]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[resolved]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[solution]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=105</guid>
		<description><![CDATA[Intro I am working on a project that includes ASP .NET MVC web site and Silverlight 2.0 application. Initialy a Visual Studio solution with both project types has been created. At the beginning, sample Silverlight application worked fine, then most of the time development was going on MVC side. Now, when development should continue on [...]]]></description>
			<content:encoded><![CDATA[<h2>Intro</h2>
<p>I am working on a project that includes ASP .NET MVC web site and Silverlight 2.0 application. Initialy a Visual Studio solution with both project types has been created. At the beginning, sample Silverlight application worked fine, then most of the time development was going on MVC side. Now, when development should continue on Silverlight side browser throws an error:</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/webpage-error-screenshot.jpg" alt="" /></p>
<p>This blog post explains how the issue has been solved. Resolving issue step by step&#8230;</p>
<h2>1.Check namespaces</h2>
<p><strong>App.xaml</strong> should have <strong>x:Class</strong> attributes formatted as &#8220;<strong>Namespace.ClassName</strong>&#8221; (e.g. &#8220;StudioBikini.ClientSide.App&#8221;).</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/app-xaml-screenshot.jpg" alt="" /></p>
<p>Same namespace and class name should also appear in <em>App.xaml.cs</em>. Note that namespace and class name are separated in C# file while glued together in XAML.</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/app-xaml-cs-screenshot.jpg" alt="" /></p>
<h2>2. Change project properties</h2>
<p>When you change a namespace for App in either C# or XAML the Startup object value in properties still holds the previous value.<br />
Right click on a <strong>project </strong>in <strong>Visual Studio</strong> and select <strong>Properties</strong>.<br />
Click on the <strong>Startup object</strong> combobox should open a list of available startup object and select the <strong>Namespace.ClassName</strong>.</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/properties-screenshot.jpg" alt="" /></p>
<p>Also make sure that <strong>Generate Silverlight manifest file</strong> checkbox is checked and an existing manifest file is selected.</p>
<h2>3. Check manifest file</h2>
<p>Some text editors add <strong>3 garbage bytes</strong> at the beginning of a file which represent encoding. Those three bytes are <strong>invisible</strong> by some editors and may cause xml parsing exception.<br />
Remove <em>Properties\AppManifest.xml</em> file and create it again.</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/manifest-screenshot.jpg" alt="" /></p>
<h2>4. Other possibilities:</h2>
<ul>
<li> Try to set assembly name and default namespace in the project properties to the same value. Namespace in properties should be the same as namespace in App.</li>
<li>Try with relative or absolute uri or false uri &#8211; if .xap file cannot be found Silverlight plug-in returns error #2104, that is different than #2103. So #2103 indicates that file has been found.</li>
<li>Clear browser&#8217;s cache (downloaded data) and reload the page with Silverlight.</li>
<li>Turn off virus scanner, as some scanners block loading unknown or hidden extensions (I had problems with .xaml.js for Silverlight 1.0).</li>
<li>If you are using <em>object</em> tag in html to load .xap file, try to change height in pixels (in case it works on IE7 but not in Firefox 3.0).</li>
<li>There may be an old .xap build. Try to rebuild VS solution or delete <em>bin</em> and <em>obj</em> folders from all projects &#8211; those folders are generated again on next build.</li>
<li>AppManifest.xml file can be <strong>read-only</strong>, usually happens when under a source control system (e.g. <strong>sourcesafe</strong>, svn), so check it out first.</li>
<li>Finally, delete AppManifest.xml, create new one and paste next lines into the file:</li>
</ul>
<blockquote><p>&lt;Deployment xmlns=&#8221;http://schemas.microsoft.com/client/2007/deployment&#8221;<br />
xmlns:x=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;&gt;<br />
&lt;Deployment.Parts&gt;<br />
&lt;/Deployment.Parts&gt;<br />
&lt;/Deployment&gt;</p></blockquote>
<h2>Solution</h2>
<p>It appears that file was under Visual SourceSafe, problem with locked file. Solution has been found progressively, step by step as described above.</p>
<p><img src="http://blog.sweetucan.com/wp-content/uploads/2009/06/solution-screenshot.jpg" alt="" /></p>
<p>Another time, another project, same error. Problem with an included assembly reference &#8211; a <em>Silverlight Class Library</em> project with web service reference and <em>Silverlight Application</em> project with reference <em>System.ServiceModel</em>&#8230; Resolved by commeting code that uses <em>System.ServiceModel</em> (code when calling web service generated classes). Alternative is to use  <em>release</em> settings instead of <em>debug</em>.</p>
<p>Any other suggestions?</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/06/silverlight-20-resolved-issue-initializeerror-2103-invalid-or-malformed-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hosting Silverlight 2.0 applications on IIS</title>
		<link>http://tech.avivo.si/2009/05/hosting-silverlight-20-applications-on-iis/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hosting-silverlight-20-applications-on-iis</link>
		<comments>http://tech.avivo.si/2009/05/hosting-silverlight-20-applications-on-iis/#comments</comments>
		<pubDate>Wed, 20 May 2009 22:36:54 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[System administration]]></category>
		<category><![CDATA[hosting silverlight 2 on IIS]]></category>
		<category><![CDATA[IIS server]]></category>
		<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=80</guid>
		<description><![CDATA[http://www.shahed.net/post/Hosting-Silverlight-20-in-IIS.aspx If you host Silverlight 2.0 application in IIS you might find that the silverlight object is not loading. If that&#8217;s the case, first thing you should check is the MIME type list. By default, the Silverlight package extension *.xap is not included. To resolve that, go to IIS Manager, properties of your web site [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shahed.net/post/Hosting-Silverlight-20-in-IIS.aspx%20">http://www.shahed.net/post/Hosting-Silverlight-20-in-IIS.aspx </a></p>
<p>If you host Silverlight 2.0 application in IIS you might find that the silverlight object is not loading. If that&#8217;s the case, first thing you should check is the MIME type list. By default, the Silverlight package extension *.xap is not included.</p>
<p>To resolve that, go to IIS Manager, properties of your web site and check the &#8220;Http Headers&#8221; tab.</p>
<p><a href="http://www.shahed.net/image.axd?picture=WindowsLiveWriter/HostingSilverlight2.0inIIS_28A2/1_2.jpg"><img style="border-width: 0px;" src="http://www.shahed.net/image.axd?picture=WindowsLiveWriter/HostingSilverlight2.0inIIS_28A2/1_thumb.jpg" border="0" alt="1" width="244" height="236" /></a></p>
<p>Then click the MIME Types button. You should see a list as bellow.</p>
<p><a href="http://www.shahed.net/image.axd?picture=WindowsLiveWriter/HostingSilverlight2.0inIIS_28A2/2_2.jpg"><img style="border-width: 0px;" src="http://www.shahed.net/image.axd?picture=WindowsLiveWriter/HostingSilverlight2.0inIIS_28A2/2_thumb.jpg" border="0" alt="2" width="229" height="244" /></a></p>
<p>If the .xap extension is not in the list then click <strong><em>New&#8230;</em></strong> and add the following entry:</p>
<p>Extension: .xap<br />
MIME type: application/x-silverlight-app</p>
<p>Now, check your site. You should get the silverlight objects properly.</p>
<p><a href="http://weblogs.asp.net/mschwarz/archive/2008/03/07/silverlight-2-not-working-on-production-web-server.aspx">http://weblogs.asp.net/mschwarz/archive/2008/03/07/silverlight-2-not-working-on-production-web-server.aspx</a></p>
<h2 class="pageTitle">Silverlight 2 not working on Production Web Server</h2>
<div>
<p>I got some questions about <em>why is <a href="http://www.silverlight.net/">Silverlight 2</a> beta not working on my production Web server?</em> Well, one of the most errors I found is the missing MIME type definition in IIS. Silverlight 2 doesn&#8217;t compile a DLL as the beta 1.1 did. The new file extension is .XAP. The only thing you have to do is following step:</p>
<ol>
<li>Open the Internet Information Services Manager (IIS Manager)</li>
<li>Right-click on IIS and select Properties</li>
<li>Click on the MIME-Types button</li>
<li>Click on New&#8230; to add a new MIME-Type</li>
<li>For file extension use <em>.XAP</em> and for the MIME-Type use <em><span style="text-decoration: line-through;">Assembly</span></em> <em>application/x-silverlight</em><br />
(don&#8217;t miss the dot before XAP!!)</li>
</ol>
<p>Now you are able to run your Silverlight 2 apps.</p>
<p><a href="http://www.ajaxpro.info/images/blog/Silverlight2notworkingonProductionWebSer_867/WindowClipping.png"><img style="border-width: 0px;" src="http://www.ajaxpro.info/images/blog/Silverlight2notworkingonProductionWebSer_867/WindowClipping_thumb.png" border="0" alt="WindowClipping" width="400" height="300" /></a></p>
<p>If you cannot modify the MIME type you can simple rename the ClientBin file to .DLL. Note that you have to modify the source param, too.</p>
<p><strong>Update:</strong> If you are using IIS7 yu can run following command. This will change the applicationHost.config in the subfolder config (section &lt;staticContent/&gt;):</p>
<p><span style="font-family: Courier New;">&#8220;%systemroot%\System32\inetsrv\appcmd&#8221; set config /section:staticContent /+[fileExtension='.xap',mimeType='application/x-silverlight']</span></div>
<p><a href="http://learn.iis.net/page.aspx/262/silverlight/">http://learn.iis.net/page.aspx/262/silverlight/</a></p>
<div class="article_header_container">
<div class="article_header_column_main">
<h1>Configuring IIS for Silverlight Applications</h1>
<div id="ctl00_ctl00_ContentPlaceHolder_ContentBody_authorExistsPanel">
<p class="article_created_on">Author: <strong>Walter Oliver</strong></p>
</div>
<p class="article_created_on">Published on December 06, 2007 by <a href="http://forums.iis.net/members/walterov.aspx">walterov</a></p>
<p class="article_updated_on">Updated on March 19, 2008 by <a href="http://forums.iis.net/members/walterov.aspx">walterov</a></p>
<p class="article_history">
<p class="article_rating">Average Rating                   function SendRating(id, rating)     {                new Ajax.Request(&#8216;/js/HelpfulHandler.ashx?command=rating&#8217;,       {         method:&#8217;post&#8217;,         parameters:  {contentid: id, vote: rating},         onSuccess: null, // function(transport){alert(transport.responseText);},         onFailure: function(){ alert(&#8216;Something went wrong&#8230;&#8217;) }       });            Element.show(&#8216;thanks&#8217;);         return false;     }          function login(url)     {         location.replace(url);  //       location.replace(&#8216;/login.aspx&#8217;);              }    <a title="Poor"> <img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_One" style="border-width: 0px;" title="Poor" src="http://learn.iis.net/themes/iis/images/star-community-left-off.png" alt="" /></a><a title="Poor"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Two" style="border-width: 0px;" title="Poor" src="http://learn.iis.net/themes/iis/images/star-community-right-off.png" alt="" /></a><a title="Fair"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Three" style="border-width: 0px;" title="Fair" src="http://learn.iis.net/themes/iis/images/star-community-left-off.png" alt="" /></a><a title="Fair"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Four" style="border-width: 0px;" title="Fair" src="http://learn.iis.net/themes/iis/images/star-community-right-off.png" alt="" /></a><a title="Average"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Five" style="border-width: 0px;" title="Average" src="http://learn.iis.net/themes/iis/images/star-community-left-off.png" alt="" /></a><a title="Average"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Six" style="border-width: 0px;" title="Average" src="http://learn.iis.net/themes/iis/images/star-community-right-off.png" alt="" /></a><a title="Good"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Seven" style="border-width: 0px;" title="Good" src="http://learn.iis.net/themes/iis/images/star-community-left-off.png" alt="" /></a><a title="Good"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Eight" style="border-width: 0px;" title="Good" src="http://learn.iis.net/themes/iis/images/star-community-right-off.png" alt="" /></a><a title="Excellent"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Nine" style="border-width: 0px;" title="Excellent" src="http://learn.iis.net/themes/iis/images/star-community-left-off.png" alt="" /></a><a title="Excellent"><img id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ArticleRating1_Ten" style="border-width: 0px;" title="Excellent" src="http://learn.iis.net/themes/iis/images/star-community-right-off.png" alt="" /></a> Rate It (0)  <span id="thanks" style="display: none;">Thank you for your feedback!</span></p>
</div>
<div class="article_header_right"><a id="ctl00_ctl00_ContentPlaceHolder_ContentBody_RSSLink" class="sprite icon_rss" href="http://learn.iis.net/rss.ashx?type=articlehistory&amp;cid=262"><span>RSS</span></a></p>
<div id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ShortCuts1_pnlHeader">function incrementAndPrint() {             new Ajax.Request(&#8216;/js/HelpfulHandler.ashx?command=print&#8217;,             {                 method:&#8217;post&#8217;,                 parameters:  Form.serialize(&#8216;aspnetForm&#8217;),                 onSuccess: null, // function(transport){alert(transport.responseText);},                 onFailure: function(){ alert(&#8216;Something went wrong&#8230;&#8217;) }             });             window.print();         }                  function sentEmail()         {           new Ajax.Request(&#8216;/js/HelpfulHandler.ashx?command=emailed&#8217;,           {             method:&#8217;post&#8217;,             parameters:  Form.serialize(&#8216;aspnetForm&#8217;),             onSuccess: null, // function(transport){alert(transport.responseText);},             onFailure: function(){ alert(&#8216;Something went wrong&#8230;&#8217;) }           });               }</p>
<ul class="article_nav">
<li id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ShortCuts1_PrintArticle"><a class="sprite icon_print">Print</a></li>
<li id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ShortCuts1_EmailArticle"><a id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ShortCuts1_EmailLink" class="sprite icon_email" href="mailto:yourname@yourcompany.com?subject=Configuring%20IIS%20for%20Silverlight%20Applications%20on%20learn.iis.net&amp;body=http://learn.iis.net/page.aspx/262/silverlight/">Email this topic</a></li>
<li id="ctl00_ctl00_ContentPlaceHolder_ContentBody_ShortCuts1_SaveToFavorites"><a class="sprite icon_save_to_fav">Save to Favorites</a></li>
</ul>
</div>
</div>
</div>
<div class="content_right_side_300px">
<div id="ctl00_ctl00_ContentPlaceHolder_ContentBody_LearnHomeFeaturedAd_StdAd">
<div class="heading_section">
<h2><span class="heading_section_top"> Featured IIS 7.0 Web Hosting</span></h2>
</div>
<div class="content_indent ad_item"><a href="http://www.discountasp.net/go/go.aspx?i=4722"><img class="ad_item_image_200x50" src="http://ads.asp.net/ads/200_50_windows2008KE.gif" alt="Windows 2008/IIS 7.0 Hosting is Here!" /></a></p>
<h3>Windows 2008/IIS 7.0 Hosting is Here!</h3>
<ul>
<li>Starting at $10/mo</li>
<li>Windows 2008 Servers w/ IIS7</li>
<li>Access to Microsoft IIS7 Manager</li>
<li>Trust Level Control</li>
<li>Pipeline Mode Selector Tool</li>
<li>ASP.NET 3.5/2.0</li>
<li>LINQ, AJAX, PHP5</li>
</ul>
<p><a href="http://www.discountasp.net/go/go.aspx?i=4723" target="_blank">Get 3 Months Free of IIS 7 Hosting Now</a></div>
<p><a href="http://ads.asp.net/a.aspx?ZoneID=32&amp;Task=Click&amp;Mode=HTML&amp;SiteID=1&amp;PageID=58505" target="_blank"> <img src="http://ads.asp.net/a.aspx?ZoneID=32&amp;Task=Get&amp;Mode=HTML&amp;SiteID=1&amp;PageID=58505" border="0" alt="" width="120" height="240" /></a></p>
<p id="ctl00_ctl00_ContentPlaceHolder_ContentBody_LearnHomeFeaturedAd_AdvertiseHereLink" class="advertise_here"><a href="http://www.iis.net/advertise/">advertise here</a></p>
</div>
</div>
<h2>Introduction</h2>
<p>Microsoft® Silverlight<sup>TM</sup> is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports fast, cost-effective delivery of high-quality video to all major browsers running on the Mac OS or Windows.</p>
<p>In most cases, hosters do not need to perform particular deployments to support Silverlight. However, check for the following basic items that could prevent Silverlight from functioning correctly.</p>
<h2>MIME Types</h2>
<h3>In Windows Server 2008 IIS 7.0</h3>
<p>All MIME types needed to support Silverlight are implemented by default in Windows Server 2008 IIS 7.0 and Windows Vista SP1.  Windows Vista RTM customers can add mime types by running &#8220;IIS Manager&#8221;, clicking on &#8220;Mime Types&#8221;, then clicking &#8220;add&#8221; and adding the following mime types:</p>
<ul>
<li>.xap     application/x-silverlight-app</li>
<li>.xaml    application/xaml+xml</li>
<li>.xbap    application/x-ms-xbap</li>
</ul>
<p><a href="http://learn.iis.net/file.axd?i=883"><img src="http://learn.iis.net/file.axd?i=883" border="0" alt="" /></a></p>
<p>Alternatively, you can add the following mime types to your %windir%\system32\inetsrv\config\applicationHost.config file in the &lt;staticContent&gt; section.</p>
<p>&lt;mimeMap fileExtension=&#8221;.xaml&#8221; mimeType=&#8221;application/xaml+xml&#8221; /&gt;<br />
&lt;mimeMap fileExtension=&#8221;.xap&#8221; mimeType=&#8221;application/x-silverlight-app&#8221; /&gt;<br />
&lt;mimeMap fileExtension=&#8221;.xbap&#8221; mimeType=&#8221;application/x-ms-xbap&#8221; /&gt;</p>
<h3>In Windows Server 2003 IIS 6.0</h3>
<p>To enable IIS 6.0 in Windows Server 2003 or IIS7 in Windows Vista RTM with the appropriate MIME Types, add:</p>
<ul>
<li>.xap     application/x-silverlight-app</li>
<li>.xaml    application/xaml+xml</li>
<li>.xbap    application/x-ms-xbap</li>
</ul>
<p>Here is a VBS script you could run to enable each of these types:</p>
<p>Const ADS_PROPERTY_UPDATE = 2<br />
&#8216;<br />
if WScript.Arguments.Count &lt; 2 then<br />
WScript.Echo &#8220;Usage: &#8221; + WScript.ScriptName + &#8221; extension mimetype&#8221;<br />
WScript.Quit<br />
end if<br />
&#8216;<br />
&#8216;Get the mimemap object.<br />
Set MimeMapObj = GetObject(&#8220;IIS://LocalHost/MimeMap&#8221;)<br />
&#8216;<br />
&#8216;Get the mappings from the MimeMap property.<br />
aMimeMap = MimeMapObj.GetEx(&#8220;MimeMap&#8221;)<br />
&#8216;<br />
&#8216; Add a new mapping.<br />
i = UBound(aMimeMap) + 1<br />
Redim Preserve aMimeMap(i)<br />
Set aMimeMap(i) = CreateObject(&#8220;MimeMap&#8221;)<br />
aMimeMap(i).Extension = WScript.Arguments(0)<br />
aMimeMap(i).MimeType = WScript.Arguments(1)<br />
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, &#8220;MimeMap&#8221;, aMimeMap<br />
MimeMapObj.SetInfo<br />
&#8216;<br />
WScript.Echo &#8220;MimeMap successfully added: &#8221;<br />
WScript.Echo &#8220;    Extension: &#8221; + WScript.Arguments(0)<br />
WScript.Echo &#8220;    Type:      &#8221; + WScript.Arguments(1)</p>
<p>If you copy and paste the code above into a VBS file and save it as ADDMIMETYPE.VBS the syntax to add each type would be:</p>
<p>ADDMIMETYPE.VBS  .xap  application/x-silverlight-app ADDMIMETYPE.VBS  .xaml application/xaml+xmlADDMIMETYPE.VBS  .xbap application/x-ms-xbap</p>
<h3>Using the IIS Manager User Interface in Windows Server 2003 IIS 6.0</h3>
<p>1. Go to Start\Administrative Tools and run IIS Manager, see figure below:</p>
<p><a href="http://learn.iis.net/file.axd?i=876"><img src="http://learn.iis.net/file.axd?i=876" border="0" alt="" /></a></p>
<p>2. Right click on the server name and select &#8220;Properties&#8221;, see figure below:</p>
<p><a href="http://learn.iis.net/file.axd?i=877"><img src="http://learn.iis.net/file.axd?i=877" border="0" alt="" /></a></p>
<p>3. In the Properties Dialog, click on the &#8220;MIME Types&#8221; button, see figure below:</p>
<p><a href="http://learn.iis.net/file.axd?i=878"><img src="http://learn.iis.net/file.axd?i=878" border="0" alt="" /></a></p>
<p>4. In the &#8220;MIME Types&#8221; Dialog, click the &#8220;New&#8221; button, see figure below:</p>
<p><a href="http://learn.iis.net/file.axd?i=879"><img src="http://learn.iis.net/file.axd?i=879" border="0" alt="" /></a></p>
<p>5. In the &#8220;MIME Type&#8221; Dialog enter one MIME Type at the time:</p>
<div class="article_content">
<li>.xap     application/x-silverlight-app</li>
<li>.xaml    application/xaml+xml</li>
<li>.xbap    application/x-ms-xbap</li>
<p>see figure below:</p>
<p><a href="http://learn.iis.net/file.axd?i=880"><img src="http://learn.iis.net/file.axd?i=880" border="0" alt="" /></a></p>
<p>For detailed information on Silverlight, visit <a href="http://silverlight.net/">http://silverlight.net/</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/05/hosting-silverlight-20-applications-on-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System.Data.SqlServerCe.3.5 not installed</title>
		<link>http://tech.avivo.si/2009/04/systemdatasqlserverce35-not-installed/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=systemdatasqlserverce35-not-installed</link>
		<comments>http://tech.avivo.si/2009/04/systemdatasqlserverce35-not-installed/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 12:43:35 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Silverlight/WPF]]></category>
		<category><![CDATA[microsoft sql server compact 3.5]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[System.Data.SqlServerCe.3.5' not installed]]></category>
		<category><![CDATA[Windows Vista 64-bit]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=76</guid>
		<description><![CDATA[SQL Compact is a great little database and highly recommended. However it was designed for use on small compact, hence its name, devices and that has some drawbacks. One of these is that it doesn&#8217;t run as a 64 bits application. And by default if you create a .NET application it is compile as &#8220;Any [...]]]></description>
			<content:encoded><![CDATA[<p>SQL Compact is a great little database and highly recommended. However it was designed for use on small compact, hence its name, devices and that has some drawbacks. One of these is that it doesn&#8217;t run as a 64 bits application. And by default if you create a .NET application it is compile as &#8220;Any CPU&#8221; meaning it will run as a 64 bits application on a 64 bits version of Windows.</p>
<p>I, or I should say <a href="http://blogs.msdn.com/rjacobs/default.aspx">Ron Jacobs</a>, ran into that using my <a href="http://code.msdn.microsoft.com/SqlCeWFPersistence">SqlCeWorkflowPersistenceService</a> because the sample/test application  was set to the default of &#8220;Any CPU&#8221;. The result is that the LINQ provider cannot load the runtime and a InvalidOperationException with message &#8220;Cannot open &#8216;WorkflowPersistenceDatabase.sdf&#8217;. Provider &#8216;System.Data.SqlServerCe.3.5&#8242; not installed.&#8221; is the result. Now the fix is rather easy but it has to be done in the main program and that is to compile it for X86 instead of Any CPU.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.SQLCompact3.5ona64bitWindows_5F00_132AE/X86.gif"><img style="border: 0px none;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.SQLCompact3.5ona64bitWindows_5F00_132AE/X86_5F00_thumb.gif" border="0" alt="X86" width="500" height="343" /></a></p>
<p>Do this and any application using  SQL Compact 3.5 will happily run on Windows 64bit as a WOW Application.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/04/systemdatasqlserverce35-not-installed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ArrayOfXElement not recognized by Silverlight 2.0</title>
		<link>http://tech.avivo.si/2009/03/arrayofxelement-not-recognized-by-silverlight-20/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=arrayofxelement-not-recognized-by-silverlight-20</link>
		<comments>http://tech.avivo.si/2009/03/arrayofxelement-not-recognized-by-silverlight-20/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 19:26:54 +0000</pubDate>
		<dc:creator>Avivo</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[ArrayOfXElement]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[interactive]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[multimedia]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[silverlight 2]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.sweetucan.com/?p=40</guid>
		<description><![CDATA[Last weekend I was working on a Silverlight 2.0 game that loads and saves scores to an external database. Database is accessed via web service which has two methods: GetScore and SaveScore. GetScore returns DataSet and SaveScore returns nothing. Web service proxy is generated as usual &#8211; right click on the project node in VS2008, [...]]]></description>
			<content:encoded><![CDATA[<p>Last weekend I was working on a Silverlight 2.0 game that loads and saves scores to an external database. Database is accessed via web service which has two methods: GetScore and SaveScore. GetScore returns DataSet and SaveScore returns nothing.</p>
<p>Web service proxy is generated as usual &#8211; right click on the project node in VS2008, &#8220;Add Service Reference&#8230;&#8221;, enter url, proxy class is generated and the methods are accessible in the code. But when I tried to build the project an error occured: <em>&#8220;The type or namespace name &#8216;ArrayOfXElement&#8217; does not exist in the namespace&#8221;</em> which means that <strong>ArrayOfXElement is unrecognized</strong> class for the compiler. Searching on the Google reveals that this happens when service method returns DataSet, so <strong>ArrayOfXElement is actually DataSet</strong> and <strong>DataSets are not supported in Silverlight 2.0</strong>.</p>
<p>A quick solution is to replace all &#8216;ArrayOfXElement&#8217; words with &#8216;object&#8217;. Project would build that way but the data would have no meaning.</p>
<p>Another solution is to change the web service return type but this is not always editable by the client side developer.</p>
<p>Finally, workaround idea is to<strong> get DataSet schema and convert it to a class</strong>. How to do this?<br />
1. Create a dummy WPF project.<br />
2. Add web service reference to the WPF project. Return type is DataSet instead of ArrayOfXElement.<br />
3. Write some code to call a web service methods that returns DataSet then extract xsd schema and save it to the disk. Build and run. Sample:<br />
<span>GameServiceClient client = new GameServiceClient();</span><br />
<span>DataSet ds = client.GetScore(1, &#8220;abc&#8221;, &#8220;&#8221;, DateTime.Now);</span><br />
<span>ds.WriteXmlSchema(@&#8221;C:\Temp\Score.xsd&#8221;);</span><br />
4. So you have the xsd file. Now find &#8216;xsd.exe&#8217; which is located in the same directory as &#8216;svcutil.exe&#8217; (e.g. <em>C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin</em>). Run it with arguments:<br />
<span>xsd C:\Temp\Score.xsd /c</span><br />
5. xsd tool generates Score.cs file which contains tables as classes and columns as properties. Include the generated file in the Silverlight project.<br />
6. Replace all &#8216;ArrayOfXElement&#8217; words with &#8216;NewDataSet&#8217; or other class name, depends on the retrieved DataSet name and generated code.</p>
<p>Note that this is just an idea. So far the sample project builds fine but there is a problem with cross-domain security. Another story.</p>
<p>Url to the web service in this example:<br />
<a href="http://www.silverlightclub.com/apps/GameService.asmx">http://www.silverlightclub.com/apps/GameService.asmx</a></p>
<p>References:<br />
<a href="http://silverlight.net/forums/t/60518.aspx">http://silverlight.net/forums/t/60518.aspx</a><br />
<a href="http://blogs.msdn.com/suwatch/archive/2009/01/21/wcf-silverlight-exception-and-serialization.aspx">http://blogs.msdn.com/suwatch/archive/2009/01/21/wcf-silverlight-exception-and-serialization.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.avivo.si/2009/03/arrayofxelement-not-recognized-by-silverlight-20/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

