繁体   English   中英

Windows XP .NET Framework 4.0中WPF xaml中的异常

[英]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中不可用

现在,我无法访问CallerMemberNameNotifyPropertyChanged

我决定用命名空间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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM