简体   繁体   中英

Exception in WPF xaml in Windows XP .NET Framework 4.0

I have built a WPF application with .NET 4.6.1.

after that i downgraded to 4.0 because it needs to run in Windows XP

The problem is that i run into a problem during the start of the programm in Windows XP.

在此处输入图片说明

here my 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>

how can i prevent that the error occures?

it seems that he has a problem with the namespaces?

this only happens in windows XP in windows 10 & windows 7 it works perfectly.

thanks in advance

EDIT:

i tried to create a new project which was 4.0 straight away.

the problem then was that the library, using System.Runtime.CompilerServices; was not available in .NET 4.0

Now i could not access the CallerMemberName for my NotifyPropertyChanged .

i decided to create a class with the namespace System.Runtime.CompilerServices so the compiler thinks that i have the class available, looked like something like this:

namespace System.Runtime.CompilerServices
{
    [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
    public class CallerMemberName : Attribute
    {
    }
}

now the build was fine but i still have the same problem as shown in the image above.

So i tried to manage this problem but i cant come up with a solution or a reasonable failure.

i decided to merge the whole application into a Windows Forms application also in .NET 4.0 and x86.

worked like a charm on the first build and also on the first test on the Windows XP and Windows 7 machine.

i will leave this question as not answered maybe somebody can come up with a solution or runs into the same problem someday

Try adding config setting:

<runtime>
 <legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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