我有一个列表框我正在结合的对象的集合。

在后面的代码时,得到的作业的列表,并将其绑定到列表框项目源:

List<JobEntity> jobList = new List<JobEntity>();
Job j = new Job();
jobList = j.LoadJobs(pageSize, pageIndex);
lbxJobs.ItemsSource = jobList;

在XAML,我然后尝试和访问某些作业的属性的。

   <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错误:16:不能   获得“HiringCompany”值(类型   从 '字符串') ''(类型 'JobEntity')。   BindingExpression:路径= HiringCompany;   的DataItem = 'JobEntity'   (的HashCode = 64844482);目标元件是   '的TextBlock'(名称= '');目标属性   是“文本”(类型“字符串”)   TargetInvocationException:'System.Reflection.TargetInvocationException:   属性访问器“HiringCompany”上   对象“JobSearch.Classes.JobEntity”   扔以下   例外: 'JobSearch.Classes.JobEntity.get_HiringCompany()'   ---> System.MethodAccessException:JobSearch.Classes.JobEntity.get_HiringCompany()   ---> System.Security.SecurityException:   请求类型的许可   “System.Security.Permissions.ReflectionPermission,   mscorlib程序,版本= 2.0.0.0,   文化=中性,   公钥= b77a5c561934e089'   失败

有任一项碰上此之前或找到该错误解决方法?

有帮助吗?

解决方案

我刚刚找到了答案,以我自己的问题。我没有我的JobEntity类明确定义为“公共”。这样做解决了问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top