0

I am trying to calculate normal map and bump map of some images. In order to do this, I am using Craig's Utility Library. However when I try to create bump map I am getting an exception saying

"VerificationException was unhandled : Operation could destabilize the runtime".

How can I solve this? The code throws exception in second line (it throws the same exception for normal map too, but this one comes first):

        BumpMap bumpMap = new BumpMap();
        pic = bumpMap.Create(pic);
ChrisF
  • 134,786
  • 31
  • 255
  • 325
user1125953
  • 585
  • 2
  • 7
  • 18

1 Answers1

1

That sort of of error usually happens when doing meta-programming (via something like ILGenerator), and getting it wrong; for example, issuing a "call" when a "callvirt" was needed, or borking the stack. It sounds to me like simply: a bug in the library. So report it to the author, or investigate it and fit it yourself.

It is technically also possible that the C# compiler has a bug and is emitting the wrong code, but that seems relatively unlikely.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • I don't think it is because of a bug in the library. I want to search about meta-programming thing. Thank you. – user1125953 Jan 10 '12 at 09:34
  • @user1125953 why don't you think it is a bug in the library? a method call **doesn't work**: library bug! (my guess is that the library is using some meta-programming internally, and: has a bug; that's OK - it happens; the author just adds a unit test, fixes it, and carries on) – Marc Gravell Jan 10 '12 at 09:36
  • It may be of course. But I could't find anybody who experienced this error who are using this library. That's why I said so... – user1125953 Jan 10 '12 at 09:38
  • @user1125953 can you perhaps post the bits of the stacktrace that aren't specific to **your** code? – Marc Gravell Jan 10 '12 at 09:46
  • Actually, I don't know how to do that sorry – user1125953 Jan 10 '12 at 10:53
  • I think I found what you said :) top 3 lines of stacktrace look like : at Utilities.Media.Image.ExtensionMethods.BitmapExtensions.GetPixel(BitmapData Data, Int32 x, Int32 y, Int32 PixelSizeInBytes) at Utilities.Media.Image.Filter.ApplyFilter(Bitmap Input) at Utilities.Media.Image.BumpMap.Create(Bitmap Image) – user1125953 Jan 10 '12 at 13:19
  • it seems like it is not able to get pixels or what? – user1125953 Jan 10 '12 at 13:21
  • @user1125953 right; now we're getting somewhere. Do you know what the pixel size is? 32-bit RGBA? 24-bit RGB? anything else? – Marc Gravell Jan 10 '12 at 13:30
  • it says PixelFormat = Format32bppArgb – user1125953 Jan 10 '12 at 13:31
  • @user1125953 basically, the code checks for 24-bit, and assumes anything else is 32-bit; another approach might be to try it with a different image... – Marc Gravell Jan 10 '12 at 13:32
  • hmmm... the pointer-arithmetic *should* be OK for that; if you have the library side-by-side, you could debug GetPixel - looking in particular Scan0 has a value; I also wonder whether the BitmapData is being used outside the LockBits - this is **definitely** a library bug (although, it transpires, nothing to do with meta-programmig). I trongly suggest filing it as a bug with the author, along with a full repro – Marc Gravell Jan 10 '12 at 13:35