C# Image.Clone to byte[] 导致 EDIT.COM 在 Windows XP 上打开

发布于 2024-08-25 00:54:51 字数 1117 浏览 6 评论 0原文

克隆图像并将其转换为字节数组似乎导致 EDIT.COM 在 Windows XP 计算机上打开。在 Windows 7 计算机上不会发生这种情况。该应用程序是 C# .NET 2.0 应用程序。有谁知道为什么会发生这种情况?

这是我的图像转换代码:

        public static byte[] CovertImageToByteArray(Image imageToConvert)
    {
        imageToConvert.Clone() as Image;

        if(clone == null)
            return null;

        imageToConvert.Dispose();

        byte[] imageByteArray;
        using (MemoryStream ms = new MemoryStream())
        {
            clone.Save(ms, clone.RawFormat);
            imageByteArray = ms.ToArray();
        }

        return imageByteArray;
    }


    public static Image ConvertByteArrayToImage(byte[] imageByteArray,
                                                ImageFormat formatOfImage)
    {
        Image image;

        using (
            MemoryStream ms = new MemoryStream(imageByteArray, 0,
                                               imageByteArray.Length))
        {
            ms.Write(imageByteArray, 0, imageByteArray.Length);
            image = Image.FromStream(ms, true);
        }

        return image;
    }

谢谢

贾斯汀

It appears that cloning a Image and converting it to a byte array is causing EDIT.COM to open up on Windows XP machines. This does not happen on a Windows 7 machine. The application is a C# .NET 2.0 application. Does anyone have any idea why this may be happening?

Here is my Image conversion code:

        public static byte[] CovertImageToByteArray(Image imageToConvert)
    {
        imageToConvert.Clone() as Image;

        if(clone == null)
            return null;

        imageToConvert.Dispose();

        byte[] imageByteArray;
        using (MemoryStream ms = new MemoryStream())
        {
            clone.Save(ms, clone.RawFormat);
            imageByteArray = ms.ToArray();
        }

        return imageByteArray;
    }


    public static Image ConvertByteArrayToImage(byte[] imageByteArray,
                                                ImageFormat formatOfImage)
    {
        Image image;

        using (
            MemoryStream ms = new MemoryStream(imageByteArray, 0,
                                               imageByteArray.Length))
        {
            ms.Write(imageByteArray, 0, imageByteArray.Length);
            image = Image.FromStream(ms, true);
        }

        return image;
    }

Thanks

Justin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的背包 2024-09-01 00:54:51

在这里,如果不猜测就很难提供帮助,所以我们开始:

在代码中的某个位置,您或外部库依赖/调用名为“edit.exe”的外部工具。也许,上帝保佑,甚至数据库中会触发一些东西。程序员不关心扩展名,在Process.StartInfo中写了“edit foo.bar”。
由于您的 PATH 和解析顺序(com 在 exe 之前),最终会在附带的计算机上调用 edit.com。

好吧 - 这实际上只是一个人为的故事,但我无法想象使用您给出的代码启动任何应用程序的方法。尝试确定发生这种情况的确切位置。我怀疑这是您显示的转换/代码。

It's hard to help without guessing here, so here we go:

Somewhere in your code you or an external library relies on/calls an external tool, called "edit.exe". Maybe, god forbid, even something triggered in the database. The programmer didn't care about the extension, wrote "edit foo.bar" in the Process.StartInfo.
Because of your PATH and the order of resolution (com before exe) this ends up calling edit.com on machines that come with it.

Well - this is really nothing but an artificial story, but I cannot imagine a way of launching any app with the code you've given. Try to be sure about the exact place where this happens. I doubt that it is the conversion/the code you showed.

春风十里 2024-09-01 00:54:51

经过大量挖掘后,发现 DevExpress 的 HyperLinkEdit 发生了一些奇怪的事情。文本值设置为“编辑”。我将其重命名为“Edet”,问题就消失了。我将向 DevExpress 报告此事以进行进一步评估。

谢谢大家,

贾斯汀

After a lot of digging it turns out to be something strange going on with a HyperLinkEdit from DevExpress. The Text value was set to "Edit". I renamed it to "Edet" and the issue went away. I will be reporting this to DevExpress for further evaluation.

Thanks everyone,

Justin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文