Error Unity Web build (System.Runtime.InteropServices.ComTypes.IStream)

Hey everyone,

I’m intern working for municipality as programmer, sow mij knowledge of c# has its limits.
I have a problem with my Web build. I’m downloading a “.gif” from (http://xml.buienradar.nl/icons/p.gif) witch is provided bij xml document(http://xml.buienradar.nl/) basically there weather icons I can yous for my (UI).
In the Standalone (Platform) it works as it should with the addition of (System.Drawing & System.Xml.Linq) , but wen I build it for web player the icon does not appear.

Unity web build with Script Debugging gives log error

I added “mscorlib” but that dint work.
I look for solution but dint find one.
I need someone to point me in the right direction.
Is it a security problem with web build witch dos not allow me to use this class.
Is it a problem with the way I download the .gif, or that the steam method attempted to read past the end of the stream.

Link to code I used to convert byte´s to a texture, (Converting GIF from Downloaded Byte Array to JPEG - Questions & Answers - Unity Discussions)

public IEnumerator WeerBerichtIcon()
    {
        string urlIcon = infoXml[6];
        Debug.Log(urlIcon);
        WWW iconwww = new WWW(urlIcon);
        yield return iconwww;
        byte[] ab = iconwww.bytes;
        byte[] pngBytes;
        using (var gifStream = new MemoryStream(ab))
        using (var image = Bitmap.FromStream(gifStream))
        using (var pngStream = new MemoryStream())
        {
            image.Save(pngStream, ImageFormat.Png);
            pngBytes = pngStream.ToArray();
        }
        tex = new Texture2D(Screen.width /2, Screen.height/2, TextureFormat.RGB24, false);
        tex.LoadImage(pngBytes);
        guitexture = tex;
        iconLoaded = true;
    }

I used openoffice to “auto-correct” hope its readable.

The issue I see here is that the WebPlayer .NET library doesn’t include the System.Runtime.InteropServices.ComTypes namespace, which is what the System.Drawing.Bitmap.FromStream class member seems to be trying to use internally. One of the replies in your Unity Answers link confirms that this method unfortunately does not work in the WebPlayer.

After a bit of searching I couldn’t find any examples for loading/converting gifs that didn’t fall back onto the System.Drawing classes. Your best bet might be to take a look at something on the asset store, perhaps this. Alternatively you can do some more searching and see if you can’t find a .NET library that doesn’t work off System.Drawing.

System.Drawing class works in Webplayer I use it to draw other textures on my GUI. Haven’t had error or problems.
Also don’t need to display it as a .gif on GUI. Just want a (png) from it.
The WWW class only allows the downloading of (jpg or png) thats wy I wanted to download the .gif as bytes. Later converting it to a png.

Example
Stand Alone Version

Web Build

The “sun” is the .gif converted to a 2D texture. (GUI.DrawTexture), the compass and the arrow pointing downwards are also drawn on the GUI, they work fine.
Ill do some more research on .Net library and so on. If i find a solution to my problem ill post it here.
Ty Kalekin

Bitmap might be in System.Drawing but FromStream takes an IStream as an argument which is in InteropServices.