私はRIAWCF RIA Servicesサンプル、HRアプリケーション4004例外
とSilverlightを開発するために絶対に初心者だ私は、エラーしばらく取得チュートリアル
に従うことによってsilverlight.netからWCF RIA Servicesサンプルを見つけました私は新しい従業員を追加しようとし
それはJITデバッガVSメッセージを一つのウィンドウをポップアップ表示されます
コード:4004
カテゴリ:管理ランタイムエラー
メッセージ:System.ServiceModel.DomainServices.Client.DomainException:タイプ
のドメインコンテキストに変更を送信中にエラーが発生しました私はAdventureWork2008EntitiesでのSilverlight 4を使用していますこのチュートリアルを行うには、以下のアプリケーションのコードです
<dataForm:DataForm x:Name="addEmployeeDataForm" AutoGenerateFields="False" AutoCommit="True" AutoEdit="True" CommandButtonsVisibility="None">
<dataForm:DataForm.EditTemplate>
<DataTemplate>
<StackPanel>
<dataForm:DataField Label="Business Entity ID">
<TextBox Text="{Binding BusinessEntityID, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Login ID">
<TextBox Text="{Binding LoginID, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="National ID">
<TextBox Text="{Binding NationalIDNumber, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Title">
<TextBox Text="{Binding JobTitle, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Marital Status">
<TextBox Text="{Binding MaritalStatus, Mode=TwoWay}" />
</dataForm:DataField>
<dataForm:DataField Label="Gender">
<TextBox Text="{Binding Gender, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
<dataForm:DataField Label="Salaried">
<CheckBox IsChecked="{Binding SalariedFlag, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
<dataForm:DataField Label="Active">
<CheckBox IsChecked="{Binding CurrentFlag, Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True }" />
</dataForm:DataField>
</StackPanel>
</DataTemplate>
</dataForm:DataForm.EditTemplate>
</dataForm:DataForm>
従業員登録Window.xaml
ます。private void addNewEmployee_Click(オブジェクト送信者、RoutedEventArgs e)の
{ EmployeeRegistrationWindow addEmp =新しいEmployeeRegistrationWindow(); addEmp.Closed + =新しいイベントハンドラ(addEmp_Closed); addEmp.Show();私は誰がこの投稿へ返信しましませんが、私は私が来て少し情報を追加しようと思いました気づく }private void addEmp_Closed(object sender, EventArgs e)
{
EmployeeRegistrationWindow emp = (EmployeeRegistrationWindow) sender;
if (emp.NewEmployee != null)
{
OrganizationContext _organizationContext = (OrganizationContext) (employeeDataSource2.DomainContext);
_organizationContext.Employees.Add(emp.NewEmployee);
employeeDataSource2.SubmitChanges();
}
}
従業員List.xaml.cs
public void InsertEmployee(Employee employee)
{
employee.HireDate = DateTime.Now;
employee.ModifiedDate = DateTime.Now;
employee.VacationHours = 100;
employee.SickLeaveHours = 0;
employee.rowguid = Guid.NewGuid();
employee.BirthDate = new DateTime(1967, 3, 18);
if ((employee.EntityState != EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Added);
}
else
{
this.ObjectContext.Employees.AddObject(employee);
}
}
OrganizationService