question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not save Bitmap to MemoryStream

See original GitHub issue

Repro var img = new Bitmap(128, 128); using var ms = new MemoryStream(); img.Save(ms, ImageFormat.Png); StackTrace at WinFormsComInterop.WinFormsComWrappers.ComputeVtables(Object, CreateComInterfaceFlags, Int32&) + 0x1af at System.Runtime.InteropServices.ComWrappers.CreateCCW(Object, CreateComInterfaceFlags) + 0x39 at System.Runtime.InteropServices.ComWrappers.<>c__DisplayClass14_0.<GetOrCreateComInterfaceForObject>b__0(Object) + 0x1c at System.Runtime.CompilerServices.ConditionalWeakTable2.GetValueLocked(TKey, ConditionalWeakTable2.CreateValueCallback) + 0x2d at System.Runtime.CompilerServices.ConditionalWeakTable2.GetValue(TKey, ConditionalWeakTable2.CreateValueCallback) + 0x3e at System.Runtime.InteropServices.ComWrappers.GetOrCreateComInterfaceForObject(Object, CreateComInterfaceFlags) + 0xa8 at System.Runtime.InteropServices.ComWrappers.ComInterfaceForObject(Object, Guid) + 0xe at System.Drawing.SafeNativeMethods.Gdip.GdipSaveImageToStream(HandleRef, Interop.Ole32.IStream, Guid&, HandleRef) + 0xbd at System.Drawing.Image.Save(Stream, ImageCodecInfo, EncoderParameters) + 0x144 at Test.Program.Main() + 0x8f

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mrzaxaryancommented, Aug 2, 2021

Yes it works in normal and reflection-free mode

0reactions
kant2002commented, Aug 2, 2021

I update https://github.com/kant2002/NativeAOTImages to be more inline with changes. so my lib no longer needed. Let me know when you resolve issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Saving a bitmap into a MemoryStream
I planed to save the stream in my class during the work, but seems like I should save it only during the process...
Read more >
Could not save bitmap data to memory stream error
Hi there, I've got a project on which I work sometimes, and I'm now trying to build and debug it on Android. I'm...
Read more >
Bitmap To Memory Stream - CSharp System.Drawing
Description. Bitmap To Memory Stream. Demo Code. using System.Drawing; using System.IO;//from w w w . j av a 2 s .c om public...
Read more >
Unable to Load bitmap from Memory Stream · Issue #1290 ...
Easy to repro: var bitmap = new Bitmap("jpegfile.jpg"); var imgStream = new MemoryStream(); bitmap.Save(imgStream); var bitmapfromstream ...
Read more >
Can't save files on the desktop - Microsoft Q&A
I have tried a workaround , copying byte array from memory stream to file stream, but then the error is : System.UnauthorizedAccessException: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found