オブジェクトのコレクションにバインドするリストボックスがあります。背後にあるコードではXBAPのデータバインディングで反射エラーが発生する
、私は仕事のリストを取得し、リストボックスの項目ソースにバインド:XAMLで
List<JobEntity> jobList = new List<JobEntity>();
Job j = new Job();
jobList = j.LoadJobs(pageSize, pageIndex);
lbxJobs.ItemsSource = jobList;
、私は、ジョブのプロパティの一部を試してみて、アクセスします。
<ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel>
<TextBlock Text="{Binding Path=Title}" Margin="5 0" />
<TextBlock Text="{Binding Path=HiringCompany}" Margin="5 0" />
</WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
これは、通常のWPFアプリケーションのために正常に動作しますが、XBAPアプリとして、それは基本的に反射権限が拒否されたので、それが値を得ることができないというエラーがスローされます。
System.Windows.Data Error: 16 : Cannot get 'HiringCompany' value (type 'String') from '' (type 'JobEntity'). BindingExpression:Path=HiringCompany; DataItem='JobEntity' (HashCode=64844482); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') TargetInvocationException:'System.Reflection.TargetInvocationException: Property accessor 'HiringCompany' on object 'JobSearch.Classes.JobEntity' threw the following exception:'JobSearch.Classes.JobEntity.get_HiringCompany()' ---> System.MethodAccessException: JobSearch.Classes.JobEntity.get_HiringCompany() ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
このエラーが発生したことはありますか?このエラーの回避策はありますか?