2011-12-13 25 views
0

通過我得到一個安全錯誤:的Silverlight,EF型EntityCollection的成員集合 - 不知道如何通過WCF

The inner exception is: {System.Security.SecurityException ---> System.Security.SecurityException: Security error.

UPDATE 我的問題是,因爲分類型(傳遞槽WCF)的內部一個產品集合。類別和模型類型的其餘部分是使用實體框架生成的代碼。類別中的產品成員屬於EntityCollection類型。

產品集合類產品:(生成的代碼)

[XmlIgnoreAttribute()] 
    [SoapIgnoreAttribute()] 
    [DataMemberAttribute()] 
    [EdmRelationshipNavigationPropertyAttribute("inventory_db_bigModel", "Products_fk", "Products")] 
    public EntityCollection<Products> Products 

的問題是怎麼做的,我宣佈在客戶端服務引用的產品系列? 我試着用ObservableCollection和通用列表,但它給了我相同的安全錯誤。 客戶端ServiceReference代碼是生成的代碼,我不確定該解決方案的方式如何,以便在每次重新生成時都不必編輯它。

回答

0

您是否在WCF服務上設置了clientaccesspolicy.xml和/或crossdomain.xml

通過設計Silverlight是從做跨域調用禁止以防止類似跨站點僞造安全威脅。

To enable a Silverlight control to access a service in another domain, the service must explicitly opt-in to allow cross-domain access. By opting-in, a service states that the operations it exposes can safely be invoked by a Silverlight control, without potentially damaging consequences to the data that the service stores.

爲了讓你有連接建立或者是clientaccesspolicy.xmlcrossdomain.xml文件中要使用該服務的根。

MSDN有更多的信息。

+0

是的,我有這些文件。使用GetUsers檢索用戶列表的應用程序的另一部分工作正常,因此與WCF服務的通信沒有問題。這個用戶模型類型裏面沒有實體框架集合。正如我在後期更新中所解釋的,類別模型類型內部有一個實體框架集合類型。所以我得到的錯誤是因爲這個實體集合在裏面,我不知道如何將它傳遞給wcf。 –

+0

@PaulRusu - 你爲什麼沒有在你的問題中包含這些信息?它徹底改變了問題的本質。 – ChrisF

相關問題