/* by josh */

2013年9月10日 星期二

[Visual Studio] 加入WCF服務參考時產生錯誤"無法為服務參考xxx產生程式碼"或加入參考時"建置系統已經參考這個元件"


When you add Service Reference into Silverlight project, some time you get “failed to generate code for the service reference…” error.  Which means Visual Studio is failed to generate client code, and if see “ServiceReferences.ClientConfig” file it is empty. This is the common error most of the people get.

Step 1. In "Add Service Reference", Get in to "Advance"
 
 
 
Step 2. uncheck the “Reuse types in referenced assemblies” check box and click on Ok button.
 
Once you click on Ok button in Service Reference dialog box, the client code will be generated and you will not get any error. Now if you open “ServiceReferences.ClientConfig” file you can see the generated code.


2013年8月5日 星期一

[C#] asp.net加入Silverlight的WCF service (可用於連接MSSQL)

Silverlight連接 MS SQL必須透過WCF;

Step1:
首先必須在asp.net 網頁中加入WCF Service:


Step2:
撰寫合約內容:

Step3: 
於Silverlight中加入服務參考

Step4:
於Silverlight xaml.cs中使用WCF Service,需注意的是這邊的WCF服務必須使用非同步的方式呼叫(1.先定義服務完成的事件處理函式2.設計事件處理函式內容3.呼叫服務)