System.Drawing.Icon构造投掷"操作已成功&QUOT完成;例外 [英] System.Drawing.Icon constructor throwing "Operation completed successfully" exception

查看:645
本文介绍了System.Drawing.Icon构造投掷"操作已成功&QUOT完成;例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows XP计算机,以下code是扔System.ComponentModel.Win32Exception的消息已成功完成的操作

On a Windows XP machine, the following code is throwing a System.ComponentModel.Win32Exception with the message "The operation completed successfully"

System.Drawing.Icon icon = new System.Drawing.Icon("icon.ico");

我可以停止该程序与崩溃

I can stop the program crashing with

try
{
    System.Drawing.Icon icon = new System.Drawing.Icon("icon.ico");
}
catch(System.ComponentModel.Win32Exception ex)
{
    if (ex.NativeErrorCode != 0)
    {
        throw;
    }
}

但当然的图标不设置。

but of course the icon is not set.

完整的堆栈跟踪

at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at System.Drawing.Icon..ctor(String fileName, Int32 width, Int32 height)
at System.Drawing.Icon..ctor(String fileName)
at hermes.Window1..ctor() in D:\\projects\\hermesclient\\hermesWPF\\hermes\\Window1.xaml.cs:line 50"

这行50是原线我张贴。

That line 50 is the original line I posted.

这是一个WPF应用程序,并在Windows 7计算机上code正常工作。

This is a WPF app, and on a Windows 7 machine the code works fine.

编辑:原来的图标不工作在Windows XP中所有,加入256色版本似乎已经固定它

Turned out the icon wasn't working in Windows XP at all, adding 256 colour versions seems to have fixed it.

推荐答案

原来的图标不工作在Windows XP中所有,加入256色版本,似乎已经解决了。

Turned out the icon wasn't working in Windows XP at all, adding 256 colour versions seems to have fixed it.

这篇关于System.Drawing.Icon构造投掷"操作已成功&QUOT完成;例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆