【发布时间】:2010-11-27 19:04:41
【问题描述】:
当我尝试使用 WCF RIA 为 silverlight 应用程序加载数据但出现错误时 如下。
消息:Silverlight 应用程序中出现未处理的错误
代码:4004
类别:ManagedRuntimeError
消息:System.ServiceModel.DomainServices.Client.DomainOperationException:查询的加载操作失败
我正在使用远程数据库,它正确地验证了用户,连接到数据库但数据绑定失败。代码:
public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// create a context to the WCF RIA service and call the RIA service method
// to get the list of all customers.
var context = new ExpertIssueTracker.Web.ITDomainContext();
dataGrid1.ItemsSource = context.IT_USERs;
context.Load(context.GetIT_USERQuery());
}
我尝试了 fiddler,但无法找出确切原因。在连接到远程托管数据库时我们有任何具体问题吗?
【问题讨论】:
-
WCF RIA 错误非常糟糕。每次我看到这条消息都是因为数据库连接字符串不正确。
-
那有什么解决办法呢? connectionString="metadata=res://*/ITModel.csdl|res://*/ITModel.ssdl|res://*/ITModel.msl;provider=System.Data.SqlClient;provider 连接字符串="Data Source=**Source***;Initial Catalog=***DBNAME***;Persist Security Info=True;User ID=***DBNAME***;Password=***Password***;MultipleActiveResultSets=True” ;" providerName="System.Data.EntityClient" />
标签: silverlight-4.0 wcf-ria-services