1、環境配置
本文的Silverlight版本為Silverlight3,具體的配置過程可以參考:http://www.cnblogs.com/psunny/archive/2009/08/31/1556976.html或者http://www.cnblogs.com/wheeloffate/archive/2009/08/25/1553973.html
如果希望破解expression studio 3的話,可以在google中搜尋【expression studio 3 破解】,也就是將下載的dll替換安裝目錄中的原檔案,替換之前別忘了備份原檔案,以防意外。
2、注意事項
2.1 跨域訪問
跨域指的是當WCF的宿主和Silverlight得宿主不在同一個域中的時候,預設是不可以訪問的。這裡的域指的是應用程式的域,詳細介紹可以參看:.net中應用程式定義域的概念。
主要是指的wcf預設不支援跨域訪問(當你在單獨一個項目中),需要兩個xml檔案來聲明wcf是可以跨域訪問的。
下面的跨域支援來自:http://www.silverlightshow.net/items/WCF-Integration-in-Silverlight-2-Beta-1.aspx
Cross-Domain Support
If you want to enable your service to work cross-domain, there are two files you will want to concern yourself with:
crossdomain.xml
This file comes from back in the macromedia flash days. Since it has wide support on the internet, it makes sense for Silverlight to support it. You can read some documentation on this file format here.
One use supported by the specification is to specify domains which can access the service:
xml version="1.0"?>
DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.yoursite.com" />
<allow-access-from domain="yoursite.com" />
<allow-access-from domain="*.moock.org" />
cross-domain-policy>
However, that detailed format is
not supported
by Silverlight. Instead, you must opt in to all domains if you want to use the crossdomain.xml approach. Such a policy file would look like this:
xml version="1.0"?>
DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
cross-domain-policy>
However, since this format doesn't cover all the scenarios that Silverlight developers are likely interested in (and flash developers too, most likely), Microsoft has provided another cross-domain file that is more flexible and currently Silverlight-specific: clientaccesspolicy.xml.