์ด๊ฒ์ด ๋ฒ๊ทธ์ธ์ง ์๋๋ฉด ๊ตฌํ๋์ง ์์ ๊ฒ์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
ํ ๋ฒ์ .Net ํ๋ ์์ํฌ์, ํ ๋ฒ์ UWP ํ๋ ์์ํฌ์ "Type" ์ ํ์ ์์ฑ์ด ์๋ ํด๋์ค๊ฐ ์์ต๋๋ค.
ํ์์ ํ์์ AssemblyQualifiedName ์์ฑ์ ์ฌ์ฉํ์ฌ ์ง๋ ฌํ๋ฉ๋๋ค.
๋ฐ๋ผ์ .Net ํ๋ ์์ํฌ์์ ์ง๋ ฌํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋ํ๋ฉ๋๋ค.
"System.EventArgs, mscorlib, ๋ฒ์ =4.0.0.0, ๋ฌธํ๊ถ=์ค๋ฆฝ, PublicKeyToken=b77a5c561934e089"
JsonConver.DeserializeObject๋ฅผ ์ฌ์ฉํ์ฌ UWP ์์ฉ ํ๋ก๊ทธ๋จ์์ ์ด๊ฒ์ ์ญ์ง๋ ฌํํ๋ฉด ์ ์ ํ Type ๊ฐ์ฒด๊ฐ ์์ฑ๋ฉ๋๋ค. ์ด๊ฒ์ UWP์์ ์ง๋ ฌํํ๋ฉด ๋ค์ ๋ฌธ์์ด์ด ์์ฑ๋ฉ๋๋ค.
"System.EventArgs, System.Private.CoreLib, ๋ฒ์ = 4.0.0.0, ๋ฌธํ = ์ค๋ฆฝ, PublicKeyToken = 7cec85d7bea7798e"
.Net ํ๋ ์์ํฌ ์ ํ๋ฆฌ์ผ์ด์
์์ ์ด๊ฒ์ ์ญ์ง๋ ฌํํ๋ ค๊ณ ํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
""System.EventArgs, System.Private.CoreLib, ๋ฒ์ = 4.0.0.0, ๋ฌธํ = ์ค๋ฆฝ, PublicKeyToken = 7cec85d7bea7798e" ๊ฐ์ 'System.Type' ํ์์ผ๋ก ๋ณํํ๋ ๋์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค."
๋ฉ์์ง๋ ๋์๊ฒ ๋ช ํํ์ง๋ง ์ ๋ค๋ฅธ ๋ฐฉํฅ์ผ๋ก ์๋ํ๋์ง ์์ํ์ง ๋ชปํ ๊ฒ์ ๋๋ค. ์ด๊ฒ์ UWP ๋ฒ์ ์ด ๋ ์ต์ ์ด๊ณ ์ด ๋ณํ์ ์ฒ๋ฆฌํ ์ ์๋ค๋ ์ฌ์ค ๋๋ฌธ์ ๋๊น, ์๋๋ฉด ๋ฒ๊ทธ์ ๋๊น?
์ ํ ์ด๋ฆ์ ์ฌ์ฉํ์ฌ ์๋ก ๋ค๋ฅธ ํ๋ ์์ํฌ๋ฅผ ์ง๋ ฌํํ๋ ๊ฒ์ ๋ถํํ๋ ๋งค์ฐ ์ด๋ ค์ด ๋ฌธ์ ์
๋๋ค. https://apisof.net/catalog/System.EventArgs ๋ฅผ ๊ฐ๋จํ ์ดํด๋ณด๋ฉด System.EventArgs
๊ฐ ์ฌ๋ฌ ๋ค๋ฅธ ์ด์
๋ธ๋ฆฌ์ ์ ์๋์ด ์๊ณ ๊ทธ ์ค ์ผ๋ถ๊ฐ System.Private.CoreLib
์ ๊ฐ์ ๊ฐ์ธ ์ด์
๋ธ๋ฆฌ์ ํ์ ์ ๋ฌ๋๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค. "System.EventArgs, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
๋ฅผ ํ์ฉํ ์ ์๋ ์ด์ ๋ ๋ชจ๋ ์ ํ์ UWP์ ๋ํ ์ ์ ํ ์ด์
๋ธ๋ฆฌ๋ก ํ์ ์ ๋ฌํ๋ mscorlib
ํ์ฌ๋ ์ด์
๋ธ๋ฆฌ๊ฐ ์๊ธฐ ๋๋ฌธ์
๋๋ค.
์ด์ ๋ํ ํด๊ฒฐ์ฑ
์ด ๋ฌด์์ธ์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋ค์ํ ์์คํ
์ ํ ์ด๋ฆ์ ๋ฐํ์ ํ๋ ์์ํฌ์ ๋ํ ์ ์ ํ ์ ํ์ ๋งคํํ๊ธฐ ์ํด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์์ฑํ ์ ์๊ณ SerializationBinder
๊ฐ ํด๋น ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค.
๊ณ ์ ํ ISerializationBinder๋ฅผ ๊ตฌํํฉ๋๋ค. ๊ทธ๊ฒ์ผ๋ก ์ ํ ์ด๋ฆ์ ์์ฑ ๋ฐ ์ฒ๋ฆฌ๋ฅผ ์ฌ์ฉ์ ์ ์ํ ์ ์์ต๋๋ค.
์ฌ์ฉ์ ์ง์ ISerializationBinder๋ก ์ฝ๊ฒ ๋ณํ๋์ง ์๋ ๋๊ท๋ชจ ์ฝ๋ ๊ธฐ๋ฐ์ ๊ฒฝ์ฐ
๋ฆฌ๋๋ ์
์ ๊ตฌํํ์ต๋๋ค(์์์ง๋ ์์ง๋ง ์๋ํฉ๋๋ค).
RedirectAssembly("System.Private.CoreLib", "mscorlib");
public static void RedirectAssembly(string fromAssemblyShotName, string replacmentAssemblyShortName)
{
Console.WriteLine($"Adding custom resolver redirect rule form:{fromAssemblyShotName}, to:{replacmentAssemblyShortName}");
ResolveEventHandler handler = null;
handler = (sender, args) =>
{
// Use latest strong name & version when trying to load SDK assemblies
var requestedAssembly = new AssemblyName(args.Name);
Console.WriteLine($"RedirectAssembly > requesting:{requestedAssembly}; replacment from:{fromAssemblyShotName}, to:{replacmentAssemblyShortName}");
if (requestedAssembly.Name == fromAssemblyShotName)
{
try
{
Console.WriteLine($"Redirecting Assembly {fromAssemblyShotName} to: {replacmentAssemblyShortName}");
var replacmentAssembly = Assembly.Load(replacmentAssemblyShortName);
return replacmentAssembly;
}
catch (Exception e)
{
Console.WriteLine($"ERROR while trying to provide replacement Assembly {fromAssemblyShotName} to: {replacmentAssemblyShortName}");
Console.WriteLine(e);
return null;
}
}
Console.WriteLine($"Framework faild to find {requestedAssembly}, trying to provide replacment from:{fromAssemblyShotName}, to:{replacmentAssemblyShortName}");
return null;
};
AppDomain.CurrentDomain.AssemblyResolve += handler;
}
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ฌ์ฉ์ ์ง์ ISerializationBinder๋ก ์ฝ๊ฒ ๋ณํ๋์ง ์๋ ๋๊ท๋ชจ ์ฝ๋ ๊ธฐ๋ฐ์ ๊ฒฝ์ฐ
๋ฆฌ๋๋ ์ ์ ๊ตฌํํ์ต๋๋ค(์์์ง๋ ์์ง๋ง ์๋ํฉ๋๋ค).