我正在使用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>
但是,沒有運氣。請提出解決方案。
什麼異常? – JeffRSon 2014-10-16 12:58:30
可能是因爲'xmlns:x = http:// schemas.microsoft.com/winfx/2006/xaml'中缺少引號? – Sjeijoet 2014-10-16 14:37:24
我也試過,但它仍然給出同樣的例外。 – Naina 2014-11-07 11:44:46