2014-10-16 114 views
0

我正在使用wpf在.net framework 4.0中开发我的项目。 以下是Crystal报表查看器的XAML代码。XAMLParseException在InitializeComponent()处未处理

<Window x:Class="KhataBahi.GenerateReports" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml 
     xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" 
     Title="GenerateReports" Height="600" Width="550"> 
    <Grid Margin="0,0,2,-1"> 
     <Button x:Name="Back" Content="Back" HorizontalAlignment="Left" Height="38" Margin="198,522,0,0" VerticalAlignment="Top" Width="115" Click="Back_Click"/> 
     <my:CrystalReportsViewer x:Name="KhataBahiAMReportsViewer" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="490"/> 

    </Grid> 

然而,其给予以下在例外的InitializeComponent();

在寻找这个问题的解决方案时,有人建议发生这种情况是因为您必须明确地告诉编译器支持旧的.Net dll进入.Net 4.0运行时。因此,我将以下内容添加到了我的app.config文件

<startup useLegacyV2RuntimeActivationPolicy="true" > 
    <supportedRuntime version= "v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 

但是编译器总是显示这样

所以消息,进一步我去dotnetconfig40.xsd的性能和编辑过的启动为

<xs:element name="startup" vs:help="configuration/startup"> 
    <xs:complexType> 
     <xs:choice minOccurs="1" maxOccurs="1"> 
      <xs:element name="requiredRuntime" vs:help="configuration/startup/requiredRuntime"> 
       <xs:complexType> 
        <xs:attribute name="version" type="xs:string" use="optional" /> 
        <xs:attribute name="safemode" type="xs:boolean" use="optional" /> 
       </xs:complexType> 
      </xs:element> 
      <xs:element name="supportedRuntime" minOccurs="1" maxOccurs="unbounded" vs:help="configuration/startup/supportedRuntime"> 
       <xs:complexType> 
        <xs:attribute name="version" type="xs:string" use="optional" /> 
        <xs:attribute name="sku" type="xs:string" use="optional" /> 
       </xs:complexType> 
      </xs:element> 
     </xs:choice> 
     <xs:attribute name="useLegacyV2RuntimeActivationPolicy" type="xs:boolean" use="optional" /> 
     <!-- see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx --> 
    </xs:complexType> 
</xs:element> 

这样删除了警告,但异常仍然存在。 我甚至试图将组件绑定明确的app.config

<runtime> 
    <assemblyBinding xmlns ="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"> 
     <probing privatePath="C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86"/> 
    </assemblyBinding> 
    </runtime> 

但是,没有运气。请提出解决方案。

+1

什么异常? – JeffRSon 2014-10-16 12:58:30

+0

可能是因为'xmlns:x = http:// schemas.microsoft.com/winfx/2006/xaml'中缺少引号? – Sjeijoet 2014-10-16 14:37:24

+0

我也试过,但它仍然给出同样的例外。 – Naina 2014-11-07 11:44:46

回答

0

您没有" "在您的名字空间为x。此外,请检查内部例外

<Window x:Class="KhataBahi.GenerateReports" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" 
    Title="GenerateReports" Height="600" Width="550"> 
<Grid Margin="0,0,2,-1"> 
    <Button x:Name="Back" Content="Back" HorizontalAlignment="Left" Height="38" Margin="198,522,0,0" VerticalAlignment="Top" Width="115" Click="Back_Click"/> 
    <my:CrystalReportsViewer x:Name="KhataBahiAMReportsViewer" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="490"/> 
</Grid> 
</Window> 
+0

我检查了它的内部异常XAML解析异常说:“类型'SAPBusinessObjects.WPF.Viewer.ViewerCore'上匹配指定绑定约束的构造函数的调用引发异常。” – Naina 2014-11-07 11:50:10

+0

应该还有更多。它试图说它不能解决它的构造函数? – 2014-11-09 03:20:38

+0

InnerException声明:“CrystalDecisions.Shared.SharedUtils的类型初始值设定项引发异常。” – Naina 2014-11-10 05:16:23