![](/img/trans.png)
[英].NET 4.0 gives Unknown Exception on XP but it working good on Windows 7
[英]Exception in WPF xaml in Windows XP .NET Framework 4.0
我已經用.NET 4.6.1構建了WPF應用程序。
之后,我降級為4.0,因為它需要在Windows XP中運行
問題是我在Windows XP中啟動程序時遇到問題。
這是我的xaml:
<Window x:Class="ETest_Scanner.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="E-Test Barcode Formatter" Height="200" Width="450"
Topmost="True" StateChanged="Window_StateChanged" Icon="IMG/scanner.ico"
Background="#FF919191">
<Grid>
<Label Content="{Binding BarcodeScanner.ScannedBarcode,
FallbackValue=AnyError}" Margin="10" FontSize="72"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
</Grid>
</Window>
如何防止錯誤發生?
似乎他對名稱空間有疑問?
這僅在Windows XP和Windows 10&Windows 7中會發生,它可以完美運行。
提前致謝
編輯:
我試圖創建一個新項目,該項目馬上就達到了4.0。
然后問題是using System.Runtime.CompilerServices;
的庫using System.Runtime.CompilerServices;
在.NET 4.0中不可用
現在,我無法訪問CallerMemberName
我NotifyPropertyChanged
。
我決定用命名空間System.Runtime.CompilerServices
創建一個類,因此編譯器認為我有可用的類,看起來像這樣:
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public class CallerMemberName : Attribute
{
}
}
現在構建很好,但我仍然遇到上圖所示的問題。
所以我試圖解決這個問題,但是我無法提出解決方案或合理的失敗。
我決定將整個應用程序也合並到.NET 4.0和x86中的Windows Forms應用程序中。
在Windows XP和Windows 7計算機上的首次構建以及首次測試中,它都像魅力一樣工作。
我將不回答這個問題,也許有一天有人可以提出解決方案或遇到相同的問題
嘗試添加配置設置:
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.