<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>sun's blog</title>
    <link>http://suntsu.ch/serendipity/</link>
    <description>...</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    <pubDate>Tue, 08 Jun 2010 08:05:42 GMT</pubDate>

    <image>
        <url>http://suntsu.ch/serendipity/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: sun's blog - ...</title>
        <link>http://suntsu.ch/serendipity/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>What is the default for WCF if InstanceContextMode is not set explicit</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/191-What-is-the-default-for-WCF-if-InstanceContextMode-is-not-set-explicit.html</link>
            <category>Azure</category>
            <category>WCF</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/191-What-is-the-default-for-WCF-if-InstanceContextMode-is-not-set-explicit.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=191</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=191</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    &lt;p&gt;If the attribute InstanceContextMode is not set explicit, the mode depends on the wcf settings. To be more specific, it depends on the &quot;reliableSession and on the &quot;security mode&quot; properties in case of wsHttpBinding.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;wsHttpBinding: &quot;ReliableSession = false&quot;, and &quot;SecurityMode = none&quot; means it is PerCall.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL2ltYWdlLnBuZw==&amp;amp;entry_id=191&quot; title=&quot;http://suntsu.ch/serendipity/uploads/image.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/image.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://suntsu.ch/serendipity/uploads/image_thumb.png&quot; width=&quot;650&quot; height=&quot;346&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;wsHttpBinding:&amp;#160; &lt;/strong&gt;&lt;strong&gt;&quot;ReliableSession = false&quot;, and &quot;SecurityMode=Message&quot; means it is PerSession.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL2ltYWdlLnBuZw==&amp;amp;entry_id=191&quot; title=&quot;http://suntsu.ch/serendipity/uploads/image.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/image.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://suntsu.ch/serendipity/uploads/image_thumb.png&quot; width=&quot;657&quot; height=&quot;480&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;wsHttpBinding: &lt;/strong&gt;&lt;strong&gt;&quot;ReliableSession = true&quot;, and &quot;SecurityMode=none&quot; means it is PerSession.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL2ltYWdlLnBuZw==&amp;amp;entry_id=191&quot; title=&quot;http://suntsu.ch/serendipity/uploads/image.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/image.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://suntsu.ch/serendipity/uploads/image_thumb.png&quot; width=&quot;651&quot; height=&quot;425&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;basicHttpBinding: It is always PerCall.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL2ltYWdlLnBuZw==&amp;amp;entry_id=191&quot; title=&quot;http://suntsu.ch/serendipity/uploads/image.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/image.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://suntsu.ch/serendipity/uploads/image_thumb.png&quot; width=&quot;648&quot; height=&quot;484&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If you set the attribute &quot;PerSession&quot; where the settings doesn&#039;t allow to use sessions(because of using basicHttpBinding, or because of not using security and relaiability on wsHttpBindng), a exception is thrown at startup.&lt;/p&gt;  &lt;p&gt;It is best practice to set the expected InstanceContextMode explicit, then it is clear what wcf will do(either what you say, or fail at startup)&lt;/p&gt;  &lt;p&gt;[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]    &lt;br /&gt;class YourService : IYourService&lt;/p&gt;  &lt;p&gt;[ServiceContract(Namespace=&amp;quot;....&amp;quot;, SessionMode=SessionMode.NotAllowed)]    &lt;br /&gt;interface IYourSession&lt;/p&gt;  &lt;p&gt;Documentation: &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L3N5c3RlbS5zZXJ2aWNlbW9kZWwuaW5zdGFuY2Vjb250ZXh0bW9kZS5hc3B4&amp;amp;entry_id=191&quot; title=&quot;http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx&quot;  onmouseover=&quot;window.status=&#039;http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontextmode.aspx&lt;/a&gt;&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 08 Jun 2010 10:05:42 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/191-guid.html</guid>
    
</item>
<item>
    <title>Visual Studio 2010 Problem: Windows Azure Tools: Failed to initialize the Development Storage service.</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/190-Visual-Studio-2010-Problem-Windows-Azure-Tools-Failed-to-initialize-the-Development-Storage-service..html</link>
            <category>Azure</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/190-Visual-Studio-2010-Problem-Windows-Azure-Tools-Failed-to-initialize-the-Development-Storage-service..html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=190</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=190</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    &lt;p&gt;I&#039;ve installed the Azure Tools for visual studio 2010, and then tried to debug a simple hello world application. Then i&#039;ve got the following error:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font size=&quot;1&quot;&gt;Windows Azure Tools: Failed to initialize the Development Storage service. Unable to start Development Storage. Failed to start Development Storage: the SQL Server instance &#039;localhost\SQLExpress&#039; could not be found.&amp;#160;&amp;#160; Please configure the SQL Server instance for Development Storage using the &#039;DSInit&#039; utility in the Windows Azure SDK.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;I do not have SQLExpress installed, but the full version of sql server 2008R2.&lt;/p&gt;  &lt;p&gt;This message told me to use the &quot;DSInit&quot; utility for setting up some ports and the storage database. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL0F6dXJlU3FsQ29tbWFuZFN0YXJ0RmFpbC5wbmc=&amp;amp;entry_id=190&quot; title=&quot;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartFail.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartFail.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;AzureSqlCommandStartFail&quot; border=&quot;0&quot; alt=&quot;AzureSqlCommandStartFail&quot; src=&quot;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartFail_thumb.png&quot; width=&quot;737&quot; height=&quot;154&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;But when i&#039;ve executed this query, i&#039;ve got this:&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#ff0000&quot;&gt;Failed to create database &#039;DevelopmentStorageDb20090919&#039; : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#ff0000&quot;&gt;One or more initialization actions failed. The development storage cannot be used without resolving these errors.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL0F6dXJlU1FMTm90V29ya2luZy5wbmc=&amp;amp;entry_id=190&quot; title=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLNotWorking.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/AzureSQLNotWorking.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;AzureSQLNotWorking&quot; border=&quot;0&quot; alt=&quot;AzureSQLNotWorking&quot; src=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLNotWorking_thumb.png&quot; width=&quot;449&quot; height=&quot;349&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now, i&#039;ve checked the InstanceName of my sql server:&lt;/p&gt;  &lt;p&gt;set nocount on   &lt;br /&gt;Declare @key Varchar(100), @PortNumber varchar(20)    &lt;br /&gt;if charindex(&#039;\&#039;,CONVERT(char(20), SERVERPROPERTY(&#039;servername&#039;)),0) &amp;lt;&amp;gt;0    &lt;br /&gt;begin    &lt;br /&gt;set @key = &#039;SOFTWARE\MICROSOFT\Microsoft SQL Server\&#039;+@@servicename+&#039;\MSSQLServer\Supersocketnetlib\TCP&#039;    &lt;br /&gt;end    &lt;br /&gt;else    &lt;br /&gt;begin    &lt;br /&gt;set @key = &#039;SOFTWARE\MICROSOFT\MSSQLServer\MSSQLServer\Supersocketnetlib\TCP&#039;    &lt;br /&gt;end    &lt;br /&gt;EXEC master..xp_regread @rootkey=&#039;HKEY_LOCAL_MACHINE&#039;, @key=@key,@value_name=&#039;Tcpport&#039;,@value=@PortNumber OUTPUT    &lt;br /&gt;SELECT CONVERT(char(20), SERVERPROPERTY(&#039;servername&#039;)) ServerName,    &lt;br /&gt;CONVERT(char(20), SERVERPROPERTY(&#039;InstanceName&#039;)) instancename,    &lt;br /&gt;CONVERT(char(20), SERVERPROPERTY(&#039;MachineName&#039;))    &lt;br /&gt;as HOSTNAME, convert(varchar(10),@PortNumber) PortNumber&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Which showed me that i don&#039;t have any instance name:&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL0F6dXJlU1FMU2VydmVySW5zdGFuY2VOYW1lLnBuZw==&amp;amp;entry_id=190&quot; title=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLServerInstanceName.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/AzureSQLServerInstanceName.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;AzureSQLServerInstanceName&quot; border=&quot;0&quot; alt=&quot;AzureSQLServerInstanceName&quot; src=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLServerInstanceName_thumb.png&quot; width=&quot;451&quot; height=&quot;106&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It seems not to be possible(or at least not easy) to change the InstanceName for the sql server, so i did not. &lt;/p&gt;  &lt;p&gt;But i now tried the DSInit tool with parameter &quot;/sqlinstance:&quot; and this worked.(No InstanceName set)&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL0F6dXJlU3FsQ29tbWFuZFN0YXJ0V29yay5wbmc=&amp;amp;entry_id=190&quot; title=&quot;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartWork.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartWork.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;AzureSqlCommandStartWork&quot; border=&quot;0&quot; alt=&quot;AzureSqlCommandStartWork&quot; src=&quot;http://suntsu.ch/serendipity/uploads/AzureSqlCommandStartWork_thumb.png&quot; width=&quot;816&quot; height=&quot;143&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL0F6dXJlU1FMV29ya2luZy5wbmc=&amp;amp;entry_id=190&quot; title=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLWorking.png&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/AzureSQLWorking.png&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;AzureSQLWorking&quot; border=&quot;0&quot; alt=&quot;AzureSQLWorking&quot; src=&quot;http://suntsu.ch/serendipity/uploads/AzureSQLWorking_thumb.png&quot; width=&quot;400&quot; height=&quot;309&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This might be helpfull for some which have the same issue.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Thu, 29 Apr 2010 08:26:46 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/190-guid.html</guid>
    <category>azure</category>
<category>Visual Studio</category>

</item>
<item>
    <title>Attach process at runtime in visual studio 2008</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/188-Attach-process-at-runtime-in-visual-studio-2008.html</link>
            <category>.net</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/188-Attach-process-at-runtime-in-visual-studio-2008.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=188</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=188</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    I have a wcf service which has to be unittested. &lt;br /&gt;
The wcf service is hosted in a console application. &lt;br /&gt;
In the unittest, i want the possibility to debug this wcf service. &lt;br /&gt;
For this, the process has to be attached to the visual studio(2008 in my case) debugger.&lt;br /&gt;
&lt;br /&gt;
You just have to add a reference to EnvDTE, and to add the following pice of code. With that, visual studio attaches the given process to the current debug session.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; EnvDTE.&lt;span style=&quot;color: #0000FF;&quot;&gt;DTE&lt;/span&gt; dte2 &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;EnvDTE.&lt;span style=&quot;color: #0000FF;&quot;&gt;DTE&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;System.&lt;span style=&quot;color: #0000FF;&quot;&gt;Runtime&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;InteropServices&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Marshal&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetActiveObject&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;VisualStudio.DTE.9.0&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; EnvDTE.&lt;span style=&quot;color: #0000FF;&quot;&gt;Debugger&lt;/span&gt; debugger &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; dte2.&lt;span style=&quot;color: #0000FF;&quot;&gt;Debugger&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Process program &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; debugger.&lt;span style=&quot;color: #0000FF;&quot;&gt;LocalProcesses&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;program.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Contains&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;MyApp.exe&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; program.&lt;span style=&quot;color: #0000FF;&quot;&gt;Attach&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s handy, its easy and there is not a lot of documentation about it... &lt;br /&gt;
There are a lot of other EnvDTE(80/90) assemblys, and i guess they are for specific visual studio versions. But i don&#039;t see the benefit in using them.  
    </content:encoded>

    <pubDate>Tue, 23 Feb 2010 10:18:06 +0100</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/188-guid.html</guid>
    <category>.net</category>
<category>Visual Studio</category>

</item>
<item>
    <title>Transfer and bind a image as byte array to a silverlight application</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/185-Transfer-and-bind-a-image-as-byte-array-to-a-silverlight-application.html</link>
            <category>Silverlight</category>
            <category>WCF</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/185-Transfer-and-bind-a-image-as-byte-array-to-a-silverlight-application.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=185</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=185</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    This sample shows how to bind a image to a silverlight application when the image is transfered within a wcf service as a byte array. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;1. Create a new silverlight project&lt;/h2&gt;&lt;br /&gt;
Create a new Silverlight prjeject, and choose &lt;strong&gt;Hoste the silverligth application in a new website.&lt;/strong&gt;&lt;br /&gt;
Then add a &lt;strong&gt;Silverlight-enabled WCF Service&lt;/strong&gt; to the web project.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;2. Create the service&lt;/h2&gt;&lt;br /&gt;
In the service class there is an operation contract which returns an object with two properties. Since i&#039;m quite lazy, the DataContract class is defined in the same file.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; SLBindBinaryImage.&lt;span style=&quot;color: #0000FF;&quot;&gt;Web&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;ServiceContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Namespace&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;AspNetCompatibilityRequirements&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;RequirementsMode &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; AspNetCompatibilityRequirementsMode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Allowed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Service1&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; ImageClass GetImage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; FileStream fs &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; File.&lt;span style=&quot;color: #0000FF;&quot;&gt;OpenRead&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;@&amp;quot;c:\project\Kaderli\Silverlight\SLBindBinaryImage\SLBindBinaryImage.Web\img.jpg&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; data &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;fs.&lt;span style=&quot;color: #0000FF;&quot;&gt;Length&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; fs.&lt;span style=&quot;color: #0000FF;&quot;&gt;Read&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;data, &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;, data.&lt;span style=&quot;color: #0000FF;&quot;&gt;Length&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ImageClass ic &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ImageClass &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; FileName &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;img.jpg&amp;quot;&lt;/span&gt;, ImageFile &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; data &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; ic&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; ImageClass&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; FileName &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; ImageFile &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;3. Bind the image within the SL application&lt;/h2&gt;&lt;br /&gt;
I just add one Image and one TextBox control to the xaml. The importent thing is to add a Resource to to the grid which is responsible for converting my byte array intot the image.&lt;br /&gt;
&lt;div class=&quot;xml geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;UserControl&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SLBindBinaryImage.MainPage&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:d&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/expression/blend/2008&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:mc&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:local&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;clr-namespace:SLBindBinaryImage&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;mc:Ignorable&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;d&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;600&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;d:DesignHeight&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;480&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Grid&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Grid&lt;/span&gt;.Resources&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;local:BinaryArrayToURIConverter&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066;&quot;&gt;x:Key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;binaryArrayToURIConverter&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Grid&lt;/span&gt;.Resources&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;StackPanel&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnLoadImage&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Get image&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Click&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnLoadImage_Click&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Button&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;txtImageName&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Text&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding FileName, Mode=OneWay}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/TextBlock&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Image&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;img&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Height&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;300&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Source&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding ImageFile,Converter={StaticResource binaryArrayToURIConverter}}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Image&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/StackPanel&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Grid&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/UserControl&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;  &lt;br /&gt;
&lt;br /&gt;
In this sample i only implemented the &lt;strong&gt;Convert&lt;/strong&gt; method. Now if the binding of the Image takes place, this Convert methode is called, and the BitmapImage is bound to the control.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Globalization&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.IO&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Windows.Data&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Windows.Media.Imaging&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; SLBindBinaryImage&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; BinaryArrayToURIConverter &lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; IValueConverter&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; Convert&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; value, Type targetType, &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; parameter, CultureInfo culture&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; MemoryStream ms &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; MemoryStream&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;value&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; BitmapImage image &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; BitmapImage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; image.&lt;span style=&quot;color: #0000FF;&quot;&gt;SetSource&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ms&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; image&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; ConvertBack&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; value, Type targetType, &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; parameter, CultureInfo culture&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;throw&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; NotImplementedException&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;4. Links and download&lt;/h2&gt;&lt;br /&gt;
&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N1bnRzdS5jaC9zZXJlbmRpcGl0eS91cGxvYWRzL1NMQmluZEJpbmFyeUltYWdlLnppcA==&amp;amp;entry_id=185&quot; title=&quot;http://suntsu.ch/serendipity/uploads/SLBindBinaryImage.zip&quot;  onmouseover=&quot;window.status=&#039;http://suntsu.ch/serendipity/uploads/SLBindBinaryImage.zip&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;solution to download(Silverlight 3)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot; http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx&quot;&gt;IValueConverter&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L21zNzUwOTUwLmFzcHg=&amp;amp;entry_id=185&quot; title=&quot;http://msdn.microsoft.com/en-us/library/ms750950.aspx&quot;  onmouseover=&quot;window.status=&#039;http://msdn.microsoft.com/en-us/library/ms750950.aspx&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;StaticResource&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Wed, 26 Aug 2009 15:10:28 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/185-guid.html</guid>
    <category>silverlight</category>

</item>
<item>
    <title>Using a Businessobject in Silverlight from client and server</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/184-Using-a-Businessobject-in-Silverlight-from-client-and-server.html</link>
            <category>Silverlight</category>
            <category>WCF</category>
            <category>work</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/184-Using-a-Businessobject-in-Silverlight-from-client-and-server.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=184</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=184</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    Following situation:&lt;br /&gt;
I have a BusinessObject called Person which i want to use in a Silverlight project. This Buisnessobject should be returned from a WCF service and should have some functionality on it. Now, if i define this object on the WCF service, i can use it only as &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9EYXRhX3RyYW5zZmVyX29iamVjdA==&amp;amp;entry_id=184&quot; title=&quot;http://en.wikipedia.org/wiki/Data_transfer_object&quot;  onmouseover=&quot;window.status=&#039;http://en.wikipedia.org/wiki/Data_transfer_object&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;DTO&lt;/a&gt;, but i cannot add additional functionality on it(Or at least i am unable to use it in a silverlight application).&lt;br /&gt;
&lt;br /&gt;
Now, i&#039;m showing a way how you can get all this requirements done.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;h2&gt;1. Create a new silverlight project&lt;/h2&gt;&lt;br /&gt;
Just create a Silverlight 3.0 project.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO1.PNG&#039;&gt;&lt;!-- s9ymdb:82 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;180&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO1.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Im using the visual studio built in webserver for providing the xap file as well as for the WCF service.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO2.PNG&#039;&gt;&lt;!-- s9ymdb:79 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;180&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO2.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;2. Create the business object and the wcf service&lt;/h2&gt;&lt;br /&gt;
Now, just add a &lt;strong&gt;Silverlight enabled webservice&lt;/strong&gt; to the web project. &lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO3.PNG&#039;&gt;&lt;!-- s9ymdb:86 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;180&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO3.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
In this newly added service1.cs, i add a new method GetPerson and a new class Person which will be my Businessobject/Datatransverobject for this sample. I have put the Person class into the same file.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;ServiceContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;Namespace&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;AspNetCompatibilityRequirements&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;RequirementsMode &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; AspNetCompatibilityRequirementsMode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Allowed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Service1&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; Person GetPerson&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Person&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;FirstName &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;manuel&amp;quot;&lt;/span&gt;, LastName &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;kaderli&amp;quot;&lt;/span&gt;, Salutation &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Dear Mr. &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Person&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; FirstName &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; LastName &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Salutation&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
This service is ready to use, and i now add a service reference on the silverlight project.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO4.PNG&#039;&gt;&lt;!-- s9ymdb:87 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;242&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO4.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;3. Use the service from silverlight&lt;/h2&gt;&lt;br /&gt;
On the xaml page, i add a button and some TextBlocks. I&#039;m using the Binding mechanism for get/set data to the controls.&lt;br /&gt;
&lt;div class=&quot;xml geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;UserControl&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SilverlightBusinessObject.MainPage&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;xmlns:d&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.microsoft.com/expression/blend/2008&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;xmlns:mc&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;mc:Ignorable&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;d&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;d:DesignWidth&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;640&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;d:DesignHeight&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;480&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;640&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Grid&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;LayoutRoot&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;StackPanel&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnGetPerson&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Content&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;GetPerson&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Click&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnGetPerson_Click&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Button&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;txtFirstName&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Text&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding FirstName, Mode=TwoWay}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/TextBlock&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;txtLastName&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Text&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding LastName, Mode=TwoWay}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/TextBlock&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;txtSalutation&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Text&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding Salutation, Mode=TwoWay}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/TextBlock&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/StackPanel&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/Grid&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/UserControl&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The csharp file does only call the service, and bind the person object to the LayoutRoot.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;partial&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; MainPage &lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; UserControl&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; MainPage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; InitializeComponent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; btnGetPerson_Click&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, RoutedEventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Service1Client sc &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Service1Client&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sc.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetPersonCompleted&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; EventHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;GetPersonCompletedEventArgs&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;sc_GetPersonCompleted&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sc.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetPersonAsync&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; sc_GetPersonCompleted&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, GetPersonCompletedEventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Person person &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Result&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; LayoutRoot.&lt;span style=&quot;color: #0000FF;&quot;&gt;DataContext&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; person&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When i now run this application, and after pressing the button it shows me the values of the three properties which are bound to the xaml.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO5.PNG&#039;&gt;&lt;!-- s9ymdb:88 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;101&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO5.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;4. Addin functionality to the person BusinessObject&lt;/h2&gt;&lt;br /&gt;
I want to add a new control to the page, which should display the full letter salutation, in my sample this would be &quot;Dear Mr. Kaderli Manuel&quot;. Of course i could do this right on the silverlight page. But this functionality belongs to the BusinessObject. Since the person object is sent via wcf, there is no possibility of code sharing. And i don&#039;t want to edit any generated proxy files.&lt;br /&gt;
What i now want to is to share the person BusinessObject between the web/wcf server and the silverlight application. But because they don&#039;t use the same .net framework(web/wcf uses .net 3.5 and the silverlight application obviously the silverlight framework) which are incompatible.&lt;br /&gt;
&lt;br /&gt;
First i add a new project of type &lt;strong&gt;Silverlight Class Library&lt;/strong&gt; to my solution.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO6.PNG&#039;&gt;&lt;!-- s9ymdb:89 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;190&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO6.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
Then i move the Person class which is in the .svc service file into a seperate class in the newly created class library project. Now i can add the method GetLetterSalutatioin to this class.&lt;br /&gt;
Make sure to include &lt;strong&gt;System.Runtime.Serialization&lt;/strong&gt; with the using statement.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Runtime.Serialization&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; BusinessDTO&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; Person&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; FirstName &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; LastName &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;DataMember&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; Salutation &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; get&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; set&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; LetterSalutation&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; get&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Format&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;{0} {1} {2}&amp;quot;&lt;/span&gt;, Salutation, LastName, FirstName&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; DoSomethiing&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//add any other businesslogic here&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;  &lt;br /&gt;
&lt;br /&gt;
Since i have remove this code from the web/wcf project there are now some errors, because tihs class is missing. I just add this Person class as link.&lt;br /&gt;
Just select &lt;strong&gt;add existing item&lt;/strong&gt;, select the Person class from the silverlight class library project, and make sure to use &lt;strong&gt;add as link&lt;/strong&gt;.&lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_184]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/20090821_SLBO7.PNG&#039;&gt;&lt;!-- s9ymdb:90 --&gt;&lt;img class=&quot;serendipity_image_center&quot; width=&quot;300&quot; height=&quot;202&quot; style=&quot;border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/20090821_SLBO7.serendipityThumb.PNG&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the .svc file, i just have to add the new namespace:&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;BusinessDTO&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;  &lt;br /&gt;
&lt;br /&gt;
In the silverlight project, it&#039;s even easier. Just add the BusinessObject project as a project reference. &lt;br /&gt;
&lt;strong&gt;Make sure to renew the service reverence on the silverlight application&lt;/strong&gt;, in order to get the latest proxy. I had first to delete the existing service reference, and the to add it again to get it working.&lt;br /&gt;
&lt;br /&gt;
Now, i&#039;m able to write the following in the silverlight client:&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; BusinessDTO.&lt;span style=&quot;color: #0000FF;&quot;&gt;Person&lt;/span&gt; person &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Result&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; letterSalutatioin &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; person.&lt;span style=&quot;color: #0000FF;&quot;&gt;LetterSalutation&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; person.&lt;span style=&quot;color: #0000FF;&quot;&gt;DoSomethiing&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;  &lt;br /&gt;
Now i have clientside a object wihch comes from a wcf service but which also can have business functionality.&lt;br /&gt;
It is also possible to use the new property LetterSalutation as source for a control.&lt;br /&gt;
&lt;div class=&quot;xml geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x:Name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;txtLetterSalutation&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;Text&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;{Binding LetterSalutation, Mode=OneWay}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/TextBlock&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;5. Use specific functionality client or serverside&lt;/h2&gt;&lt;br /&gt;
Because i use the code from a silverlight class library now in a silverlight project as well as in a .net 3.5 project, there may be some problems.&lt;br /&gt;
E.g. some functionality like ObservableCollection are not in the same assmbly in the .net 3.5 framework and in the silverlight framework. Then you might have situations where you like to have code for either client or serverside.&lt;br /&gt;
For this you can use &lt;strong&gt;#if SILVERLIGHT&lt;/strong&gt; statement in the BusinessObjects classes.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&amp;#160; &lt;br /&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#if SILVERLIGHT&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//code available only for silverlight applicatioins&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#else&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//code available for web/wcf service&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #008080;&quot;&gt;#endif&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You can get the whole solution &lt;a href=&quot;uploads/SilverlightBusinessObject.zip&quot;&gt;right here.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now, this is the way i&#039;m working with BusinessObjects and silverlight/wcf. If one has a remark, or an other solution, please leave a commen.&lt;br /&gt;
&lt;br /&gt;
cheers 
    </content:encoded>

    <pubDate>Fri, 21 Aug 2009 16:03:51 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/184-guid.html</guid>
    <category>silverlight</category>
<category>wcf</category>

</item>
<item>
    <title>Silverlight/WCF starter solution (not for dummies)</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/166-SilverlightWCF-starter-solution-not-for-dummies.html</link>
            <category>Silverlight</category>
            <category>WCF</category>
            <category>work</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/166-SilverlightWCF-starter-solution-not-for-dummies.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=166</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=166</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    It took me several days to create a proper solution fundament for silverlight, so i decided to publish my starter solution. Maybe it helps some of you.&lt;br /&gt;
There is a solution available for download for each of the four parts.&lt;br /&gt;
&lt;br /&gt;
I had the following requirements:&lt;br /&gt;
&lt;br /&gt;
&lt;ul class=&quot;bb-list-ordered bb-list-ordered-d&quot;&gt;&lt;li class=&quot;bb-listitem&quot;&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;Session management.&lt;/span&gt;&lt;br /&gt;
In the second web service call, i want to know something from the first call&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;li class=&quot;bb-listitem&quot;&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;Impersonate user&lt;/span&gt;&lt;br /&gt;
I don&#039;t want to enter my credentials if my service has to work as my user.&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;li class=&quot;bb-listitem&quot;&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;Error handling&lt;/span&gt;&lt;br /&gt;
It&#039;s not very cool to get a white website after an error occurs.&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;li class=&quot;bb-listitem&quot;&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;Unit tests of the wcf service&lt;/span&gt;&lt;br /&gt;
It would be great to have tests for the stuff above&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start. I&#039;m going to implement each of this topic separately, and hopefully get a solution working till this blog entry is finish.&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Initialize solution&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I just start with a new Silverlight solution in visual studio 2008. The only thing i change from original, is to assign a static port to the built in web server. This makes the life with wcf much easier.&lt;br /&gt;
&lt;br /&gt;
Then add a new Silverlight-enabled WCF Service to the web project, create some operation contract, and add a service reference to the silverlight project.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;1. Session management (with aspNetCompatibilityEnabled)&lt;/h2&gt;&lt;br /&gt;
For this, there are two possibilities:&lt;br /&gt;
&lt;br /&gt;
   1. Do it yourself (Write something like a session agent service)&lt;br /&gt;
   2. Use the ASP session management&lt;br /&gt;
&lt;br /&gt;
I guess there are lots of reasons not to use aspNetCompatibility (The most obvious might be performance), but the simplicity of it was the reason for me to choose it anyway. I have to say that i did not invent this, i just copied it from an article of  SpoonStomper from the silverlight forum.&lt;br /&gt;
&lt;br /&gt;
The following goal i want to achieve. I press a button on my silverlight application which sends a string to my service. Then i want to press another button and get back this string again(Sounds really easy btw.).&lt;br /&gt;
&lt;br /&gt;
To enable the asp session management you first have to edit the web.config&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;xml geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;serviceHostingEnvironment&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;aspNetCompatibilityEnabled&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;//this should be default since silverlight 3&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
On your service class, you have to change the RequirementsMode from Allowed to Required&lt;br /&gt;
&lt;br /&gt;
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]&lt;br /&gt;
public class MyCoolService{.&lt;br /&gt;
&lt;br /&gt;
With this modification, you&#039;re ready to go. Now you can use the HttpContext.Current.Session for handling session stuff.&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ServiceCallOne&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; message&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; HttpContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Session&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; message&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; ServiceCallTwo&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;HttpContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Session&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
You can download the solution with activated asp session management &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5zdW50c3UuY2gvc2VyZW5kaXBpdHkvdXBsb2Fkcy9TZXNzaW9uTWFuYWdlbWVudC56aXA=&amp;amp;entry_id=166&quot;  onmouseover=&quot;window.status=&#039;http://www.suntsu.ch/serendipity/uploads/SessionManagement.zip&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;download session management sample&quot;&gt;from here&lt;/a&gt;&lt;br /&gt;
Make sure to use my .suo file, since the service settings are stored in this file.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Impersonate user&lt;/h2&gt;&lt;br /&gt;
The user impersonation is build on top of the previous topic. Since we are asp.net controlled, we can use the HttpContext to impersonate.&lt;br /&gt;
&lt;br /&gt;
Here you can find the description from microsoft&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; WhoAmIAfterImpersonate&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;WindowsIdentity&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;HttpContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;User&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Identity&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Impersonate&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; HttpContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;User&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Identity&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
After the Impersonate, the service stuff will be executed as the user who has called it.&lt;br /&gt;
&lt;br /&gt;
Btw. as far as i understand, this requires ntlm authentication. To get this in firefox without being asked for username and password, have a look here&lt;br /&gt;
&lt;br /&gt;
You can download the solution with Impersonate &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5zdW50c3UuY2gvc2VyZW5kaXBpdHkvdXBsb2Fkcy9JbXBlcnNvbmF0ZS56aXA=&amp;amp;entry_id=166&quot;  onmouseover=&quot;window.status=&#039;http://www.suntsu.ch/serendipity/uploads/Impersonate.zip&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;download impersonate sample&quot;&gt;from here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Error handling&lt;/h2&gt;&lt;br /&gt;
Since it is not possible to catch regular exception from a wcf service in a silverlight application, there is another way to do it.&lt;br /&gt;
&lt;br /&gt;
I just explain it in a short story, and give the example. You may find the whole story from microsoft here.&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;First: Create a FaultBehavior class in your web project:&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Collections.Generic&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Linq&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.ServiceModel&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.ServiceModel.Channels&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.ServiceModel.Configuration&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.ServiceModel.Description&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.ServiceModel.Dispatcher&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;System.Web&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;namespace&lt;/span&gt; SilverlightWCF.&lt;span style=&quot;color: #0000FF;&quot;&gt;Web&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; MyFaultBehavior &lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; BehaviorExtensionElement, IEndpointBehavior&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ApplyDispatchBehavior&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; SilverlightFaultMessageInspector inspector &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; SilverlightFaultMessageInspector&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; endpointDispatcher.&lt;span style=&quot;color: #0000FF;&quot;&gt;DispatchRuntime&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;MessageInspectors&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;inspector&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; SilverlightFaultMessageInspector &lt;span style=&quot;color: #008000;&quot;&gt;:&lt;/span&gt; IDispatchMessageInspector&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; BeforeSendReply&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ref&lt;/span&gt; Message reply, &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; correlationState&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;reply.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsFault&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; HttpResponseMessageProperty property &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; HttpResponseMessageProperty&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Here the response code is changed to 200.&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; property.&lt;span style=&quot;color: #0000FF;&quot;&gt;StatusCode&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System.&lt;span style=&quot;color: #0000FF;&quot;&gt;Net&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;HttpStatusCode&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;OK&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; reply.&lt;span style=&quot;color: #0000FF;&quot;&gt;Properties&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;HttpResponseMessageProperty.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; property&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; AfterReceiveRequest&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;ref&lt;/span&gt; Message request, IClientChannel channel, InstanceContext instanceContext&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Do nothing to the incoming message.&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; null&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// The following methods are stubs and not relevant.&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; AddBindingParameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ServiceEndpoint endpoint, BindingParameterCollection bindingParameters&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ApplyClientBehavior&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ServiceEndpoint endpoint, ClientRuntime clientRuntime&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Validate&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ServiceEndpoint endpoint&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Type&lt;/span&gt; BehaviorType&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; get &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=typeof+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;typeof&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;MyFaultBehavior&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; CreateBehavior&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;return&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; MyFaultBehavior&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Second: Edit the web.config&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;xml geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;system&lt;/span&gt;.serviceModel&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--Add a behavior extension within the service model--&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;extensions&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;behaviorExtensions&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;myFault&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SilverlightWCF.Web.MyFaultBehavior, SilverlightWCF.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/behaviorExtensions&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/extensions&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;behaviors&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--Add a endpointBehavior below the behaviors--&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;endpointBehaviors&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;behavior&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;myFaultBehavior&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;myFault&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/behavior&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/endpointBehaviors&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--Set the behaviorConfiguration of the endpoint--&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;endpoint&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;address&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;binding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;customBinding&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;bindingConfiguration&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;customBinding0&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;contract&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;SilverlightWCF.Web.MyCoolService&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;behaviorConfiguration&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;myFaultBehavior&amp;quot;&lt;/span&gt; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!--For debugging, it might be cool to have some more error information.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt; &amp;#160;to get this, set includeExceptionDetailInFaults to true--&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;serviceDebug&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;includeExceptionDetailInFaults&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Third: Create an operation contract which throws an exception.&lt;/span&gt;&lt;br /&gt;
Make sure not to throw regular exception, but FaultException&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;OperationContract&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ThrowException&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;throw&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; FaultException&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;this is my Exception&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Fourth: Handle the error within your silverlilght application&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; btnThrowException_Click&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, RoutedEventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;ThrowExceptionCompleted&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;+=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; EventHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;System.&lt;span style=&quot;color: #0000FF;&quot;&gt;ComponentModel&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsyncCompletedEventArgs&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;serviceClient_ThrowExceptionCompleted&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;ThrowExceptionAsync&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; serviceClient_ThrowExceptionCompleted&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #000000;&quot;&gt;System.&lt;span style=&quot;color: #0000FF;&quot;&gt;ComponentModel&lt;/span&gt;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;AsyncCompletedEventArgs&lt;/span&gt; e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Error&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// In case of success&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #0600FF;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Error&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=is+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;is&lt;/span&gt;&lt;/a&gt; FaultException&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; FaultException fault &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Error&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;as&lt;/span&gt; FaultException&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; txtThrowException.&lt;span style=&quot;color: #0000FF;&quot;&gt;Text&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &amp;#160;e.&lt;span style=&quot;color: #0000FF;&quot;&gt;Error&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Message&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
You can download the solution with error handling &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5zdW50c3UuY2gvc2VyZW5kaXBpdHkvdXBsb2Fkcy9FeGNlcHRpb24uemlw&amp;amp;entry_id=166&quot;  onmouseover=&quot;window.status=&#039;http://www.suntsu.ch/serendipity/uploads/Exception.zip&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;download exception sample here&quot;&gt;from here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Unit test the the wcf service (using sessions)&lt;/h2&gt;&lt;br /&gt;
&lt;br /&gt;
Here i have to say, to unit test a single wcf method is not that difficult(its like if you unit test a library).&lt;br /&gt;
&lt;br /&gt;
But if you use the asp.net session to store information, the client(browser) handles this with cookies. If you want to unit test a method which needs a value from the session, you have to handle the cookies manually. Here you can find a very good explanation for handling cookies in asmx/wcf services.&lt;br /&gt;
&lt;br /&gt;
First you have to create a unit test project. I had to do this by hand, since create unit test on a method did not create a new project.&lt;br /&gt;
&lt;br /&gt;
Then use Add service reference to add a reference of the web/wcf project to your unit test project.&lt;br /&gt;
&lt;br /&gt;
Now implement the test methode:&lt;br /&gt;
&lt;div class=&quot;csharp geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;TestMethod&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; TestMethod1&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; _sharedCookie &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Empty&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//Creates connection to the WCF service&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//It&#039;s done by code, not via config file&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//The config file would be overwritten all the time&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;EndpointAddress objEndpoint &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; null&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;CustomBinding cb &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; CustomBinding&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//binding depends how your web server is set up&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;BinaryMessageEncodingBindingElement bmebe &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; BinaryMessageEncodingBindingElement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//TextMessageEncodingBindingElement tebe = new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8);&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;HttpTransportBindingElement htbe &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; HttpTransportBindingElement&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;cb.&lt;span style=&quot;color: #0000FF;&quot;&gt;Elements&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;bmebe&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;cb.&lt;span style=&quot;color: #0000FF;&quot;&gt;Elements&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;htbe&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;objEndpoint &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; EndpointAddress&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;http://localhost:11111/MyCoolService.svc&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;MyCoolServiceClient _serviceClient &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; MyCoolServiceClient&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;cb, objEndpoint&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//howto manage cookies: http://megakemp.wordpress.com/2009/02/06/managing-shared-cookies-in-wcf/&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; OperationContextScope&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;_serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;InnerChannel&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;_serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;ServiceCallOne&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;my first message to the server&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// Extract the cookie embedded in the received web service response&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// and stores it locally&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;HttpResponseMessageProperty response &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;HttpResponseMessageProperty&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;OperationContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;IncomingMessageProperties&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;HttpResponseMessageProperty.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;_sharedCookie &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; response.&lt;span style=&quot;color: #0000FF;&quot;&gt;Headers&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Set-Cookie&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; OperationContextScope&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;_serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;InnerChannel&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//this sets the cookie for the next service request&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;HttpRequestMessageProperty request &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; HttpRequestMessageProperty&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;request.&lt;span style=&quot;color: #0000FF;&quot;&gt;Headers&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Cookie&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; _sharedCookie&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;OperationContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;OutgoingMessageProperties&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;HttpRequestMessageProperty.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; request&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; returnValue &lt;span style=&quot;color: #008000;&quot;&gt;=&lt;/span&gt; _serviceClient.&lt;span style=&quot;color: #0000FF;&quot;&gt;ServiceCallTwo&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;Assert.&lt;span style=&quot;color: #0000FF;&quot;&gt;AreEqual&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;my first message to the server&amp;quot;&lt;/span&gt;, returnValue&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
As you can see, i call two method separately, and i return with the second method the session value which was set in the first method call.&lt;br /&gt;
You can download the solution with error handling &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5zdW50c3UuY2gvc2VyZW5kaXBpdHkvdXBsb2Fkcy9Vbml0VGVzdC56aXA=&amp;amp;entry_id=166&quot;  onmouseover=&quot;window.status=&#039;http://www.suntsu.ch/serendipity/uploads/UnitTest.zip&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;download unit test project here&quot;&gt;from here.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&#039;s9y_typeset s9y_typeset_strike&#039; style=&#039;text-decoration: line-through&#039;&gt;&lt;/div&gt;&lt;br /&gt;
Please let me know when you find mistakes/bugs in this sample.&lt;br /&gt;
&lt;br /&gt;
cheers&lt;br /&gt;
manuel  
    </content:encoded>

    <pubDate>Wed, 22 Jul 2009 23:11:26 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/166-guid.html</guid>
    <category>Silverlight</category>
<category>WCF</category>

</item>
<item>
    <title>Use WCF service from a Silverlight application</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/158-Use-WCF-service-from-a-Silverlight-application.html</link>
            <category>Silverlight</category>
            <category>WCF</category>
            <category>work</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/158-Use-WCF-service-from-a-Silverlight-application.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=158</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=158</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    At &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5ldmlkZW5jZS5ldQ==&amp;amp;entry_id=158&quot;  onmouseover=&quot;window.status=&#039;http://www.evidence.eu&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;work&quot;&gt;work&lt;/a&gt;, i&#039;m involved in a silverlight application, and i&#039;ve got my first challange.&lt;br /&gt;
It&#039;s not that easy to use an WCF service which is not hosted in an IIS environment right from an Silverlight application.&lt;br /&gt;
With the help of the official &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3NpbHZlcmxpZ2h0Lm5ldC9mb3J1bXMvcC8yMTY3OC83NzUxNC5hc3B4&amp;amp;entry_id=158&quot;  onmouseover=&quot;window.status=&#039;http://silverlight.net/forums/p/21678/77514.aspx&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot; title=&quot;Silverlight forum&quot;&gt;Silverlight forum&lt;/a&gt;, i figured it out.&lt;br /&gt;
You may download an test this sample visual studio solution. Of course you have to set up the proper environment for developing Silverlight application first.&lt;br /&gt;
The solution contains the following project:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;SilverLightTestAppWeb (Startup website for the silverlight application)&lt;br /&gt;
&lt;li&gt;SilverLightTestApp.csproj (Silverlight application)&lt;br /&gt;
&lt;li&gt;WCF.csproj (WCF service for providing data)&lt;br /&gt;
&lt;li&gt;WCFServer.csproj (Console application for hosting WCFServer.csproj)&lt;br /&gt;
&lt;li&gt;WCFPolicy.csproj (WCF/REST service for providing clientaccesspolicy.xml)&lt;br /&gt;
&lt;li&gt;WCFPolicyServer.csproj (Console application for hosting WCFPolicy.csproj)&lt;br /&gt;
&lt;li&gt;WCFTestApp.csproj (Test application for WCFServer.csproj)&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
To test it, the following projects must be started: WCFServer, WCFPolicyServer, SilverLightTestAppWeb.&lt;br /&gt;
With this you are ready to go. If you then see the silverlight application, and press the button, it will first call the WCFServer, and then request the WCFPolicyServer for receive the clientaccesspolicy.xml. The policy is only checked once at the first webservice call.&lt;br /&gt;
For testing it, you may download it from here &lt;a href=&quot;http://suntsu.ch/serendipity/uploads/WCF.rar&quot; title=&quot;WCF.rar&quot; target=&quot;_blank&quot;&gt;WCF.rar&lt;/a&gt;. &lt;br /&gt;
Just make sure to set the proper startup projects: &lt;br /&gt;
&lt;a  class=&#039;serendipity_image_link&#039;  rel=&#039;gb_imageset[greybox_group_entry_158]&#039; href=&#039;http://suntsu.ch/serendipity/uploads/WCFSilverlightStartup.png&#039;&gt;&lt;!-- s9ymdb:77 --&gt;&lt;img class=&quot;serendipity_image_left&quot; width=&quot;110&quot; height=&quot;69&quot; style=&quot;float: left; border: 0px; padding-left: 5px; padding-right: 5px;&quot; src=&quot;http://suntsu.ch/serendipity/uploads/WCFSilverlightStartup.serendipityThumb.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
cheers&lt;br /&gt;
manuel&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 05 Aug 2008 14:01:11 +0200</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/158-guid.html</guid>
    <category>Silverlight</category>
<category>WCF</category>

</item>
<item>
    <title>SVN Mirror unter Windows einrichten</title>
    <link>http://suntsu.ch/serendipity/index.php?/archives/146-SVN-Mirror-unter-Windows-einrichten.html</link>
            <category>SVN</category>
            <category>work</category>
    
    <comments>http://suntsu.ch/serendipity/index.php?/archives/146-SVN-Mirror-unter-Windows-einrichten.html#comments</comments>
    <wfw:comment>http://suntsu.ch/serendipity/wfwcomment.php?cid=146</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://suntsu.ch/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=146</wfw:commentRss>
    

    <author>nospam@example.com (suntsu)</author>
    <content:encoded>
    Howdi &lt;br /&gt;
&lt;br /&gt;
Ich durfte auf der Arbeit ein SVN Server/Mirror aufsetzen.&lt;br /&gt;
Da ich alles schnell wieder vergesse schreibe ich das mal hier nieder...&lt;br /&gt;
Das ganze ist zwar im &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3N2bmJvb2sucmVkLWJlYW4uY29tL2VuLzEuNC9zdm4tYm9vay5odG1sI3N2bi5yZXBvc2FkbWluLm1haW50LnJlcGxpY2F0aW9u&amp;amp;entry_id=146&quot; title=&quot;http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.reposadmin.maint.replication&quot;  onmouseover=&quot;window.status=&#039;http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.reposadmin.maint.replication&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;SVN RedBook&lt;/a&gt; ziemlich gut beschrieben, allerdings nicht fuer Windows&lt;br /&gt;
&lt;br /&gt;
1. Repository erstellen:&lt;br /&gt;
Als erstes muss das Repository erstellt werden&lt;br /&gt;
 &lt;strong&gt;svnadmin create C:\svnrepository\RepositoryName&lt;/strong&gt;&lt;br /&gt;
2. Berechtigung vergeben&lt;br /&gt;
Es muss ein User vorhanden sein mit dem die Synchronisation durchgefuehrt wird. Dieser User darf sonst nicht verwendet werden.&lt;br /&gt;
3. Hooks registrieren(kopieren)(Sind unter Erweitert vorhanden):&lt;br /&gt;
Es braucht zwei hooks. 1. &lt;strong&gt;start-commit&lt;/strong&gt;, 2. &lt;strong&gt;pre-revprop-change&lt;/strong&gt; damit nur noch von einem User(Mirror-User) aenderungen am Repository vorgenommen werden koennen.&lt;br /&gt;
4. Mirror initialisieren&lt;br /&gt;
&lt;strong&gt;&quot;C:\Program Files\Subversion\bin\svnsync.exe&quot; initialize http://mirror host/MirrorRepository http://master host/MasterRepository --username user --password password&lt;/strong&gt;&lt;br /&gt;
5. Synchronisation starten&lt;br /&gt;
Mit folgender Zeile wird die Synchronisation gestartet. Dies kann man auch auf dem MasterRepository als &lt;strong&gt;post-commit&lt;/strong&gt; hook einrichten, damit jede aenderung sofort auf das MirrorRepository uebertragen wird. &lt;br /&gt;
&lt;strong&gt;svnsync synchronize http://mirror host/MirrorRepository --username user --password password&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Will man auf sourcen des MirrorRepositorys aenderungen mittels &lt;strong&gt;svn switch --relocate&lt;/strong&gt; auf das MasterRepository commiten, muss man dafuer die &lt;strong&gt;UUID&lt;/strong&gt; des MirrorRepository gleich der UUID des MasterRepository setzen. &lt;br /&gt;
Dafuer muss man sich zuerst eine Textdatei uuid.txt anlegen, und folgenden Text reinschreiben:&lt;br /&gt;
&lt;strong&gt;SVN-fs-dump-format-version: 2&lt;br /&gt;
UUID: 65390229-12b7-0310-b90b-f21a5aa7ec8e&lt;br /&gt;
&lt;/strong&gt;&lt;br /&gt;
UUID natuerlich mit der UUID des MasterRepositoy ersetzen, und am Ende des files eine Leerzeile lassen(wieso auch immer)&lt;br /&gt;
Danach kann man via cmd die UUID des MirrorRepositoy anpassen:&lt;br /&gt;
&lt;strong&gt;type uuid.txt | svnadmin load --force-uuid C:\svnrepository\MirrorRepositoy &lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cheers&lt;br /&gt;
manuel&lt;br /&gt;
&lt;br /&gt;
ps: Mir ist klar das Windos boese ist, aber das habe ich auf der Arbeit nicht zu entscheiden &lt;img src=&quot;http://suntsu.ch/serendipity/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
pps: UUID unter windows aendern ist recht tricky. Unter &lt;a href=&quot;http://suntsu.ch/serendipity/exit.php?url=aHR0cDovL3d3dy5uYWJibGUuY29tL3N2bi1yZWxvY2F0ZS1mYWlscy1kdWUtdG8tYmFkLWNoYXItYXQtZW5kLW9mLXVybF91dWlkLSUzRXV1aWQtdGQxMzcxNjI0My5odG1s&amp;amp;entry_id=146&quot; title=&quot;http://www.nabble.com/svn-relocate-fails-due-to-bad-char-at-end-of-url_uuid-%3Euuid-td13716243.html&quot;  onmouseover=&quot;window.status=&#039;http://www.nabble.com/svn-relocate-fails-due-to-bad-char-at-end-of-url_uuid-%3Euuid-td13716243.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;http://www.nabble.com/svn-relocate-fails-due-to-bad-char-at-end-of-url_uuid-%3Euuid-td13716243.html&lt;/a&gt; ist eine Beschreibung zu finden. &lt;br /&gt;&lt;a href=&quot;http://suntsu.ch/serendipity/index.php?/archives/146-SVN-Mirror-unter-Windows-einrichten.html#extended&quot;&gt;Continue reading &quot;SVN Mirror unter Windows einrichten&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 07 Jan 2008 16:42:51 +0100</pubDate>
    <guid isPermaLink="false">http://suntsu.ch/serendipity/index.php?/archives/146-guid.html</guid>
    <category>SVN</category>

</item>

</channel>
</rss>