Skip to content

Commit 885f724

Browse files
committed
Upgrade WpfMVVMSample to net471 and fix runtime exceptions
1 parent 89192da commit 885f724

File tree

9 files changed

+79
-126
lines changed

9 files changed

+79
-126
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
55
</startup>
6-
</configuration>
6+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<Application x:Class="WpfMVVMSample.App"
1+
<unity:PrismApplication x:Class="WpfMVVMSample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:local="clr-namespace:WpfMVVMSample">
4+
xmlns:unity="http://prismlibrary.com/">
55
<Application.Resources>
66

77
</Application.Resources>
8-
</Application>
8+
</unity:PrismApplication>
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
using System.Windows;
1+
using System.Windows;
2+
using Prism.Ioc;
3+
using WpfMVVMSample.Settings;
84

95
namespace WpfMVVMSample
106
{
117
/// <summary>
128
/// Interaction logic for App.xaml
139
/// </summary>
14-
public partial class App : Application
10+
public partial class App
1511
{
16-
protected override void OnStartup(StartupEventArgs e)
12+
protected override void RegisterTypes(IContainerRegistry containerRegistry)
1713
{
18-
base.OnStartup(e);
14+
containerRegistry.RegisterSingleton<SettingsManager>();
15+
}
1916

20-
var bootstrapper = new Bootstrapper();
21-
bootstrapper.Run();
17+
protected override Window CreateShell()
18+
{
19+
return new MainWindow();
2220
}
2321
}
2422
}

Samples/WpfMVVMSample/WpfMVVMSample/Bootstrapper.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ public UnitToStringConverter()
2828

2929
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
3030
{
31-
var unitType = value.GetType();
32-
var unitEnumType = unitType.GetProperty("BaseUnit").PropertyType;
31+
var quantityType = value.GetType();
32+
var unitEnumType = quantityType.GetProperty("BaseUnit").PropertyType;
3333
var unitEnumValue = _settings.GetDefaultUnit(unitEnumType);
3434
var significantDigits = _settings.SignificantDigits;
3535

36-
var result = unitType
37-
.GetMethod("ToString", new[] { unitEnumType, typeof(IFormatProvider), typeof(int) })
38-
.Invoke(value, new object[] { unitEnumValue, null, significantDigits });
36+
var quantityInUnit =
37+
quantityType
38+
.GetMethod("ToUnit", new[] {unitEnumType})
39+
.Invoke(value, new[] {unitEnumValue});
40+
41+
var result = quantityType
42+
.GetMethod("ToString", new[] {typeof(IFormatProvider), typeof(int)})
43+
.Invoke(quantityInUnit, new object[] {null, significantDigits});
3944

4045
return result;
4146
}
@@ -68,6 +73,7 @@ private static object ParseDouble(Type targetType, double number, Type unitEnumT
6873
.GetMethod("From", new[] { typeof(QuantityValue), unitEnumType })
6974
.Invoke(null, new object[] { (QuantityValue)number, unitEnumValue });
7075
}
76+
7177
private static object ParseUnit(object value, Type targetType)
7278
{
7379
return targetType

Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.Designer.cs

Lines changed: 18 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/WpfMVVMSample/WpfMVVMSample/Properties/Settings.Designer.cs

Lines changed: 9 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Samples/WpfMVVMSample/WpfMVVMSample/WpfMVVMSample.csproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
<OutputType>WinExe</OutputType>
99
<RootNamespace>WpfMVVMSample</RootNamespace>
1010
<AssemblyName>WpfMVVMSample</AssemblyName>
11-
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1414
<WarningLevel>4</WarningLevel>
1515
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<TargetFrameworkProfile />
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1819
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,7 +36,7 @@
3536
</PropertyGroup>
3637
<ItemGroup>
3738
<Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
38-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\CommonServiceLocator.dll</HintPath>
39+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\CommonServiceLocator.dll</HintPath>
3940
</Reference>
4041
<Reference Include="Prism, Version=7.1.0.431, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
4142
<HintPath>..\..\packages\Prism.Core.7.1.0.431\lib\net45\Prism.dll</HintPath>
@@ -67,7 +68,7 @@
6768
<Reference Include="System.ServiceProcess" />
6869
<Reference Include="System.Transactions" />
6970
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
70-
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
71+
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
7172
</Reference>
7273
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7374
<HintPath>..\..\packages\Prism.Wpf.7.1.0.431\lib\net45\System.Windows.Interactivity.dll</HintPath>
@@ -85,25 +86,25 @@
8586
<HintPath>..\..\packages\UnitsNet.4.0.0-beta1\lib\net40\UnitsNet.dll</HintPath>
8687
</Reference>
8788
<Reference Include="Unity.Abstractions, Version=3.3.1.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
88-
<HintPath>..\..\packages\Unity.Abstractions.3.3.1\lib\net46\Unity.Abstractions.dll</HintPath>
89+
<HintPath>..\..\packages\Unity.Abstractions.3.3.1\lib\net47\Unity.Abstractions.dll</HintPath>
8990
</Reference>
9091
<Reference Include="Unity.Configuration, Version=5.2.5.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f, processorArchitecture=MSIL">
91-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\Unity.Configuration.dll</HintPath>
92+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Configuration.dll</HintPath>
9293
</Reference>
9394
<Reference Include="Unity.Container, Version=5.8.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
94-
<HintPath>..\..\packages\Unity.Container.5.8.11\lib\net46\Unity.Container.dll</HintPath>
95+
<HintPath>..\..\packages\Unity.Container.5.8.11\lib\net47\Unity.Container.dll</HintPath>
9596
</Reference>
9697
<Reference Include="Unity.Interception, Version=5.5.5.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
97-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\Unity.Interception.dll</HintPath>
98+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.dll</HintPath>
9899
</Reference>
99100
<Reference Include="Unity.Interception.Configuration, Version=5.1.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
100-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\Unity.Interception.Configuration.dll</HintPath>
101+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.Configuration.dll</HintPath>
101102
</Reference>
102103
<Reference Include="Unity.RegistrationByConvention, Version=2.1.9.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
103-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\Unity.RegistrationByConvention.dll</HintPath>
104+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.RegistrationByConvention.dll</HintPath>
104105
</Reference>
105106
<Reference Include="Unity.ServiceLocation, Version=2.1.2.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
106-
<HintPath>..\..\packages\Unity.5.8.11\lib\net46\Unity.ServiceLocation.dll</HintPath>
107+
<HintPath>..\..\packages\Unity.5.8.11\lib\net47\Unity.ServiceLocation.dll</HintPath>
107108
</Reference>
108109
<Reference Include="WindowsBase" />
109110
<Reference Include="PresentationCore" />
@@ -114,7 +115,6 @@
114115
<Generator>MSBuild:Compile</Generator>
115116
<SubType>Designer</SubType>
116117
</ApplicationDefinition>
117-
<Compile Include="Bootstrapper.cs" />
118118
<Compile Include="Converters\EnumBindingSource.cs" />
119119
<Compile Include="Settings\SettingsManager.cs" />
120120
<Page Include="MainWindow.xaml">
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="CommonServiceLocator" version="2.0.4" targetFramework="net461" />
4-
<package id="Prism.Core" version="7.1.0.431" targetFramework="net461" />
5-
<package id="Prism.Unity" version="7.1.0.431" targetFramework="net461" />
6-
<package id="Prism.Wpf" version="7.1.0.431" targetFramework="net461" />
7-
<package id="System.Configuration.ConfigurationManager" version="4.5.0" targetFramework="net461" />
8-
<package id="System.Reflection.Emit" version="4.3.0" targetFramework="net461" />
9-
<package id="System.Security.AccessControl" version="4.5.0" targetFramework="net461" />
10-
<package id="System.Security.Permissions" version="4.5.0" targetFramework="net461" />
11-
<package id="System.Security.Principal.Windows" version="4.5.1" targetFramework="net461" />
12-
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
13-
<package id="UnitsNet" version="4.0.0-beta1" targetFramework="net461" />
14-
<package id="Unity" version="5.8.11" targetFramework="net461" />
15-
<package id="Unity.Abstractions" version="3.3.1" targetFramework="net461" />
16-
<package id="Unity.Container" version="5.8.11" targetFramework="net461" />
3+
<package id="CommonServiceLocator" version="2.0.4" targetFramework="net471" />
4+
<package id="Prism.Core" version="7.1.0.431" targetFramework="net471" />
5+
<package id="Prism.Unity" version="7.1.0.431" targetFramework="net471" />
6+
<package id="Prism.Wpf" version="7.1.0.431" targetFramework="net471" />
7+
<package id="System.Configuration.ConfigurationManager" version="4.5.0" targetFramework="net471" />
8+
<package id="System.Reflection.Emit" version="4.3.0" targetFramework="net471" />
9+
<package id="System.Security.AccessControl" version="4.5.0" targetFramework="net471" />
10+
<package id="System.Security.Permissions" version="4.5.0" targetFramework="net471" />
11+
<package id="System.Security.Principal.Windows" version="4.5.1" targetFramework="net471" />
12+
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />
13+
<package id="UnitsNet" version="4.0.0-beta1" targetFramework="net471" />
14+
<package id="Unity" version="5.8.11" targetFramework="net471" />
15+
<package id="Unity.Abstractions" version="3.3.1" targetFramework="net471" />
16+
<package id="Unity.Container" version="5.8.11" targetFramework="net471" />
1717
</packages>

0 commit comments

Comments
 (0)