Silverlight3系列(一)Silverlight配合WCF進行資料庫操作

來源:互聯網
上載者:User

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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.