Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabinding in XBAP throws reflection error
    text
    copied!<p>I have a listbox that I'm binding to a collection of objects. </p> <p>In the code behind, I get a list of the jobs and bind it to the listbox items source:</p> <pre><code>List&lt;JobEntity&gt; jobList = new List&lt;JobEntity&gt;(); Job j = new Job(); jobList = j.LoadJobs(pageSize, pageIndex); lbxJobs.ItemsSource = jobList; </code></pre> <p>In the xaml, I then try and access some of the properties of the job. </p> <pre><code> &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;WrapPanel&gt; &lt;TextBlock Text="{Binding Path=Title}" Margin="5 0" /&gt; &lt;TextBlock Text="{Binding Path=HiringCompany}" Margin="5 0" /&gt; &lt;/WrapPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; </code></pre> <p>This works fine for a normal wpf application, but as an xbap app it throws an error that basically says it can't get the value because Reflection Permissions were denied.</p> <blockquote> <p>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</p> </blockquote> <p>Has any one run into this before or found a workaround for this error? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload