<?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>Ioan Lazarciuc&#039;s Weblog</title>
	<atom:link href="http://www.lazarciuc.ro/ioan/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lazarciuc.ro/ioan</link>
	<description>I program, therefore I exist.</description>
	<lastBuildDate>Mon, 19 Dec 2011 06:24:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Debugging Silverlight Sidebar Gadgets from Visual Studio</title>
		<link>http://www.lazarciuc.ro/ioan/2010/07/28/debugging-silverlight-sidebar-gadgets-from-visual-studio/</link>
		<comments>http://www.lazarciuc.ro/ioan/2010/07/28/debugging-silverlight-sidebar-gadgets-from-visual-studio/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:16:06 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2010/07/28/debugging-silverlight-sidebar-gadgets-from-visual-studio/</guid>
		<description><![CDATA[Ever since I started working with Windows Sidebar gadgets I’ve been debugging them the same way: enabling script debugging in the IE options (for JavaScript based gadgets) and then using the “Attach to Process” command from Visual Studio. When I created a template (posts here and here) that speeds up development of Silverlight Sidebar gadgets, [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since I started working with Windows Sidebar gadgets I’ve been debugging them the same way: enabling script debugging in the IE options (for JavaScript based gadgets) and then using the “Attach to Process” command from Visual Studio.</p>
<p>When I created a template (posts <a href="http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/" target="_blank">here</a> and <a href="http://www.lazarciuc.ro/ioan/2010/04/09/update-for-silverlight-sidebar-gadget-project-template/" target="_blank">here</a>) that speeds up development of Silverlight Sidebar gadgets, I wanted to offer the smoothest development experience possible. Ironically, that in itself has been a very bumpy ride. The last hurdle I had to cross was to provide the familiar debug experience (F5).</p>
<p> <span id="more-51"></span>
<p>My first attempt at this was just to set appropriate start options for the Web project that is in the template:</p>
<ul>
<li>Post build event that installs the gadget (runs a generated .gadget file) </li>
<li>%ProgramFiles(x86)%\Windows Sidebar\sidebar.exe as the start program </li>
</ul>
<p>This attempt failed with a very suggestive error:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SidebarAttach" border="0" alt="SidebarAttach" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2010/07/SidebarAttach.png" width="429" height="161" /> </p>
<p>I ran into this error every time the debugger was attached by the start options (F5, not using the Attach to Process command) and a Silverlight gadget was running in the Sidebar. I even tried to start debugging the sidebar when no Silverlight gadget ran, then added the Silverlight gadget to the Sidebar, but it was no use: same result.</p>
<p>I tried to get help with this error, but I could not find anything on it. The issue also seems like a very isolated corner case that does not affect too many people, so it would be tough to get any help.</p>
<p>While trying to find a workaround for F5 debugging, I wondered if I could run a custom app that manipulates the right Visual Studio instance to run the Attach to Process command and attach to sidebar.exe. Luckily, I was in Michael Leonard’s office at the time, because I got a quick answer: he had done similar things in the past. Half an hour later I had a code snippet about getting the Visual Studio automation object corresponding to a specific VS instance. Many thanks to Michael Leonard and Adam Nathan for getting the wheels turning on this.</p>
<p>The other parts of the solution flowed naturally:</p>
<ul>
<li>You can attach to the Visual Studio instance that has a specific solution open (info <a href="http://msdn.microsoft.com/en-us/library/ms228755.aspx" target="_blank">here</a>). </li>
<li>You can start the sidebar if it’s not already running (<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx" target="_blank">System.Diagnostics.Process.Start</a>) </li>
<li>You can launch the “Attach to Process” command using the DTE objects (info <a href="http://msdn.microsoft.com/en-us/library/envdte.process.attach.aspx" target="_blank">here</a>). </li>
<li>You can pass the full solution path as a command line parameter from the Visual Studio project Debug options (though not for all projects; for web projects it won’t work because macros are not supported). </li>
<li>You can provide a transparent retry logic for COM calls that fail due to the destination being busy (info <a href="http://msdn.microsoft.com/en-us/library/ms228772.aspx" target="_blank">here</a>; note the part about the single-thread apartment requirement). </li>
</ul>
<p>I incorporated the custom app and the required build events into a new version of the Silverlight Windows Gadget template, available both in <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bf347eb6-99bd-4c99-89d0-6ca3fe1eb54e" target="_blank">C#</a> and <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/01606aa9-d60d-47cc-8037-e7ba937d3a52" target="_blank">VB</a> flavour.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2010/07/28/debugging-silverlight-sidebar-gadgets-from-visual-studio/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Custom Parameters in Multi-Project Templates</title>
		<link>http://www.lazarciuc.ro/ioan/2010/04/25/custom-parameters-in-multi-project-templates/</link>
		<comments>http://www.lazarciuc.ro/ioan/2010/04/25/custom-parameters-in-multi-project-templates/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 15:07:59 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[multi-project]]></category>
		<category><![CDATA[parameter]]></category>
		<category><![CDATA[project template]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2010/04/25/custom-parameters-in-multi-project-templates/</guid>
		<description><![CDATA[Visual Studio project templates offer two ways of specifying template parameter values: In the .vstemplate file, using a CustomParameters section, as described here. Using a template wizard in order to specify run-time values in the IWizard.RunStarted method, as described here. The problem is that these mechanisms don’t work as one would expect in the case [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Studio project templates offer two ways of specifying template parameter values:</p>
<ul>
<li>In the .vstemplate file, using a CustomParameters section, as described <a href="http://msdn.microsoft.com/en-us/library/ms247063(VS.80).aspx" target="_blank">here</a>. </li>
<li>Using a template wizard in order to specify run-time values in the <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.templatewizard.iwizard.runstarted.aspx" target="_blank">IWizard.RunStarted</a> method, as described <a href="http://msdn.microsoft.com/en-us/library/ms185301(VS.80).aspx" target="_blank">here</a>. </li>
</ul>
<p>The problem is that these mechanisms don’t work as one would expect in the case of multi-project templates. The parameters specified in the root template are not picked up by the child project templates. I tried to find a workaround online but could not find anything. Finally, I came up with a workaround of my own.</p>
<p> <span id="more-44"></span>
<p>My workaround requires that the root project template and the child project templates have template wizards.</p>
<p>For demonstration purposes, let’s assume that the root template has a RootTemplateWizard class assigned as the template wizard. Let’s also assume that the child project that needs parameters values from the root template has a ChildTemplateWizard class assigned as the template wizard. If your child project template does not already have a template wizard, then you need to add one in order to pick up parameter values from the root template.</p>
<p>The main thing that will allow the two wizard classes to communicate is the fact that for multi-project templates the solution/project creation is done within the same application domain. This means that static members from each of the two classes are viewable in both classes.</p>
<p>Let’s say that ChildTemplateWizard needs to specify a $MyInheritedParam$ value. This is done in the IWizard.RunStarted method by adding the value to the replacementsDictionary method parameter with the key “$MyInheritedParam$”. Because we’re anticipating the value being present in a static field, we use that field as the value in the replacementsDictionary, as indicated in the code below:</p>
<div style="border-bottom: 1px solid; border-left: 1px solid; border-top: 1px solid; border-right: 1px solid">
<p align="left"><font color="#0000ff" face="Consolas">public</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">class</font><font color="#000000" face="Consolas"> </font><font color="#2b91af" face="Consolas">ChildTemplateWizard</font><font color="#000000" face="Consolas"> : </font><font color="#2b91af" face="Consolas">IWizard</font><font color="#000000" face="Consolas"></font> </p>
<p align="left">{</p>
<p align="left"><font color="#0000ff" face="Consolas">&#160;&#160;&#160; public</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">static</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">string</font><font color="#000000" face="Consolas"> MyInheritedParam;</font> </p>
<p align="left"><font color="#0000ff" face="Consolas">&#160;&#160;&#160; public</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">void</font><font color="#000000" face="Consolas"> RunStarted(</font><font color="#0000ff" face="Consolas">object</font><font color="#000000" face="Consolas"> automationObject, </font><font color="#2b91af" face="Consolas">Dictionary</font><font color="#000000" face="Consolas">&lt;</font><font color="#0000ff" face="Consolas">string</font><font color="#000000" face="Consolas">, </font><font color="#0000ff" face="Consolas">string</font><font color="#000000" face="Consolas">&gt; replacementsDictionary, </font><font color="#2b91af" face="Consolas">WizardRunKind</font><font color="#000000" face="Consolas"> runKind, </font><font color="#0000ff" face="Consolas">object</font><font color="#000000" face="Consolas">[] customParams)</font> </p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; replacementsDictionary[<font color="#a31515" face="Consolas">&quot;$MyInheritedParam$&quot;</font><font color="#000000" face="Consolas">] = MyInheritedParam;</font> </p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; …</p>
<p align="left">}</p>
</p></div>
<p>The value for the MyInheritedParam static field can be set from the RootTemplateWizard class, from its RunStarted method. The other IWizard methods are not suitable because they get called only after project generation is complete for all child projects. The code below illustrates setting the value for the static field.</p>
<div style="border-bottom: 1px solid; border-left: 1px solid; border-top: 1px solid; border-right: 1px solid">
<p align="left"><font color="#0000ff" face="Consolas">public</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">class</font><font color="#000000" face="Consolas"> </font><font color="#2b91af" face="Consolas">RootTemplateWizard</font><font color="#000000" face="Consolas"> : </font><font color="#2b91af" face="Consolas">IWizard</font><font color="#000000" face="Consolas"></font> </p>
<p align="left">{</p>
<p align="left"><font color="#0000ff" face="Consolas">&#160;&#160;&#160; public</font><font color="#000000" face="Consolas"> </font><font color="#0000ff" face="Consolas">void</font><font color="#000000" face="Consolas"> RunStarted(</font><font color="#0000ff" face="Consolas">object</font><font color="#000000" face="Consolas"> automationObject, </font><font color="#2b91af" face="Consolas">Dictionary</font><font color="#000000" face="Consolas">&lt;</font><font color="#0000ff" face="Consolas">string</font><font color="#000000" face="Consolas">, </font><font color="#0000ff" face="Consolas">string</font><font color="#000000" face="Consolas">&gt; replacementsDictionary, </font><font color="#2b91af" face="Consolas">WizardRunKind</font><font color="#000000" face="Consolas"> runKind, </font><font color="#0000ff" face="Consolas">object</font><font color="#000000" face="Consolas">[] customParams)</font> </p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; {</p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="#2b91af" face="Consolas">ChildTemplateWizard</font>.<font color="#000000" face="Consolas">MyInheritedParam = <font color="#a31515" face="Consolas">&quot;test value&quot;</font>;</font> </p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p align="left">&#160;&#160;&#160;&#160;&#160;&#160; …</p>
<p align="left">}</p>
</p></div>
<p>It’s worth mentioning that RootTemplateWizard and ChildTemplateWizard don’t have to be placed in separate assemblies. If placed in the same assembly, you only have to install a single assembly in the GAC when installing the multi-project template.</p>
<p>P.S. While writing this post and looking up some links for documentation I stumbled upon a <a href="http://www.matteozan.it/2008/04/16/iwizard-and-multiproject/" target="_blank">blog post</a> where the same principle is used to transmit custom parameters to child project templates. This post did not appear when I was searching for an already existing solution and for me it was not immediately clear that it solved this issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2010/04/25/custom-parameters-in-multi-project-templates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Update for Silverlight Sidebar Gadget Project Template</title>
		<link>http://www.lazarciuc.ro/ioan/2010/04/09/update-for-silverlight-sidebar-gadget-project-template/</link>
		<comments>http://www.lazarciuc.ro/ioan/2010/04/09/update-for-silverlight-sidebar-gadget-project-template/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 17:41:42 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[project template]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2010/04/09/update-for-silverlight-sidebar-gadget-project-template/</guid>
		<description><![CDATA[For the past few weeks I’ve been working on fixing a number of bugs signalled about the Silverlight Gadget Template I created a while ago. I’ve had to work around some strange issues and try everything I could to make the gadget development experience as pleasant as possible. I’d like to thank Kiran Bachu for [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few weeks I’ve been working on fixing a number of bugs signalled about the <a href="http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/" target="_blank">Silverlight Gadget Template</a> I created a while ago. I’ve had to work around some strange issues and try everything I could to make the gadget development experience as pleasant as possible. I’d like to thank Kiran Bachu for his valuable support in finding bugs and testing the gadget template.</p>
<p>Version <strong>1.8</strong> of the gadget is released for the following Visual Studio/Silverlight version combinations:</p>
<p><span id="more-39"></span>
<p>&#160;</p>
<table border="0" cellspacing="0" cellpadding="2" width="439">
<tbody>
<tr>
<td valign="top" width="132">&nbsp;</td>
<td valign="top" width="133"><strong>Silverlight 3.0 RTW</strong></td>
<td valign="top" width="172"><strong>Silverlight 4.0 RTW or Newer</strong></td>
</tr>
<tr>
<td valign="top" width="132"><strong>Visual Studio 2008</strong></td>
<td valign="top" width="133">Ver. 1.0 available <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2010/SilverlightSidebarGadget_2008_3RTW.vsi" target="_blank">here</a></td>
<td valign="top" width="172">N/A (not supported)</td>
</tr>
<tr>
<td valign="top" width="132"><strong>Visual Studio 2010</strong></td>
<td valign="top" width="133">Available for <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bf347eb6-99bd-4c99-89d0-6ca3fe1eb54e" target="_blank">C#</a> and <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/01606aa9-d60d-47cc-8037-e7ba937d3a52" target="_blank">VB</a></td>
<td valign="top" width="172">Available for <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bf347eb6-99bd-4c99-89d0-6ca3fe1eb54e" target="_blank">C#</a> and <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/01606aa9-d60d-47cc-8037-e7ba937d3a52" target="_blank">VB</a></td>
</tr>
</tbody>
</table>
<p>I modified the CSS for the HTML page that hosts the flyout and the gadget itself in order to eliminate all margins and padding. You can set these from the Silverlight controls.</p>
<p>I fixed the issue with docking/undocking the gadget. Aside from a JS bug I had, there was also some weird Silverlight behaviour that cause the freeze on some machines.</p>
<p>I exposed the SettingsClosed event for both the docked and undocked Silverlight controls and fixed an issue related to saving settings values.</p>
<p>I added build events for the SilverlightGadgetWeb project that create a .gadget file that can be used to install/update the gadget. I also added code to actually install/update the gadget on each build. I did this in order to provide an easy way of trying out code changes.</p>
<p><strike>I tried to fix the Silverlight application references in the SilverlightGadgetWeb project, but the only way that can be achieved is by providing a custom wizard for the project template that requires installation in the GAC. For now I think this requirement would be too strong for the template installation process. Aside from re-adding the Silverlight project references I also recommend setting the project dependencies manually to make sure that the project is the last one to be built in the solution. You can do this by right clicking the web project, choosing “Project Dependencies…” and then selecting all the Silverlight projects.</strike> (see below for details)</p>
<p>I also tried to arrange for “F5 debugging” in Visual Studio, but it was not possible. I managed to set the sidebar as the start program for the web project, but the debugger failed to attach to the process if the Silverlight gadget was running. Even if attaching succeeds at start-up (when no Silverlight gadget runs), when I added a Silverlight gadget the debugger crashed. In conclusion, Debug-&gt;Attach to Process is still the best way to debug gadgets.</p>
<p>I will be adding more versions of the template as soon as I get around to it, so stay tuned if your development configuration is not available yet. </p>
<p><strong>UPDATE:</strong> In version 1.5 of the template I created a project template wizard to properly create Silverlight application references for the SilverlightGadgetWeb project and to establish a correct build order. This wizard also prompts for the Silverlight version to use when creating the projects.</p>
<p><strong>UPDATE:</strong> In version 1.6 of the template I fixed the F5 debugging scenario by providing a fake SilverlightGadgetDebugger project in the template that runs a custom app which attaches the Visual Studio instance to the Sidebar process (more info on the workaround <a href="http://www.lazarciuc.ro/ioan/2010/07/28/debugging-silverlight-sidebar-gadgets-from-visual-studio/" target="_blank">here</a>). Starting with this version, I’m also providing a Visual Basic.NET flavour of the template. For the download link, check the table above.</p>
<p><strong>UPDATE:</strong> Version 1.7 of the template offers a fully automated debug experience within Visual Studio 2010 for the gadgets. In short, the SilverlightGadgetDebugger&#160; project will close any running version of the Sidebar and start a new one containing only the gadget to be debugged. When debugging/running is done, the original Sidebar (if it was running) is restored. Also, a bug involving detection of the 32 bit Program Files folder (which was used to detect installed Silverlight versions and locate the 32 bit Sidebar) has been fixed.</p>
<p><strong>UPDATE:</strong> Version 1.8 of the template offers support for debugging 64 bit gadgets. This can be done by setting the Target Platform to “x64” for the SilverlightGadgetDebugger. Changes to the Target Platform require a reload of the SilverlightGadgetDebugger project, because Visual Studio does not update the values of the parameters used in command line parameters for debugging.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2010/04/09/update-for-silverlight-sidebar-gadget-project-template/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>WCF Contract Limits?</title>
		<link>http://www.lazarciuc.ro/ioan/2009/05/28/wcf-contract-limits/</link>
		<comments>http://www.lazarciuc.ro/ioan/2009/05/28/wcf-contract-limits/#comments</comments>
		<pubDate>Wed, 27 May 2009 21:42:06 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[metadata exchange]]></category>
		<category><![CDATA[readerQuotas]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2009/05/28/wcf-contract-limits/</guid>
		<description><![CDATA[Today I’ve hit the size limit for a WCF service contract. It might seem unbelievable, but it’s almost true. I have a service contract with about 40 operations. After adding a new method to the contract, I get an error from the WCF Test Client: Error: Cannot obtain Metadata from http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex If this is a [...]]]></description>
			<content:encoded><![CDATA[<p>Today I’ve hit the size limit for a WCF service contract. It might seem unbelievable, but it’s almost true.</p>
<p> <span id="more-28"></span>
<p>I have a service contract with about 40 operations. After adding a new method to the contract, I get an error from the WCF Test Client:</p>
<blockquote><p><em>Error: Cannot obtain Metadata from </em><a href="http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex"><em>http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex</em></a><em> If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.&#160; For help enabling metadata publishing, please refer to the MSDN documentation at </em><a href="http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata"><em>http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata</em></a><em> Exchange Error&#160;&#160;&#160; URI: </em><a href="http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex"><em>http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex</em></a><em>&#160;&#160;&#160; Metadata contains a reference that cannot be resolved: '</em><a href="http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'"><em>http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'</em></a><em>.&#160;&#160;&#160; There is an error in XML document (1, 110009).&#160;&#160;&#160; The value for the 'base' attribute is invalid - 'q1:EntityObject' is an invalid value for the 'base' attribute..HTTP GET Error&#160;&#160;&#160; URI: </em><a href="http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex"><em>http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex</em></a><em>&#160;&#160;&#160; There was an error downloading '</em><a href="http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'"><em>http://localhost:8731/Design_Time_Addresses/CDA.Services/ApplicationService/mex'</em></a><em>.&#160;&#160;&#160; The request failed with HTTP status 400: Bad Request.</em></p>
</blockquote>
<p>Same error if i attempt to add this service to a project. The message seems to change depending on which method I leave out, or put in. It seems to be getting hilarious, but it’s not. Accidentally, i got this error(truncated):</p>
<blockquote><p><em>There is an error in XML document The maximum nametable character count quota (16384) has been exceeded while reading XML data.</em></p>
</blockquote>
<p>After a bit of searching online, I found out that this is a recognized issue with the default metadata exchange binding, <a href="http://social.msdn.microsoft.com/forums/en-US/wcf/thread/17592561-c470-452a-a52c-2a5a2839582c/" target="_blank">here</a>. The workarounds didn’t look good at all to me, so I continued searching. Then, I came across <a href="http://msdn.microsoft.com/en-us/library/aa395212.aspx" target="_blank">this</a>, which looks a lot more promising.</p>
<p>I created a custom wsHttpBinding that I used for the meta data contract. Now the task was to get the Visual Studio IDE and the WCF Test Client to use this binding when adding or updating a service reference. In order for this, corresponding bindings must be configured for each tool, in its .exe.config file. The binding must be identical with the one on the service side, and it must have a name that corresponds to the protocol used by it (http, https, net.tcp).</p>
<p>There are 3 places(files) that need to be updated: devenv.exe.config, WcfTestClient.exe.config and SvcUtil.exe.config. Actually, if you have several versions of the Windows SDK installed, you might have more than 3 places to modify. My advice is to do a search for each of the config file names and change as many of them as required in order to get your work back on track.</p>
<p>I would have thought that the mexHttp(s)Binding would allow for custom quotas for the reader. Perhaps in .NET 4.0? (vote <a href="https://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=459384" target="_blank">here</a> if it hurts)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2009/05/28/wcf-contract-limits/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>XNA Streaming &#8211; Part4</title>
		<link>http://www.lazarciuc.ro/ioan/2009/03/23/xna-streaming-part4/</link>
		<comments>http://www.lazarciuc.ro/ioan/2009/03/23/xna-streaming-part4/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 15:16:15 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[xna streaming]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2009/03/23/xna-streaming-part4/</guid>
		<description><![CDATA[In the previous parts of this articles I’ve talked about the service components of the XNA Streaming system. In this part, I’m going to talk about the Communication Broker. The role of the Communication Broker is to cover the communication with the Streaming Service. By doing so, the code required of client applications is simplified, [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous parts of this articles I’ve talked about the service components of the XNA Streaming system. In this part, I’m going to talk about the Communication Broker.</p>
<p>The role of the Communication Broker is to cover the communication with the Streaming Service. By doing so, the code required of client applications is simplified, and less duplicate code will be generated for each application using the system. the broker also caches all variable changes and periodically sends all changes accumulated to the service, thus reducing the number of calls per second required by a single client to a predictable amount.</p>
<p> <span id="more-27"></span>
<p>The broker uses a synchronized queue to accumulate changes and a timer to periodically clear the queue and send the resulting TimeSlice to the Streaming service. A receive background worker is used to reconstruct changes received from the Streaming service and raise appropriate UpdateProperty events.</p>
<p>The main operations provided by the broker are:</p>
<p><strong>Start:</strong> used to start the processing of the broker by registering with the Streaming service. If the game is run in broadcast mode, this method starts the timer for the periodical TimeSlice send. If in observer mode, the broker requests the whole state from the Streaming service and raises the UpdateGameState event, to allow the application to initialize its state.</p>
<p><strong>Stop:</strong> used to stop broker processing and to unregister from the Streaming service.</p>
<p>The events exposed by the broker are UpdateProperty, UpdateGameState and OutOfSynch. The first two events are to be sued by the application to change the value of a single property, or of all properties controlled by the XNA Streaming system. The OutOfSynch event is raised whenever the intervals between two consecutive slices do not match. The application can decide what to do at this point; for example, it could ask for the whole state of the game from the broker, which in turn would make the request to the Streaming service.</p>
<p>The application has to implement the GetCurrentState method of the IObservableGame interface in order to provide the broker with the current state of the application when needed.</p>
<h3>Considerations for Writing Applications</h3>
<p>There are some aspects that have to be taken into account when writing or adapting applications that use the XNA Streaming system.</p>
<p>User input has to be converted to changes of values. For example, mouse movement in a 3D environment can be translated into a set of 3 camera angles that completely define the way the camera is pointing. Pressing a button can be translated into a boolean flag set to true.</p>
<p>For simplicity, (most) user input should be ignored when in observe mode in order to avoid conflicts in UI commands that could have unpredictable effects.</p>
<p>One should take into careful consideration whether a piece of information is a “user input” variable, or a result of a law being applied to an initial value. Variables that are not broadcast have a high chance of being out of synch between the broadcaster and the observers. If the effect of such a variable is not critical (e.g. hit/miss decision) then it can be left out of the TimeSlice. Otherwise, one might discover that it is possible to miss a target, but hit it at the replay.</p>
<h3>Results</h3>
<p>The resulting prototype of the XNA Streaming system was presented at the 2008 edition of the Romanian Microsoft Community Bootcamp.</p>
<p><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2009/03/img-3595.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="IMG_3595" border="0" alt="IMG_3595" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2009/03/img-3595-thumb.jpg" width="452" height="303" /></a> </p>
<h3>Conclusion</h3>
<p>The XNA Streaming system is a good first prototype or toy, but it is by no means a decent communication framework. Aspects such as security, collaboration, dynamic send permissions, multicast, unicast and data conflict resolution have to be solved in order to obtain a communication framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2009/03/23/xna-streaming-part4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XNA Streaming &#8211; Part 3</title>
		<link>http://www.lazarciuc.ro/ioan/2009/02/27/xna-streaming-part-3/</link>
		<comments>http://www.lazarciuc.ro/ioan/2009/02/27/xna-streaming-part-3/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 18:43:15 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2009/02/27/xna-streaming-part-3/</guid>
		<description><![CDATA[After quite a long break, I resume the series of articles on my XNA Streaming project by describing the actual Stream Service component. This component is responsible for transmitting the broadcast information to all connected users. The information is encoded in (&#60;property name&#62;, &#60;value&#62;) pairs. All serializable data types are supported for values. Users register [...]]]></description>
			<content:encoded><![CDATA[<p>After quite a long break, I resume the series of articles on my XNA Streaming project by describing the actual Stream Service component. This component is responsible for transmitting the broadcast information to all connected users.</p>
<p>The information is encoded in (&lt;property name&gt;, &lt;value&gt;) pairs. All serializable data types are supported for values. Users register with the Stream Service either as Broadcaster or as Observer. After this step, the Broadcaster uses the service to send updates for information (property-value pairs). Observers get notified by the service of the updated information via a IXNAStreamCallback callback contract, a feature of WCF services.</p>
<p><span id="more-22"></span></p>
<p>Updates for a certain variable can occur at a very high frequency (camera angle in a 3D application). If a separate call to the service would be generated every few milliseconds, then the service would easily become overwhelmed by the calls. The solution chosen is to “buffer” several information changes and send them all at time, at set time intervals. We name this “buffer” a TimeSlice. A time slice has a Duration and several time slice entries. A TimeSliceEntry has a PropertyName, a Value and a SliceOffset, used to express the time since the beginning of the TimeSlice when the value change has occurred. This way we gain control over the number of calls made to the service.</p>
<p>The Stream Service provides the following operations:</p>
<p><strong>RegisterCallback:</strong> used to register with an application (given by name) for a role (given as a member of a GameMode enumeration). Only one Broadcaster can exist. This operation involves storing a user’s callback interface instance in a dictionary that has the application’s name as key and a list of callback interfaces (IXNAStreamCallback) instances.</p>
<p><strong>UnregisterCallback:</strong> used to safely end a registration with an application (if a client does not unregister, sending updates or requesting the overall state would fail).</p>
<p><strong>UpdateStateVariables:</strong> used to send a TimeSlice to all subscribers of an application. This is the actual method that performs the broadcast. It uses a method defined in the callback contract to broadcast the TimeSlice to all registered clients except the broadcaster.</p>
<p><strong>GetCurrentState:</strong> to be used by an Observer in order to resynchronize with the broadcaster. This method should be called right after registering with an application. The GameState returned is a collection of game state entries. Each GameStateEntry contains a Key (the name of the variable) and a Value. The Stream Service request the current GameState from the Broadcaster via the callback contract.</p>
<p>The IXNAStreamCallback contract contains the following operations:</p>
<p><strong>StateVariablesChanged:</strong> service calls this method for Observers whenever it receives a TimeSlice from the Broadcaster. It is up to the client to reconstruct the information changes in the TimeSlice with proper timing.</p>
<p><strong>GetCurrentState:</strong> service calls this method for the Broadcaster whenever it receives a corresponding request from an Observer. The method returns the current GameState.</p>
<p>The Stream Service does not provide complex functionality, in order to make the actual information broadcast as fast as possible. The more complex functionality is implemented in the Communication Broker, that will be described in the next part of the series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2009/02/27/xna-streaming-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA Streaming &#8211; Part 2</title>
		<link>http://www.lazarciuc.ro/ioan/2008/10/26/xna-streaming-part-2/</link>
		<comments>http://www.lazarciuc.ro/ioan/2008/10/26/xna-streaming-part-2/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 23:31:03 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/10/26/xna-streaming-part-2/</guid>
		<description><![CDATA[In part one of this article, I did an overview of the XNA Streaming project. In this part I’m going to describe the File Transfer Service. The main responsibility of the File Transfer Service is to provide access to streamable games. The service stores the game files in a database table, together with their relative [...]]]></description>
			<content:encoded><![CDATA[<p>In <a target="_blank" href="http://www.lazarciuc.ro/ioan/2008/09/21/xna-streaming-part-1/" title="XNA Stremaing - Part 1">part one</a> of this article, I did an overview of the XNA Streaming project. In this part I’m going to describe the File Transfer Service.</p>
<p>The main responsibility of the File Transfer Service is to provide access to streamable games. The service stores the game files in a database table, together with their relative file paths. This way the file system structure can be recreated when downloading the game. The game’s name, author and a short description are also stored in another table.</p>
<p><span id="more-21"></span></p>
<p>The operations that the File Transfer Service supports are:</p>
<ul>
<li>Create a game with no files: This operation simply creates a game entity with the game’s name, author and description with no files.</li>
<li>Upload a file for an already created game: This operation stores a file together with it’s relative path to the game’s folder for a previously created game. This operation gets invoked for each file in a game’s folder.</li>
<li>Delete a game: Removes a game from the database together with its files.</li>
<li>Get all uploaded games: This operation returns a collection of general information about uploaded games (game name, uploader and description).</li>
<li>Get all relative file paths for a game: This operation returns a collection containing the relative paths for all the files of a game. This list can be used to download each file and save locally.</li>
<li>Download a file from a game: This operation downloads a file specified by the game to which it belongs and its relative path to the game folder.</li>
<li>Get start up information for a game: This operation returns the game’s name, which is used to identify the streamed game at runtime, the address and endpoint name for the Streaming service. This information is used to start a game, both in observe or in broadcast mode.</li>
</ul>
<p>The download/upload of each file takes place through streaming. This limits the in memory portion of a potentially large file at any moment to the size of the buffer of the stream. Stream parameters and return values are a feature of WCF services.</p>
<p>The File Streaming Service has as UI an <a target="_blank" href="http://msdn.microsoft.com/en-us/library/aa970060.aspx">XBAP</a> that helps in uploading, downloading and starting a game.</p>
<p><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/XNAStreamingPart2_99B5/image.png"><img border="0" width="426" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/XNAStreamingPart2_99B5/image_thumb.png" alt="image" height="261" style="display: inline; border-width: 0px" title="image" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2008/10/26/xna-streaming-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XNA Streaming &#8211; Part 1</title>
		<link>http://www.lazarciuc.ro/ioan/2008/09/21/xna-streaming-part-1/</link>
		<comments>http://www.lazarciuc.ro/ioan/2008/09/21/xna-streaming-part-1/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 21:38:53 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[streaming]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/09/21/xna-streaming-part-1/</guid>
		<description><![CDATA[Introduction As I mentioned in my previous post, at this year's Microsoft Community Bootcamp I entered in the demo competition together with Adi. We've had some issues in the past with (cheap) broadcasting of presentations. There are plenty of professional tools out there that accomplish this goal, but that's not my point. My point is [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>As I mentioned in my previous <a href="http://www.lazarciuc.ro/ioan/2008/09/18/microsoft-community-bootcamp-v5/" target="_blank">post</a>, at this year's Microsoft Community Bootcamp I entered in the demo competition together with <a href="http://adimuresan.wordpress.com/" target="_blank">Adi</a>. We've had some issues in the past with (cheap) broadcasting of presentations. There are plenty of professional tools out there that accomplish this goal, but that's not my point. My point is that I have not yet found a cheap (free) utility that will allow me to give a presentation to several viewers that may not be in the same room (or the screen isn't big enough for the whole audience).</p>
<p>Given this background, Adi proposed we create a way in which several people can see the same thing that a broadcaster transmits. Further, the "thing" that everyone sees is actually an XNA game, that could might as well be an interactive presentation in 3D.</p>
<p><span id="more-20"></span></p>
<h3>Description</h3>
<p>The main idea is that, given an XNA game (possibly a game that did not take into consideration broadcasting though our "system"), produce a mechanism such that a <em>broadcaster</em> can transmit the content on the screen to any number of <em>observers</em>. As infrastructure for communication a WCF service was chosen. The reason for this is because it is relatively quick to implement and set up, it supports binary protocols and also bidirectional, asynchronous communication via service callbacks.</p>
<p>The first idea that comes to mind when deciding what to broadcast is whole images, pixel by pixel. The trouble with this is that if we have an application with resolution of 800x600 pixels, 32 bit color depth, at 60 frames/second, then we would require at least 109 MBytes/second/observer. This is totally unacceptable. Even with video compression, it would still require substantial bandwidth.</p>
<p>Instead, we decided that we could reduce the whole state of a game to a few state variables and a few "laws" that govern how these state variables evolve in time. Transmitting only some state variables proves to require much less bandwidth than transmitting the whole image. To further reduce the size of the messages transmitted, we identified 2 categories of state variables: the ones that are directly influenced by a user (through keyboard input for example), and the ones that have an initial value, and a law that dictates it's evolution in time. The state variables that evolve independent of user input can be left out of the "frame-by-frame" transmissions, and just the initial value has to be transmitted.</p>
<h3>XNA Streaming Components</h3>
<p>Given the initial description of the system proposed, we decided initially on three components:</p>
<p>The Streaming Service, that would receive calls from the broadcaster when state variables change and then transmit those changes through callbacks to all the subscribed observers. Aside from this main communication channel, the Streaming Service also provides initial synchronization for observers, meaning the service prompts the broadcaster (through a callback) to send the whole game state each time a new observer connects.</p>
<p>The File Transfer Service is responsible for storing all "broadcastable" game binaries,  delivering them to clients and providing startup information for each game (Streaming Service address).</p>
<p>The actual game, which has to be able to run in two modes: broadcast and observer. The game makes service calls to transmit/request state variables and responds to the callbacks of the Streaming Service.</p>
<p>At this point we analysed the communication between the game and the Streaming Service. Everything seemed fine, except for one detail: if we have a camera component that provides tens if not hundreds of new values every second, and we take into consideration that we have more than just the camera in a game, we can see that the number of service method calls performed by the broadcaster to transmit state variable changes is in the order of hundreds (at least) per second. This will cripple the service, regardless of the hardware it runs on (provided we stick to the "cheap" area...). A way to seriously cut down the number of service method calls was needed.</p>
<p>One way to reduce the service calls is to buffer the state variable changes, i.e. store each value together with the time at which the change occurred, and after a specific amount of time, send all buffered variable changes to the service, which in turn redistributes them to the observers, which reconstruct the sequence of state variable changes using the information received and timers. We call each such buffer a TimeSlice, and a touple of the form &lt;VarName, VarValue, TimeSpan&gt; a SliceEntry, where the TimeSpan is the time interval passed since the beginning of the current TimeSlice.</p>
<p>At this point we decided to call the new component a CommunicationBroker. It became clear that all code that would involve the Streaming Service would now be placed in the CommunicationBroker, and that sending calls/responding to the Streaming Service can be abstracted through this broker. In fact we now obtained an XNA Streaming Framework. This significantly reduces the complexity of the code that is necessary in the streamed game. Further more, now we had an actual streaming part, we stream the variable changes.</p>
<p>This is the end of part one of the article. In subsequent parts, I will describe each component in more detail and present some preliminary test results.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2008/09/21/xna-streaming-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Community Bootcamp v5</title>
		<link>http://www.lazarciuc.ro/ioan/2008/09/18/microsoft-community-bootcamp-v5/</link>
		<comments>http://www.lazarciuc.ro/ioan/2008/09/18/microsoft-community-bootcamp-v5/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 21:53:55 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Community]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/09/18/microsoft-community-bootcamp-v5/</guid>
		<description><![CDATA[During 11.09.2008 and 14.09.2008 I attended the fifth annual event dedicated to Microsoft professionals from the industry and academic environment. I also attended last year and wrote a bit about the experience here. A change from last year's event was the fact that this year, the professionals invited were almost as many as MSPs (until [...]]]></description>
			<content:encoded><![CDATA[<p><a title="IMG_0047" href="http://www.flickr.com/photos/12744616@N08/2860921788/"><img alt="IMG_0047" src="http://static.flickr.com/3051/2860921788_9f9b1e8819_m.jpg" align="left" border="0" /></a>During 11.09.2008 and 14.09.2008 I attended the fifth annual event dedicated to Microsoft professionals from the industry and academic environment. I also attended last year and wrote a bit about the experience <a href="http://www.lazarciuc.ro/ioan/2007/09/06/microsoft-community-bootcamp/" target="_blank">here</a>. A change from last year's event was the fact that this year, the professionals invited were almost as many as MSPs (until now,&#160; only a handful of MVPs had been invited). The location was Vatra Dornei. Possibly due to the fact that the bootcamp was held later than last year, it was much colder (and so we were &quot;encouraged&quot; to stay indoors or dress &quot;heavily&quot;).</p>
<p><span id="more-19"></span></p>
<p>We all received a book on blogging and one on how to overcome disadvantages that prevent you from continuing your path on the road to (more) success (yes, it sounds a bit cheesy, but the book might be insightful). Keeping the inspirational note, the event's T-shirt featured Microsoft's <a href="http://www.microsoft-watch.com/content/corporate/microsofts_blue_monster.html" target="_blank">Blue Monster</a>, and the attached slogan: &quot;Change the world or go home&quot;.</p>
<p>The first day was dedicated to MSP presentations. We started with some laughs as each university team lead stepped up and presented last year's achievements in a rather &quot;fashionable&quot; way...</p>
<table cellspacing="0" cellpadding="2" width="404" border="0">
<tbody>
<tr>
<td valign="top" width="103"><a title="Step up!" href="http://www.flickr.com/photos/12744616@N08/2857033894/"><img alt="Step up!" src="http://static.flickr.com/3071/2857033894_052b41c93a_t.jpg" border="0" /></a></td>
<td valign="top" width="106"><a title="IMG_0011" href="http://www.flickr.com/photos/12744616@N08/2860054185/"><img alt="IMG_0011" src="http://static.flickr.com/2018/2860054185_0377a9513e_t.jpg" border="0" /></a></td>
<td valign="top" width="108"><a title="IMG_0038" href="http://www.flickr.com/photos/12744616@N08/2860905560/"><img alt="IMG_0038" src="http://static.flickr.com/3064/2860905560_a53aa1f617_t.jpg" border="0" /></a></td>
<td valign="top" width="85"><a title="IMG_0023" href="http://www.flickr.com/photos/12744616@N08/2860066179/"><img alt="IMG_0023" src="http://static.flickr.com/3199/2860066179_cc0a34421c_t.jpg" border="0" /></a></td>
</tr>
</tbody>
</table>
<p>An interesting point was the demo competition. Myself and <a href="http://adimuresan.wordpress.com/" target="_blank">Adi</a> participated with a project named XNA Streaming (<a href="http://www.catalinzima.com/" target="_blank">Cata</a> will, again, correct me into saying it's XNA Framework Content Streaming) that uses WCF to transmit a set of data from one XNA Framework application to another one, the aim being to obtain the same &quot;content&quot; on each machine. I'll get back with a post on how we did it (for real this time <img src='http://www.lazarciuc.ro/ioan/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ). The only competition was <a href="http://blog.nadas.ro/" target="_blank">Mihai Nadas</a>, with Acoustic Fingerprints. The two ideas were really nice (as nice as the one that won last year's competition), but I was a bit disappointed by the lack of competition. The outcome? Both projects were declared winners, and each won an XBOX 360 for their MSP team.</p>
<table cellspacing="0" cellpadding="2" width="461" border="0">
<tbody>
<tr>
<td valign="top" width="229"><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/MicrosoftCommunityBootcampv5_14D47/IMG_3596.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="151" alt="IMG_3596" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/MicrosoftCommunityBootcampv5_14D47/IMG_3596_thumb.jpg" width="224" border="0" /></a></td>
<td valign="top" width="230"><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/MicrosoftCommunityBootcampv5_14D47/IMG_3600.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="151" alt="IMG_3600" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/MicrosoftCommunityBootcampv5_14D47/IMG_3600_thumb.jpg" width="224" border="0" /></a></td>
</tr>
</tbody>
</table>
<p>The rest of the day was filled with more presentations on being a good technology evangelist. No fun in the first day... well, at least not &quot;organized&quot; fun. We managed to spread across the hotel's lobby and use it's wireless network to play some LAN games in the evening.</p>
<table cellspacing="0" cellpadding="2" width="401" border="0">
<tbody>
<tr>
<td valign="top" width="199"><a title="Boss man" href="http://www.flickr.com/photos/12744616@N08/2856227087/"><img height="100" alt="Boss man" src="http://static.flickr.com/3276/2856227087_94b816a72d_t.jpg" width="133" border="0" /></a></td>
<td valign="top" width="200"><a title="Passion" href="http://www.flickr.com/photos/12744616@N08/2856230315/"><img alt="Passion" src="http://static.flickr.com/3119/2856230315_996b5a98b0_t.jpg" align="middle" border="0" /></a></td>
</tr>
</tbody>
</table>
<p>Saturday morning there was a common session for MSPs and professionals on where Microsoft is going in the next year. After lunch, we had a bit of luck as the rain stopped and we went &quot;out in the open&quot; for some ATV, horseback riding, biking and Tyrolean traverse. Things went ok, considering it got quite cold, I had to ride a 700cc ATV with no helmet and one ATV crashed by tumbling through the air (I'm not kidding) and into someone's yard, but no one got (seriously) hurt.</p>
<p>In the evening, we had a few games of <a href="http://en.wikipedia.org/wiki/Mafia_(party_game)" target="_blank">Mafia</a>. It's quite a tradition at the Community Bootcamp, possibly because there's never a shortage in supply of great players. It was my first time playing the game and I enjoyed it.</p>
<p>On the last day, each team had a private talk with the academic program leader, Todi. After that, we had lunch and went home tired, but (at least a bit) happier...</p>
<p>The main attraction for (part) of our university's team were the squirrels in the park near our hotel. Apparently all Romanian squirrels answer to the name of Mariana, and they come to feed if you start making noise by knocking 2 nuts against each other. I can say that the squirrels respond well to food, as for the Mariana part... I'm not so convinced. Or maybe it's (somehow) my fault that they wouldn't answer my calls.</p>
<table cellspacing="0" cellpadding="2" width="400" border="1">
<tbody>
<tr>
<td valign="top" width="200"><a title="Feeding the invisible squirell" href="http://www.flickr.com/photos/12744616@N08/2857051264/"><img height="165" alt="Feeding the invisible squirell" src="http://static.flickr.com/3120/2857051264_8c482e9d62_m.jpg" width="220" border="0" /></a></td>
<td valign="top" width="200"><a title="More squirell feeding" href="http://www.flickr.com/photos/12744616@N08/2857048396/"><img height="165" alt="More squirell feeding" src="http://static.flickr.com/3100/2857048396_b29dcffb77_m.jpg" width="220" border="0" /></a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2008/09/18/microsoft-community-bootcamp-v5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Vista Sidebar Gadget Using Microsoft Silverlight</title>
		<link>http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/</link>
		<comments>http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 14:25:53 +0000</pubDate>
		<dc:creator>cretz</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Gadget]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[template. visual studio]]></category>

		<guid isPermaLink="false">http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/</guid>
		<description><![CDATA[Introduction Some while ago I did a post on how to create a Vista Sidebar gadget using JavaScript. I also mentioned that I tried to create the gadget using XBAP or Silverlight, but due to the limitations in those technologies at that time, I decided that I had to give up on too much of [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Some while ago I did a <a title="Creating Sidebar Gadgets using JavaScript only" href="http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/" target="_blank">post</a> on how to create a Vista Sidebar gadget using JavaScript. I also mentioned that I tried to create the gadget using XBAP or Silverlight, but due to the limitations in those technologies at that time, I decided that I had to give up on too much of the Sidebar gadget specific functionality (flyouts, cross domain data retrieval).</p>
<p>More than 6 months have passed since then and now I am pleased to announce that I've changed my opinion regarding Silverlight Sidebar gadgets. Due to the fact that the Silverlight technology has matured a lot (version 2.0 beta 2 is now available), Sidebar gadgets can be developed using this technology, without sacrificing any Sidebar gadget specific functionality. This is due to the fact that there is full interoperability between Silverlight and the JavaScript code. Also, cross domain calls are now allowed in Silverlight, so retrieving data is no longer an issue. Furthermore, it has been greatly enhanced due to the fact that one can consume <a title="MSDN on Windows Communication Foundation" href="http://msdn.microsoft.com/en-us/library/ms735119.aspx" target="_blank">WCF</a> services using Silverlight.</p>
</p>
<p> <span id="more-18"></span>
</p>
<h3>Getting Started</h3>
<p>The first step is to have a look over the &quot;classic&quot; <a href="http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/" target="_blank">way</a> of developing Sidebar gadgets. Even though most of the &quot;hard work&quot; can now be done in Silverlight, the &quot;wiring&quot;, the guts of the whole gadget are still the classic ones, relying on JavaScript and HTML. Next, if you are not familiar with Silverlight development, I recommend you spend some time getting comfortable with Silverlight. For this you can visit <a href="http://www.silverlight.net">http://www.silverlight.net</a> and try out the tutorials there.</p>
<p>The result of my inquiries in this subject is a Visual Studio project template that can be used to quickly start development for a Silverlight Sidebar gadget. I got inspired by the template <a title="Tim Heuer&#39;s Project Tempalte for Sidebar Gadgets" href="http://timheuer.com/blog/archive/2007/03/11/14010.aspx" target="_blank">Tim Heuer</a> has created for jump starting Sidebar gadget development using just JavaScript/HTML. The requirements for installing and using the template are:</p>
<ul>
<li>Microsoft Visual Studio 2008 (Standard or better) </li>
<li>Microsoft Silverlight 2.0 beta 2 </li>
<li>Silverlight Tools Beta 2 for Visual Studio 2008 </li>
</ul>
<p>After downloading the template installer from <a title="Silverlight Sidebar Gadget Project Template Installer" href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/SilverlightSidebarGadget.vsi" target="_blank">here</a>, in order to install it, just run the downloaded file. The Visual Studio Content Installer will handle the rest (click next and ignore security warnings, because I did not sign the template).</p>
<p>After installing the template, in order to create a new Sidebar gadget, in Visual Studio click File-&gt;New-&gt;Project. You will notice that under the C# node, at the bottom, under &quot;My Templates&quot;, a new entry has appeared: &quot;Silverlight Sidebar Gadget&quot;. Give the solution a name and then click Ok.</p>
<p><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/CreatingaVistaSidebarGadgetUsingSilverli_DEE6/NewProject.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="NewProject" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/CreatingaVistaSidebarGadgetUsingSilverli_DEE6/NewProject_thumb.jpg" width="468" height="333" /></a></p>
<p>You will notice that 6 projects have been automatically added to the newly created solution: SilverlightSidebarGadgetWeb, SilverlightGadgetDocked, SilverlightGadgetUnDocked, SilverlightGadgetSettings, SilverlightGadgetFlyout and SilverlightGadgetUtilities. In order, these correspond to: the main gadget web site project that will actually end up being deployed (all content and code is added to this site), the Silverlight control that is displayed when the gadget is docked, the Silverlight control that is displayed when the gadget is undocked, the Silverlight control that is displayed on the settings page of the gadget, the Silverlight control that is displayed on the flyout page of the gadget and a utilities library for Silverlight, providing a managed code API for Sidebar gadgets. This API translates to calls in the JavaScript Sidebar Gadget API.</p>
<p><strong>IMPORTANT:</strong> Due to limitations in the way the template is built, the Silverlight applications have to be added to the gadget's main project manually. This can be done by going to the Property Pages for the website project, the Silverlight Applications tab and then click add for each additional Silverlight project. Clear the &quot;Add a test page that references the control&quot; checkbox, and make sure the &quot;Enable Silverlight debugging&quot;checkbox is checked if you want debugging capabilities for Silverlight. Silverlight and JavaScript simultaneous debugging is not possible at the current time (Silverlight debugging requires disabling Script debugging from IE).</p>
<p><a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/CreatingaVistaSidebarGadgetUsingSilverli_DEE6/AddSilverlightApplications.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="AddSilverlightApplications" src="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/CreatingaVistaSidebarGadgetUsingSilverli_DEE6/AddSilverlightApplications_thumb.jpg" width="470" height="334" /></a></p>
<p>In a later version of the project template this will no longer be required, but for that I have to add a custom Wizard to the project template that can prepare the projects in the template.</p>
<p>The code is commented, so I'm not going to cover it in detail. Also, for Sidebar gadget development guidance, read my previous <a title="Creating Sidebar Gadgets using JavaScript only" href="http://www.lazarciuc.ro/ioan/2007/11/01/creating-a-windows-vista-sidebar-gadget/" target="_blank">post</a> on the topic. The gadget is set up to use Silverlight controls for each page of the gadget. This is not required, and Silverlight controls can be removed from the project (along with their projects form the solution) as needed. There are 2 main classes defined in the SilverlightGadgetUtilities class: SilverlightGadget and SilverlightGadgetEvents. The first is used to access the JavaScript Sidebar Gadget API. The second is used to expose the JavaScript events related to a gadget as managed events in the Silverlight controls.</p>
<h3>Known &quot;bumps&quot;</h3>
<p>There are some things that will simply not work, no matter how hard you try to get them to work. Usually this is due to the fact that the current Sidebar gadget API or the gadget user experience provided by Microsoft does not allow it. These &quot;hick-ups&quot; are specified in the documentation comments of the classes or directly as comments.</p>
<p>Due to the fact that the Gadget JavaScript object does not allow attaching multiple event handlers for the same event, one must take care what event handler is registered for a particular event. Possible outcomes are: events that do not get triggered at all in the Silverlight controls, events that get triggered only in some Silverlight controls.</p>
<p>Due to the user experience with Sidebar gadgets, some events cannot be triggered in Silverlight controls: the Docked, Undocked events, all gadget events in the flyout, etc.</p>
<p>Some properties from the SilverlightGadget class are read-only even though the Sidebar gadget JavaScript API specifies that they are read-write. This is due to the fact that attempting to set those properties resulted in exceptions at runtime and those exceptions are most probably caused by the JavaScript API itself.</p>
<p>I tried to &quot;discover&quot; all such &quot;bumps&quot; that might appear and document them in the template directly. If there is something I missed or you have a question, please <a href="http://www.lazarciuc.ro/ioan/contact/" target="_blank">contact me</a> or post a comment and I will try to modify the template to fix or document the issue. Also, any suggestions on improving this project template are welcomed.</p>
<p>I'm looking forward to seeing many Silverlight Sidebar gadgets being developed. If you create such a gadget using this project template, please let me know by posting a comment with a link to the Live Gallery page of the gadget or a link to a page describing it.</p>
<p>Once again, the link for the Visual Studio project template is displayed below.</p>
<p>FILE: <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/SilverlightSidebarGadget.vsi" target="_blank">SilverlightSidebarGadget.vsi</a></p>
<p><strong>UPDATE: </strong>If you have Microsoft Visual Studio 2008 SP1 installed, you will need the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=50A9EC01-267B-4521-B7D7-C0DBA8866434&amp;displaylang=en" target="_blank">Microsoft Visual Studio Tools Beta 2 for Visual Studio 2008</a> in order to be able to create Silverlight projects. This also means that you cannot use the provided template without installing the new version of the Silverlight Tools.</p>
<p><strong>UPDATE 2:</strong> I’ve upgraded the projects in the template for Silverlight 3 Beta. The corresponding template can be found <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/SilverlightSidebarGadget_3Beta.vsi" target="_blank">here</a>.</p>
<p><strong>UPDATE 3:</strong> I’ve created a version of the template for Silverlight 2 final. The corresponding template can be found <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2008/SilverlightSidebarGadget_2.vsi" target="_blank">here</a>.</p>
<p><strong>UPDATE 4:</strong> I’ve upgraded the projects in the template for Silverlight 3 RTW. The corresponding template can be found <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2009/SilverlightSidebarGadget_3RTW.vsi" target="_blank">here</a>.</p>
<p><strong>UPDATE 5:</strong> I’ve created a version of the template using Visual Basic projects. The corresponding template can be found <a href="http://www.lazarciuc.ro/ioan/wp-content/uploads/2009/SilverlightSidebarGadget_3RTW_vb.vsi" target="_blank">here</a>.</p>
<p><strong>UPDATE 6:</strong> I’ve created a version of the template for Visual Studio 2010, using the new extension format. The corresponding template can be found <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bf347eb6-99bd-4c99-89d0-6ca3fe1eb54e" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lazarciuc.ro/ioan/2008/08/02/creating-a-vista-sidebar-gadget-using-microsoft-silverlight/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
	</channel>
</rss>

