Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Image.FromStream don';I don’我的新windows安装不能以同样的方式工作_C#_.net_Windows_.net 3.5_System.drawing - Fatal编程技术网

C# Image.FromStream don';I don’我的新windows安装不能以同样的方式工作

C# Image.FromStream don';I don’我的新windows安装不能以同样的方式工作,c#,.net,windows,.net-3.5,system.drawing,C#,.net,Windows,.net 3.5,System.drawing,我有一个测试,它以前在我的旧机器上工作。(Windows Vista Ultimate 32位) 在我的新机器(Windows7 64位)上,它不再工作了 我得到一个例外: System.ArgumentException : Parameter is not valid. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)

我有一个测试,它以前在我的旧机器上工作。(Windows Vista Ultimate 32位)

在我的新机器(Windows7 64位)上,它不再工作了

我得到一个例外:

System.ArgumentException : Parameter is not valid.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at Litium.Framework.Image.Test.ImageManagerTests.Can_get_Image_from_BMP_Stream()
如果我试着用这个,它会起作用

private static readonly byte[] TEST_GIF = new byte[]
    {
        0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x2, 0, 0x2, 0, 0x11, 0, 0, 0x2C, 0, 0
        , 0, 0, 0x2, 0, 0x2, 0, 0xA1, 0xFF, 0, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0,
        0x80, 0x2, 0x3, 0xC, 0x26, 0x5, 0, 0x3B
    };

为什么这在我的新机器上不起作用?

您是否尝试在末尾添加额外的0字节?我有一个很好的感觉

您是否尝试在末尾添加额外的0字节?我有一个很好的感觉

大头针丹尼尔!这很有帮助,但现在我将改为更简单的:私有静态只读字节[]TEST_BMP=File.ReadAllBytes(“TEST.BMP”):)不太冒险,但我会允许的。大头针丹尼尔!这很有帮助,但现在我将改为更简单的:私有静态只读字节[]TEST_BMP=File.ReadAllBytes(“TEST.BMP”):)不太冒险,但我允许。
private static readonly byte[] TEST_GIF = new byte[]
    {
        0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x2, 0, 0x2, 0, 0x11, 0, 0, 0x2C, 0, 0
        , 0, 0, 0x2, 0, 0x2, 0, 0xA1, 0xFF, 0, 0, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0,
        0x80, 0x2, 0x3, 0xC, 0x26, 0x5, 0, 0x3B
    };