' System.DateTimeOffset'来自assembly&#m; mscorlib,版本= 2.0.0.0

时间:2011-01-25 21:06:00

标签: winforms datetimeoffset

我的Windows窗体应用程序(使用C#在Visual Studio 2008中创建)分布在我们公司,可在50多台PC上运行,没有任何问题。

昨天,我不得不在运行WinXP的旧PC上安装它。我的Visual Studio 2008安装项目提示安装.Net Framework 3.5 SP1。我们安装了它,重新启动,然后继续安装。

安装完成后,我关掉旧机器,等了大约5秒钟,然后重新打开。

当我尝试运行应用程序时,我遇到了Unhandled异常:“无法从程序集'mscorlib加载类型'System.DateTimeOffset',Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5 ......等等,等等,等等。

Screen Shot of error

  1. 为什么3.5 SP1没有安装DateTimeOffset功能?

  2. 为什么应用程序会尝试从mscorlib version 2.0加载

  3. 我搜索了关键字DateTimeOffset,但它在我的项目中的任何位置都不存在。这是DateTime(即DateTime.Now.AddDays(1))的一部分吗?

  4. 以下是完整例外情况的副本:

       See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.TypeLoadException: Could not load type 'System.DateTimeOffset' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
       at System.ComponentModel.ReflectTypeDescriptionProvider.get_IntrinsicTypeConverters()
       at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetConverter(Object instance)
       at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetConverter()
       at System.ComponentModel.TypeDescriptor.GetConverter(Type type)
       at System.Windows.Forms.ListControl.GetItemText(Object item)
       at System.Windows.Forms.ComboBox.NativeAdd(Object item)
       at System.Windows.Forms.ComboBox.OnHandleCreated(EventArgs e)
       at System.Windows.Forms.Control.WmCreate(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ComboBox.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.42 (RTM.050727-4200)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Suite
        Assembly Version: 2.2.21.30536
        Win32 Version: 2.2.21
        CodeBase: file:///C:/Program%20Files/Aaon%20Coil%20Products,%20Inc/ACP%20Software%20Suite/Suite.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.42 (RTM.050727-4200)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Core
        Assembly Version: 3.5.0.0
        Win32 Version: 3.5.30729.1 built by: SP
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    Accessibility
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
    ----------------------------------------
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.42 (RTM.050727-4200)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    AcpFormHeader
        Assembly Version: 1.0.5.0
        Win32 Version: 1.0.5
        CodeBase: file:///C:/Program%20Files/Aaon%20Coil%20Products,%20Inc/ACP%20Software%20Suite/AcpFormHeader.DLL
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.42 (RTM.050727-4200)
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    
        
    
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.
    
    

3 个答案:

答案 0 :(得分:2)

Win32 Version: 2.0.50727.42 (RTM.050727-4200)

安装过程中出现严重错误。版本42是最初的.NET 2.0版本。跟踪还显示2.0.50727.3053,这是一个很好的。目前,该机器具有组装版本的混合匹配。确实有例外。当然不知道这是怎么发生的,我猜测在现有2.0安装的基础上安装了糟糕的3.5。或者您忘记在安装后重启机器。

答案 1 :(得分:1)

  1. 好问题。安装似乎有问题。
  2. 因为.NET 3.5使用2.0运行时,.NET 3.0也是如此。
  3. 不,不是。它是一个完全独立的结构(参见MSDN)。必须有一些 使用它的组件,可能是第三方组件。

答案 2 :(得分:1)

我今天遇到了同样的问题。我以这种方式在DataVisualization.Charting.Series中插入值

MaSerie.Points.AddXY(x, y)

我为此更改了代码,并且DateTimeOffset错误消失了

MaSerie.Points.Add(New DataVisualization.Charting.DataPoint(x, y))