C# 是否在.NET 4.0服务上加载程序集4.5?

C# 是否在.NET 4.0服务上加载程序集4.5?,c#,.net,wpf,windows,C#,.net,Wpf,Windows,我在.NET4.0中有一个服务。(C#)并且我需要加载.NET4.5中编码的新程序集。使用方法调用(Methodinfo/Reflection),服务会显示以下错误消息:“调用目标已引发异常。”在InnerException中,我得到了“System.TypeInitializationException:“System.Windows.FrameworkElement”的类型初始值设定项引发了异常。“有人能帮我吗?” -->异常消息: 调用的目标已引发异常。 -->完成内部异常:System.

我在.NET4.0中有一个服务。(C#)并且我需要加载.NET4.5中编码的新程序集。使用方法调用(Methodinfo/Reflection),服务会显示以下错误消息:“调用目标已引发异常。”在InnerException中,我得到了“System.TypeInitializationException:“System.Windows.FrameworkElement”的类型初始值设定项引发了异常。“有人能帮我吗?”

-->异常消息: 调用的目标已引发异常。 -->完成内部异常:System.TypeInitializationException:“System.Windows.FrameworkElement”的类型初始值设定项引发了 异常。-->System.TypeInitializationException:类型 “System.Windows.Media.Transform”的初始值设定项引发异常。 --->System.ComponentModel.Win32异常:操作在MS.Win32.HwndWrapper..ctor(Int32类样式,Int32)上成功完成 样式,Int32 exStyle,Int32 x,Int32 y,Int32宽度,Int32高度, 字符串名称,IntPtr父级,HwndWrapperHook[]钩子)位于 System.Windows.Threading.Dispatcher..ctor()位于 System.Windows.DependencyObject..ctor()位于 System.Windows.Media.Transform..cctor()---内部异常结束 堆栈跟踪---位于System.Windows.FrameworkElement..cctor()处--- 内部异常堆栈跟踪的结束---at System.Windows.Controls.UserControl..cctor()


找到了一些引用:

该服务对于WPF代码来说绝对不是一个愉快的家。看到GetStockObject()失败是非常不寻常的,如此不寻常以至于Microsoft从未发现中断的异常报告。这导致了愚蠢的“操作成功完成”“留言。再说一次,服务从来都不是GUI代码的适当归宿。