操作系统:Windows XP SP2
开发环境:VS2003以前,设计时在Windows设计器中控件是Win2000风格的,不知道是改了什么设置,现在设计器中的控件总是XP风格的,生成的程序必须要启用XP风格,而且要DoEvents,否则无法正常加载有ImageList的窗体,但这样一来,在Win2000下加载窗体又会出错.以前可以运行的程序,只要在现在的VS中再编译出来的就无法运行.记得好像在设计器的控件风格发生改变的那段时间,好像安装过VAssistX插件.我猜想可能是VS2003在加载插件时在启用了System.Windows.Forms.Application.EnableVisualStyles(),导致设计器设计时控件已经是XP风格.我正在验证这个想法是否正确,也请各位高手关注及解答这个问题.实在不行就用最蠢也是肯定有效的方法:重新安装VS2003或重装系统 :(

解决方案 »

  1.   

    重装VS2003也是没用的!因为这些项目将不能被调试。
    Windows设计器也实现了XP主题是因为VS.IDE(..\Common7\IDE\devenv.exe)的目录下存在一个devenv.exe.manifest,如果删除它,重启VS.IDE就会恢复到Windows2000的主题,可是无法调试在支持XP主题时设计的窗体。所以你最好别去删除它!
    最好的解决办法(再次感谢Sunmast)是:
    不使用Application.EnableVisualStyles(),
    在项目生成目录(..\Bin\)添加一个YourApp.exe.manifest文件
      

  2.   

    多谢3tzjq(永不言弃)关注,按你的方法做了:
    不使用Application.EnableVisualStyles(),
    在项目生成目录(..\Bin\)添加一个YourApp.exe.manifest文件XP下运行没问题,Win2000下运行时加载有ImageList控件的窗体时仍会出错.
    请教这应该如何解决.
      

  3.   

    错误提示如下:See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Failed to load ImageList.
       at System.Windows.Forms.ImageListStreamer..ctor(SerializationInfo info, StreamingContext context)
       --- End of inner exception stack trace ---
       at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)
       at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)
       at System.Runtime.Serialization.ObjectManager.DoFixups()
       at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
       at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
       at System.Resources.ResourceReader.LoadObject(Int32 pos)
       at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
       at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture)
       at System.Resources.ResourceManager.GetObject(String name)
       at DbCtrl.DbToolBarB.InitializeComponent()
       at DbCtrl.DbToolBarB..ctor()
       at SolomonSale.FrmSale..ctor()
       at SolomonSale.FrmMDI.MimSale_Click(Object sender, EventArgs e)
       at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
       at System.Windows.Forms.MenuItemData.Execute()
       at System.Windows.Forms.Command.Invoke()
       at System.Windows.Forms.Control.WmCommand(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
    ----------------------------------------
    SolomonSale
        Assembly Version: 1.0.2060.30348
        Win32 Version: 1.0.2060.30348
        CodeBase: file:///D:/Roy/Solomon/Sale20050822_3/SolomonSale.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    ----------------------------------------
    System
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 7.0.5000.0
        Win32 Version: 7.10.3052.4
        CodeBase: file:///c:/winnt/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
    ----------------------------------------
    System.Data
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
    ----------------------------------------
    System.EnterpriseServices
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
    ----------------------------------------
    DbCtrl
        Assembly Version: 1.0.2060.30341
        Win32 Version: 1.0.2060.30341
        CodeBase: file:///D:/Roy/Solomon/Sale20050822_3/DbCtrl.DLL
    ----------------------------------------************** JIT Debugging **************
    To enable just in time (JIT) debugging, the config file for this
    application or machine (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:<configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the machine
    rather than being handled by this dialog.
      

  4.   

    不会啊!YourApp.exe.manifest文件的YourApp替换成你的可执行文件名了吗?
      

  5.   

    TO:3tzjq(永不言弃) ( ) 
    这个问题在Web下如何解决?
    我上次发了一个贴子,结果问题没有解决!
      

  6.   

    换了,在XP里可以,但在Win2000里运行时加载ImageList里就出错.
      

  7.   

    To: 3tzjq(永不言弃)按你的方法做了:
    不使用Application.EnableVisualStyles(),
    在项目生成目录(..\Bin\)添加一个我的程序文件名.exe.manifest文件这个方法已经生效,已经可以看到XP样式的控件.但老问题仍然没有解决: Win2000下运行时加载有ImageList控件的窗体时出错也试过将:YourApp.exe.manifest文件内的name="DevEnv.exe"改为"我的程序文件名.exe",在Main()方法中加入DoEvents(),但问题依旧.
      

  8.   

    TO:cdo(VC?我才刚学)
    怎样做?