質問

I have this issue when using a WPF User User Control Library I have made, in a WPF Browser App.

I added it to the Page as follows and have added the Reference to my User Control to the project

<Page x:Class="Page1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:tools="clr-namespace:Visualisation;assembly=Visualisation"
  mc:Ignorable="d" 
  d:DesignHeight="600"
  d:DesignWidth="1100"
  Title="Page1">
<Grid Name="main">
    <tools:uc3dview Name="_View"></tools:uc3dview>
</Grid>
</Page>

I get the following error.

System.Reflection.TargetInvocationException was unhandled
Message: Exception has been thrown by the target of an invocation.

If I use this exact user control in a WPF application, I have no problems.

Is there some constructor notation I'm missing so my User Control Library can work in both WPF applications and more importantly in a WPF Browser App. I'm using Visual Studio 2012, if that matters.

Thanks in advance.

役に立ちましたか?

解決

I finally figured it out. The user control had a a drop shadow effect on one of its controls.

<ScrollViewer.Effect>
            <DropShadowEffect/>
</ScrollViewer.Effect>

Because this xbap Browser app was running in partial trust mode. When the control went to get the authorisation to do the drop shadow effect the error was raised.

Running the browser app in full trust or just commenting out the drop shadow effect, fixes the problem.

If someone can explain it better. Please go ahead.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top