mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Fix a issue when deserialize binary storage.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
@@ -23,6 +24,8 @@ namespace Wox.Infrastructure.Storage
|
|||||||
|
|
||||||
protected override void LoadInternal()
|
protected override void LoadInternal()
|
||||||
{
|
{
|
||||||
|
//http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
|
||||||
|
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
@@ -43,7 +46,32 @@ namespace Wox.Infrastructure.Storage
|
|||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
serializedObject = LoadDefault();
|
serializedObject = LoadDefault();
|
||||||
|
#if (DEBUG)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||||
|
{
|
||||||
|
Assembly ayResult = null;
|
||||||
|
string sShortAssemblyName = args.Name.Split(',')[0];
|
||||||
|
Assembly[] ayAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
foreach (Assembly ayAssembly in ayAssemblies)
|
||||||
|
{
|
||||||
|
if (sShortAssemblyName == ayAssembly.FullName.Split(',')[0])
|
||||||
|
{
|
||||||
|
ayResult = ayAssembly;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ayResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SaveInternal()
|
protected override void SaveInternal()
|
||||||
@@ -58,11 +86,11 @@ namespace Wox.Infrastructure.Storage
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error(e.Message);
|
Log.Error(e.Message);
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
{
|
{
|
||||||
throw e;
|
throw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="Default.xaml"></ResourceDictionary>
|
<ResourceDictionary Source="Base.xaml"></ResourceDictionary>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||||
|
|||||||
Reference in New Issue
Block a user