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

<channel>
	<title>Dot Net Thoughts &#187; Silverlight</title>
	<atom:link href="http://www.dotnetthoughts.net/category/net/silverlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetthoughts.net</link>
	<description>thoughts about .Net, WPF, Sharepoint, Javascript and more.</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:59:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Deploying WCF Service in IIS : no svc MIME Type</title>
		<link>http://www.dotnetthoughts.net/2010/04/23/deploying-wcf-service-in-iis-no-svc-mime-type/</link>
		<comments>http://www.dotnetthoughts.net/2010/04/23/deploying-wcf-service-in-iis-no-svc-mime-type/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 00:10:15 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[404.3 Error]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=867</guid>
		<description><![CDATA[Few days back I developed a Silverlight application, which uses a WCF Service to communicate to Database. After the development when I tried to deploy the WCF Service on my IIS, it was displaying some error like Server Error in Application &#8220;Default Web Site/SampleApp&#8221; HTTP Error 404.3 &#8211; Not Found Description: The page you are [...]]]></description>
			<content:encoded><![CDATA[<p>Few days back I developed a Silverlight application, which uses a WCF Service to communicate to Database. After the development when I tried to deploy the WCF Service on my IIS, it was displaying some error like</p>
<blockquote><p>Server Error in Application &#8220;Default Web Site/SampleApp&#8221;<br />
HTTP Error 404.3 &#8211; Not Found<br />
Description: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.<br />
Error Code: 0&#215;80070032<br />
Notification: ExecuteRequestHandler<br />
Module: StaticFileModule<br />
Requested URL: http://localhost:80/SampleApp/CoreService.svc<br />
Physical Path: C:\Users\Documents\Visual Studio 2005\Projects\SampleApp\SampleApp\CoreService.svc<br />
Logon User: Anonymous<br />
Logon Method: Anonymous<br />
Handler: StaticFile</p></blockquote>
<p>I tried IIS MimeTypes and I couldn&#8217;t found an application mapping for SVC file. After doing some searching I found the fix. It is happening  because of not registering the WCF in IIS. You can resolve this using WCF Installation utility which comes with .Net Framework 3.0. Run the command prompt as Administrator, go to the Windows Communication Foundation folder in c:\Windows\Microsoft.NET\Framework\v3.0\ folder. Execute the servicemodelreg.exe with -i or /i switch. After the installation try reloading the Page. It will fix this issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/04/23/deploying-wcf-service-in-iis-no-svc-mime-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unable to start debugging. The Silverlight managed debugging package isn&#8217;t installed.</title>
		<link>http://www.dotnetthoughts.net/2010/04/16/unable-to-start-debugging-the-silverlight-managed-debugging-package-isnt-installed/</link>
		<comments>http://www.dotnetthoughts.net/2010/04/16/unable-to-start-debugging-the-silverlight-managed-debugging-package-isnt-installed/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 08:16:49 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight 3]]></category>
		<category><![CDATA[SL4]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=845</guid>
		<description><![CDATA[If you installed latest version of Silverlight (Silverlight 4), it may break the your current silverlight development environment. After in the Silverlight 4 installation, if you try to debug any Silverlight 3 project, you will get a message from Visual Studio 2008, saying &#8220;Unable to start debugging. The Silverlight managed debugging package isn&#8217;t installed.&#8221; To [...]]]></description>
			<content:encoded><![CDATA[<p>If you installed latest version of Silverlight (Silverlight 4), it may break the your current silverlight development environment. After in the Silverlight 4 installation, if you try to debug any Silverlight 3 project, you will get a message from Visual Studio 2008, saying &#8220;Unable to start debugging. The Silverlight managed debugging package isn&#8217;t installed.&#8221;</p>
<div id="attachment_846" class="wp-caption alignnone" style="width: 475px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/04/msdev_error.jpg"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2010/04/msdev_error.jpg" alt="Unable to start debugging. The Silverlight managed debugging package isn&#039;t installed." title="Unable to start debugging. The Silverlight managed debugging package isn&#039;t installed." width="465" height="157" class="size-full wp-image-846" /></a><p class="wp-caption-text">Unable to start debugging. The Silverlight managed debugging package isn't installed.</p></div>
<p>To fix this error, install the Silverlight Developer Run time. You can get it from here : http://go.microsoft.com/fwlink/?LinkID=188039.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/04/16/unable-to-start-debugging-the-silverlight-managed-debugging-package-isnt-installed/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>File Uploader using Silverlight and WCF</title>
		<link>http://www.dotnetthoughts.net/2010/01/06/file-uploader-using-silverlight-and-wcf/</link>
		<comments>http://www.dotnetthoughts.net/2010/01/06/file-uploader-using-silverlight-and-wcf/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 02:38:02 +0000</pubDate>
		<dc:creator>Anuraj P</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.Net 3.0 / 3.5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[FileUpload]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.dotnetthoughts.net/?p=693</guid>
		<description><![CDATA[From Silverlight 2 onwards it supports Open File Dialog, which helps developers to implement upload file logic, with the help of WCF services. Silverlight Open File Dialog offers better control over the existing HTML FileUpload control, like File Filter, File Sizes etc, and it can be managed from client side. Here is a simple implementation [...]]]></description>
			<content:encoded><![CDATA[<p>From Silverlight 2 onwards it supports Open File Dialog, which helps developers to implement upload file logic, with the help of WCF services. Silverlight Open File Dialog offers better control over the existing HTML FileUpload control, like File Filter, File Sizes etc, and it can be managed from client side. Here is a simple implementation of Silverlight uploader with WCF.</p>
<p>Silverlight UI &#8211; XAML</p>
<pre class="brush: xml;">
&lt;Canvas x:Name=&quot;LayoutRoot&quot;&gt;
    &lt;StackPanel Margin=&quot;10&quot; Background=&quot;White&quot; Orientation=&quot;Horizontal&quot;&gt;
        &lt;TextBlock Text=&quot;Select File :&quot; /&gt;
        &lt;TextBox Name=&quot;txtFileName&quot; Width=&quot;200&quot; /&gt;
        &lt;Button Name=&quot;cmdBrowse&quot; Content=&quot;Browse&quot; Click=&quot;cmdBrowse_Click&quot; /&gt;
        &lt;Button Name=&quot;cmdUpload&quot; Content=&quot;Upload&quot; Click=&quot;cmdUpload_Click&quot; /&gt;
    &lt;/StackPanel&gt;
&lt;/Canvas&gt;
</pre>
<p>And the code behind</p>
<pre class="brush: csharp;">
FileInfo fi;
private void cmdBrowse_Click(object sender, RoutedEventArgs e)
{
    //Open File Dialog
    OpenFileDialog dlg = new OpenFileDialog();
    //The _FilterText variable used to control file extentions
    //supported by the Upload control
    dlg.Filter = this._FilterText;
    bool? result = dlg.ShowDialog();
    if (result.HasValue &amp;&amp; result.Value)
    {
        this.fi = dlg.File;
        //The _FileSize variable used to control the
        //Maximum Size supported by the control.
        if (this.fi.Length &gt; this._FileSize)
        {
            //Control will fire a FileSizeError event, if the
            //Uploading File Size greater than the specified.
            if (this._onFileSizeError != null)
            {
                this._onFileSizeError(this, EventArgs.Empty);
            }
            return;
        }
        this.txtFileName.Text = this.fi.Name;
    }
}

private void cmdUpload_Click(object sender, RoutedEventArgs e)
{
    //Uploading part.
    if (this.fi != null)
    {
        byte[] buffer = new byte[this.fi.Length];
        using (Stream s = this.fi.OpenRead())
        {
            //Reading the File Content to the Stream.
            //It is using a WCF Service with Upload File method
            s.Read(buffer, 0, buffer.Length);
            ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
            client.UploadFileCompleted += new EventHandler&lt;System.ComponentModel.AsyncCompletedEventArgs&gt;(client_UploadFileCompleted);
            client.UploadFileAsync(this.fi.Name, buffer);
        }
    }
}

private void client_UploadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
    //Application will raise another Event
    //after the completion of the File Upload.
    if (this._onFileUploadCompleted != null)
    {
        this._onFileUploadCompleted(this, EventArgs.Empty);
    }
}
</pre>
<p>And here is the WCF Service with Upload File method.</p>
<pre class="brush: csharp;">
//IService1 Interface
[ServiceContract]
public interface IService1
{
    [OperationContract]
    void UploadFile(string fileName, byte[] content);
}

//IService1 Interface implementation
public class Service1 : IService1
{
    public void UploadFile(string fileName, byte[] content)
    {
        using (FileStream sw = File.OpenWrite(Path.Combine(@&quot;C:\Uploads&quot;, fileName)))
        {
            sw.Write(content, 0, content.Length);
        }
    }
}
</pre>
<p>To enable communication between Silverlight and Javascript the &#8220;System.Windows.Browser&#8221; namespace is used. Which supports various attributes and methods, will expose the properties and events of the silverlight application to the Javascript. </p>
<pre class="brush: csharp;">
public MainPage()
{
    InitializeComponent();
    //This method enables the scripting support to the Application.
    //From Javascript developer can access the Properties and events
    //like SilverlightObj.Content.Page.Property
    HtmlPage.RegisterScriptableObject(&quot;Page&quot;, this);
}

private string _FilterText = &quot;Text Files|*.txt&quot;;
private int _FileSize = 1000;
private event EventHandler _onFileSizeError;
private event EventHandler _onFileUploadCompleted;

//This attribute used to expose the Property to Client side.
//From Javascript : ctrl.Content.Page.FileSize = 2000;
[ScriptableMember]
public int FileSize
{
    get
    {
        return this._FileSize;
    }
    set
    {
        this._FileSize = value;
    }
}
[ScriptableMember]
public string Filter
{
    get
    {
        return this._FilterText;
    }
    set
    {
        this._FilterText = value;
    }
}

[ScriptableMemberAttribute]
public EventHandler OnFileSizeError
{
    get
    {
        return this._onFileSizeError;
    }
    set
    {
        this._onFileSizeError = value;
    }
}

[ScriptableMemberAttribute]
public EventHandler OnFileUploadCompleted
{
    get
    {
        return this._onFileUploadCompleted;
    }
    set
    {
        this._onFileUploadCompleted = value;
    }
}
</pre>
<p>And in the Javascript, the property can access and can modify it.</p>
<pre class="brush: jscript;">
function onPluginLoaded() {
    var ctrl = document.getElementById(&quot;silverlightControlHost1&quot;);
    ctrl.Content.Page.Filter = &quot;Image Files|*.jpg;*.gif;*.png|All Files(*.*)|*.*&quot;;
    ctrl.Content.Page.FileSize = 20000;
    ctrl.Content.Page.OnFileSizeError = function () {
        alert(&quot;File Size should be less than 2 KB&quot;);
    };
    ctrl.Content.Page.OnFileUploadCompleted = function () {
        alert(&quot;Uploaded successfully !&quot;);
    };
}
</pre>
<p>And the HTML Part &#8211; Here the onLoad parameter will assign the Javascript to execute on loading of the silverlight application.</p>
<pre class="brush: xml;">
&lt;object id=&quot;silverlightControlHost1&quot; data=&quot;data:application/x-silverlight-2,&quot; type=&quot;application/x-silverlight-2&quot;
    width=&quot;100%&quot; height=&quot;100%&quot;&gt;
    &lt;param name=&quot;onLoad&quot; value=&quot;onPluginLoaded&quot; /&gt;
&lt;/object&gt;
</pre>
<p>And here is the screen shot, of the same running on my Windows 7 machine.</p>
<div id="attachment_695" class="wp-caption alignnone" style="width: 310px"><a href="http://www.dotnetthoughts.net/wp-content/uploads/2010/01/application.png"><img src="http://www.dotnetthoughts.net/wp-content/uploads/2010/01/application-300x238.png" alt="Silverlight File Uploader" title="Silverlight File Uploader" class="size-medium wp-image-695" /></a><p class="wp-caption-text">Silverlight File Uploader</p></div>
<p>Please let me know your comments and feedbacks. Happy Programming. <img src='http://www.dotnetthoughts.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetthoughts.net/2010/01/06/file-uploader-using-silverlight-and-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
