私のアプリケーションはいくつかのDLLに依存しています。私はそれらをすべてリソースに入れ、アプリケーションの起動時よりも、Webで見つけた方法を使用してそれらをロードします。
public static void LoadDllsFromResources()
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, a) =>
{
string dllName = a.Name.Contains(',')
? a.Name.Substring(0, a.Name.IndexOf(','))
: a.Name.Replace(".dll", "");
dllName = dllName.Replace(".", "_");
if (dllName.EndsWith("_resources")) return null;
System.Resources.ResourceManager rm =
new System.Resources.ResourceManager(
"DesktopDashboard" + ".Properties.Resources",
System.Reflection.Assembly.GetExecutingAssembly());
byte[] bytes = (byte[])rm.GetObject(dllName);
return System.Reflection.Assembly.Load(bytes);
};
}
WPFToolkitExtended.dllを追加しようとするまでは、問題なく動作しました。私のアプリよりもエラーがスローされます。このDLLが特別な理由は何ですか?
System.Windows.Markup.XamlParseException:'SetconnectionIdが例外をスローしました。' 行番号「4」および行位置「37」。---> System.InvalidCastException:[A]Xceed.Wpf.Toolkit.BusyIndicatorを[B]Xceed.Wpf.Toolkit.BusyIndicatorにキャストできません。タイプAは、バイト配列のコンテキスト「LoadNether」の「WPFToolkit.Extended、Version = 1.7.4644.13122、Culture = neutral、PublicKeyToken=3e4669d2f30244f4」に由来します。タイプBは、バイト配列のコンテキスト「LoadNether」の「WPFToolkit.Extended、Version = 1.7.4644.13122、Culture = neutral、PublicKeyToken=3e4669d2f30244f4」に由来します。DesktopDashboard.LogoutWindow.System.Windows.Markup.IComponentConnector.Connect(Int32 connectionId、Object target)at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetConnectionId(Object root、
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback、Object args、Int32 numArgs)at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source、Delegate method、Object args、Int32 numArgs、Delegate catchHandler)at System.Windows .Threading.DispatcherOperation.InvokeImpl()at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)at System.Threading.ExecutionContext.runTryCode(Object userData)at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code、CleanupCode backoutCode 、Object userData)at System.Threading.ExecutionContext.RunInternal(ExecutionContextexecutionContext、ContextCallback callback、Object state)at System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext、System.Windows.Threading.DispatcherOperation.Invoke()at System.Windows.Threading.Dispatcher.ProcessQueue( )at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr lParam、Boolean&handled)at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd、Int32 msg、IntPtr wParam、IntPtr )at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback、Object args、Int32 numArgs)at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source、Delegate method、オブジェクト引数、Int32 numArgs、Delegate catchHandler)at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority、TimeSpan timeout、Delegate method、Object args、Int32 numArgs)at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd、Int32 msg、IntPtr IntPtr lParam)at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG&msg)at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)DispatchMessage(MSG&msg)at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)DispatchMessage(MSG&msg)at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
System.Windows.Application.RunDispatcher(オブジェクト無視)at System.Windows.Application.RunInternal(ウィンドウウィンドウ)at System.Windows.Application.Run(ウィンドウウィンドウ)at System.Windows.Application.Run()at DesktopDashboard.App .Main(String [] args)