c# - Loading embedded resource on Windows 7 -


I have an app that works fine on my WinXP machine. However, when I try to run it on my Win7 machine, it still fails when it tries to load an embedded resource. Resources are all (I can see them using reflectors).

The rows that have failed are all forms:

  splash. Image = new bitmap (ContainerForm) .Assembly.GetManifestResourceStream ("SplashTest.Resources.Logo.gif"));  

and they all fail with the same exception:

  exception = 'System.ArgumentException: parameter is not valid. On the system Drawing Bitmap..cracker (stream stream)  

I do not understand why it is not working on my Win7 machine but it is on my normal WinXP dev machine.

Any thoughts?

There are not many possible failure modes: Assembly.GetManifestResourceStream () will receive zero if the resource is not found. This will fail with the exception shown by the Betamap constructor. In a bit of a bug, it was supposed to reduce the argument.

Anyhoo, it seems that for some reason the assembly has not been created with bitmap processing on your XP machine. Double-click on Double-Check Manifestation with Ildasm.exe, you will see .source for your name.

Better mouse trap, project + property, to add resources to the resource tab, click the arrow on the Add resource button, add an existing file, and navigate to the file. You can then reference the bitmap directly through the auto-generated property:

  Splash.Image = Properties.Resources.Logo;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -