How about no more Silverlight 6 ?

I am considering what solution will be a good replacing solution if Microsoft really no more have new Silverlight edition like Silverlight 6, I tried using JavaScript way (or JavaScript library such as jQuery) and found for non-small data realtime data, JavaScript solution is worse than Silverlight solutions.

But, is there really no better solution if we do not use Silverlight? we will not choose flash because if we will not use Silverlight why we should use similar tech solution?

Continue reading “How about no more Silverlight 6 ?”

Silverlight 4 or 5 Application Supports Multiple Languages (Localize)

Silverlight can use resource to support multiple languages. We do not talk about the regular steps which how to use resource files.

Here we have to know there is additional step to do in Silverlight 4 or 5, at least in Visual Studio 2010 (We did not try Visual Studio 2012 and Visual Studio 2013):

Continue reading “Silverlight 4 or 5 Application Supports Multiple Languages (Localize)”

Silverlight Application Compile Failed in Visual Studio 2013

We had an ASP.NET project using Silverlight and WCF which developed in Visual Studio 2010 and Visual Studio 2012, both versions worked without any problems.

From this year we tried migrate the ASP.NET project to Visual Studio 2013 since there are new features we can use in Visual Studio 2013, however, we could not compile the project, the compile errors came from Silverlight sub project, which all were about the service reference did not include methods, which meant the Silverlight application could not load WCF service, even we removed the web service reference and rebuilt still not worked, also, there were other errors message indicated Silverlight application could not find some libraries.

Continue reading “Silverlight Application Compile Failed in Visual Studio 2013”

Summary of Deploy WCF, Silverlight and ASP.NET

We posted 3 guides about Deploy a web application which includes WCF, SilverLight and ASP.NET , for simplified all steps, here provides a “quick guide”:

1: Make sure you have installed IIS successfully, at least you can visit http://localhost and see a default web page;

2: Open IIS Management (7 and above), right mouse click Sites\Default Web Site and choose “Add Virtual Directory”, here we create a virtual directory using a physical Widows path (you can make a new path here such as C:\ConspecWeb without leaving away IIS management tool), and give an alias name such as ConspecWeb;

3: Right mouse click the virtual directory that you just created in step 2, and choose Add Application, here we create a web application, we choose another physical path or create a new path, normally we will create a new sub path under the path that we created in step 2, for example: C:\ConspecWeb\WebTerminal, we give an alias name WebTerminal, and select Application Pool as ASP.NET 4.0;

4: Now copy the Website files (not WCF service files)  to C:\ConspecWeb\WebTerminal folder, and try to visit http:/localhost/ConspecWeb/WebTerminal, you should see the website home page (but just Silverlight page do not work since we have not set WCF yet), if no, then there must be some error places which you have not set correctly;

5: Go to the folder which you put the WCF service files, open the web config file, if your WCF hosted in a Windows application, the config file name should like  xxxx.exe.config; scroll down to Services section, most of content have already set for us, we just need to change the endpoint address to our real address:

— First, we set baseAddress as our WCF service root path, for our case, it is;

— We have an endpoint for Client Access Policy file for the cross domain handling for Silverlight application, the address should be empty, means it uses the base address which we set above;

— We have basicHttpBinding endpoint to provide services to Silverlight clients, the endpoint address we set to “SL/”;

— endpoint for Meta Data Exchange, we set to “SL/mex

so the final endpoint addresses will be set like following:

      <service name="ServiceApp.Services.TerminalService" behaviorConfiguration="TerminalServiceBehavior" >
        <endpoint address="" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="" name="PolicyEndpoint" contract="ServiceApp.Services.IClientAccessPolicy" />
        <endpoint address="SL/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ConspecService" contract="ServiceApp.Services.ITerminalService"   name="TerminalServiceSLEndPoint"/>
        <endpoint address="SL/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="" />


Sometimes when you use “localhost” and use another port number which is not 80, you might use the config similar with the following:

      <service name="CCService.Services.CCServices">
        <endpoint address="http://localhost:8732/" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="" name="PolicyEndpoint" contract="CCService.Services.IClientAccessPolicy" />
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ConspecService" contract="CCService.Services.ICCServices"   name="TerminalServiceSLEndPoint"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="http://localhost:8732/MyServiceAddress/CCServices/" />

after you done above, please try to visit the service URL, you should see the service information, if you can not see, there must be some wrong you have not set correctly yet;

6:  Now set website Silverlight client, the process will be same as the description here; all other left steps also can be found in previous 3 blogs which we have posted.

Silverlight and Socket Samples

We know Silverlight needs a limit range of Port number 4502 ~ 4534, and Port 943 for security policy.

But in Silverlight 4, the security policy file can be downloaded via either TCP port 943 or HTTP (port 80);

so here we found 2 great samples for using port 943 and not using port 943:

1: In this page, check the last 2 links: Pushing Data to a Silverlight Client with Socket I and II, this is for using Port 943;

2: Silverlight 4: Silverlight 4 RC – Socket Security Changes

Silverlight and Socket Links

1: HTTP Communication and Security with Silverlight (including Cross-Domain Communication)

2: How to: Specify Browser or Client HTTP Handling

3: Network Security Access Restrictions in Silverlight

Silverlight supports two types of security policy files:
   — Flash policy file -  crossdomain.xml policy file used by Adobe Flash. 
   — Silverlight policy file -  clientaccesspolicy.xml file used by Silverlight

In Silverlight 3, the Silverlight runtime tries to open a connection using TCP to a well-known port (port 943) on the target site. If a TCP connection can be established, the Silverlight runtime sends the special string <policy-file-request/> to the server to request a Silverlight socket policy file. The Silverlight runtime then waits to receive a reply from the target site that contains a Silverlight policy file.

In Silverlight 4, an application can choose instead to retrieve the policy file via the HTTP protocol on TCP port 80 instead of the custom TCP protocol on port 943. This allows HTTP servers that are already running HTTP services to authorize socket connections from Silverlight applications without having to deploy a new TCP service on the machine and open a port through a firewall for port 943.

To deploy a socket policy file on a server for sockets in Silverlight 3, system administrators need to configure a separate authentication service on port 943 for each IP address that is to provide the policy file definition.

To deploy a policy file on a server for sockets in Silverlight 4, system administrators can choose to use the above method on port 943 or use HTTP port 80. For use with HTTP, system administrators need to configure a web service for each IP address that is to provide the policy file definition and make the Silverlight policy file available over HTTP. The policy file for sockets must be stored in the "clientaccesspolicy.xml" file at the root of a web server that responds for the resolved IP address of the target connection request. …

4: Silverlight Socket Class

5: Silverlight working with Socket

6:  Pushing Data to a Silverlight Client with Sockets: Part I (Silverlight 2)

7: Pushing Data to a Silverlight Client with Sockets: Part II (Silverlight 2)

A Case: Deploy a web application which includes WCF, Silverlight and ASP.NET part 3

I posted the previous 2 parts of our case deployment in 2012:

1: A Case: Deploy a web application which includes WCF, Silverlight and ASP.NET part 1;
2: A Case: Deploy a web application which includes WCF, Silverlight and ASP.NET part 2;

Today I post the 3rd part: Deploy the case on a server which installed Windows Server 2008 R2.

The main point which we should be very careful is the different between in cases of you deploy the ASP.NET with Silverlight on Windows Server and on Windows XP / Windows 7, which is that we should consider more security settings on Windows Server version, it means we might never met some troubles on Windows 7 but they are normal on Windows Server.

OK, let us check the first problem: if you deploy the case on Windows server, when you done all steps which were mentioned in previous 2 posts, you will find all Silverlight web page still not work, for example, you will only see the empty page, not any Silverlight page content display.

The reason is about Security.

In previous part 2, after you unzip SLApp.xap, and changed Silverlight Client side configuration file, and zipped whole folder files into a new file, The Windows Server system actually changed the file security information, this is the big difference with when you do the same procedure in Windows 7.

Please check the following screen shot, the new file has a different icon with old SLApp.xap file.


Right click the file and check the properties, click Security tab, you can see the different security settings:

image  image

So now we now the new zipped file missed some security information. Let us just add missed group or user names which are IIS_IUSRS, Usuarios and TrustedInstaller, you might not have to add all missed roles, for example, you might ONLY need to add the IIS_IUSRS user. (In our case, we added IIS_IUSRS and Usuarios)

After you added missed security information, you will see the web page visiting works again.

A Case: Deploy a web application which includes WCF, Silverlight and ASP.NET part 2

About our case’s deployment, I have posted the part 1 here. This article is the part 2.

We have done the discuss for Web Server settings and WCF configuration. Here we start from the 3rd part: Silverlight project configuration.

C> Silverlight project:

The Silverlight project or application also need to be set since it communicates with WCF services. you have to specify your right WCF service URL to Silverlight project or application. However, our smart Microsoft does NOT provide a similar config file with WCF or other applications, there is NOT a configuration file for Silverlight. All configuration information were involved in a binary file, which is a .xap file, Normally, you can find it under ClientBin folder.


So what you should do is try to find a way to change the config information in this .xap file. There are also some solutions on the internet to tell programmer to use other ways to set information for Silverlight application, but by now I have not found a ideal solution. Maybe we need to research more about this.

OK, let us come back to try to set for Silverlight. actually, the way is simple, the .xap file is actually a compress file, it is a true .zip file !, so, my friend, the magic is here! Haha… Just change the extension name .xap to .zip (or for more safe, just like me, copy the .xap file to a .zip file), and unzip using your normal way to expand it. 


Bingo! now you can see the expanded folder which includes lots of secret files!


What we need to care about is the ServiceReferences.ClientConfig file only, so we can ignore all other files here. Please use any text edit tool such as notepad to open this file, you can see the content is like the following:


Now I think smart you know what should do, yes, just use a correct WCF service address to replace the above green box wrapped content, our case is which mentioned in part 1. and save it. and close the editor tool.

OK, you fixed the Silverlight configuration, one more step: please DO NOT forget to recover the .xap file

What we should do is just compress all the folder to a zip file again. and change the extension name to .xap file, that is.! But, please DO NOT compress the files out side of the files’ folder, but inside the folder please! so that you can get a compress file which does not include the folder itself. otherwise your .xap file will not work.

Maybe I need to teach you more details here even though it is a very simple step:

Make sure you are inside of the files’ folder; and choose all files in this folder, and then right mouse, choose a compress way due to your compress tools installed, for Windows 7, you just simply choose “send to” a compress file.  Again: you should make sure you are inside the folder, so that the generated zip file will NOT include the folder itself. This is also very important!


Finally, Change your .zip file to .xap file using the original file name. that is! The configuration for Silverlight done!

D> Website Project:

The most simple part is website in our case, we do not need any configuration for our website project since most of settings have already done on previous projects.

All we need to do is copy all web files including Silverlight project content (Web developer should prepare a complete website deployment package first. the package include website and Silverlight project,  you should do the Silverlight part configuration just like what I told above), We should copy the content to the virtual folder on IIS web server which we created in the part 1, in our case, the URL is:

If you have finished all configuration successfully, and you have started the WCF Service, and you have copy all website files on IIS web server, now you should be able to visit your website.

Let me leave for other stuff. I might come back for more support information, in case of I find more.

Good luck!

A Case: Deploy a web application which includes WCF, Silverlight and ASP.NET part 1

We have a web application which developed using ASP.NET 4.0 (Web Forms), Silverlight 4.0 and WCF 4.0.

Brief information about our application:

1: We use WCF to provide all data to clients, some data are from database, another part of data are from a real time data resource;
2: We use self host for the WCF service, which host the WCF on a standalone WPF application, the real time data resource is exactly from the WPF application;
3: All clients are the web pages which using Silverlight, Silverlight content hosted on ASP.NET web form pages.

Here I am going to talk about deployment of our web application, we deploy it to our different customers.


I will introduce the whole deployment to 4 different parts:
A> Web Server; B> WCF project; C> Silverlight project; D> Web site.

A> Web server (IIS):

Actually we should not too worry about the settings on web server (IIS), because most of time the customer should arrange their own network administrator (or call other name but just an administrator) to handle this part.

What I suggest is that using IIS 7 or above, which matches and supports well most of ASP.NET web applications especially new ASP.NET techs.

And, we need to create 2 Applications (on IIS 7, the “Add Application” is different from “Add Virtual Directory” ) on IIS, the one is for WCF service, another one is for Web site.

(Update: Actually, for WCF self host mode, we do not need to add an application for WCF, because the WCF service URL has been already set in the host program. So please know we ONLY need one application folder for website project below.)

You can check the following image, for our case, we created 2 virtual folders on our IIS server:

ConsWCFServices virtual folder is for our WCF service project;  (Update: Do NOT need this one)
WebTerminal2012 virtual folder is for our Web site project;


B> WCF project:

Before we put our WCF project content on the corresponding virtual folder which I introduced above, we need to set the WCF configuration, to let WCF work correctly.

If you choose other WCF host mode but not self host. for example you choose web server host mode, you have to copy your final WCF service content to IIS web server finally.  However, please know in our case, we use WCF self host mode, so we actually DO NOT need to put any generated WCF conten on our IIS, what we should do just set right URLs to “image” our WCF service to IIS web server

Because we use a WPF application to host WCF, so we should open the WPF config file, which named xxxx.exe.config (xxxx is WPF project name, if you choose web server host, you need to find a config file maybe named web.config):

We should set 2 parts for WCF Service with the self host program:

The first part is for database: here you need to change the database connection string.  Put your database server name, your database name and your database user account information. But Please DO NOT change the connection string name! (for example, the following connection string’s name is SysDBConnString, then please do not change it.)


The second part
is for WCF services:

Please check the following settings, I have mentioned above, we need 2 virtual folders on IIS web server, but we just need to care about the WCF virtual folder here. Look at the following 2 URLs which wrapped by green boxes.

The first URL is for the the “famous WCF and Silverlight trouble” – The “Cross Domain issue”. (Yes, if you want to know what it the cross domain trouble, you can check the link, I have posted a blog before about it).

Actually, you don’t need to know what the cross domain trouble is, just set a right URL here, please make sure the URL is the root virtual folder which your WCF service content will be located in. for example: suppose we are set a WCF service with a web server host mode (not like ours self host), we should created the web application folder such as ConsWCFServices on our IIS, which you can see in above IIS part. the root URL is just “”, it is a root virtual folder. This is very important, otherwise you will meet the famous cross domain trouble.
Update: For self host mode, we still need to a root virtual folder (web application root folder on IIS), but you just set it in the web configuration file, you DO NOT need to create an physical folder on IIS for a self host mode WCF service.

I can set (map) my WCF service content in the root folder, but I can choose NOT. Just like our case, the second URL is just our real WCF folder, we put (map) our WCF service program in the second URL. But please know  you have to choose a sub folder under the root WCF virtual folder which you have set in the first URL.  in our case, we choose a sub folder named “TerminalService/SL/”, actually this sub folder is NOT exists on IIS server (and you do not need to create it either). but when you set this sub folder, you should make sure later you can get WCF service information through this sub folder, the full URL is in our case.


OK, the WCF part set done. all you need to do now is just starting the WCF service on your hosting project.

After you done WCF config, please use a web browser to try to visit your WCF service, using the sub folder URL which I mentioned above:

In our case, we can get the WCF web service result, just like the following showing:


If you can not see the similar page, that means you have not set correct configuration for your WCF service project. Please double check your settings, and even have to contact with the web server administrator.

OK, let use pause here. so that we can make sure our WCF is working. See you guys on the part 2.