sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

Access Violation (Read & Write) with BitmapSource and DataStream #957

Closed Skyppid closed 5 years ago

Skyppid commented 6 years ago

Crosslink to Stackoverflow: Here

Well to test the integration of DirectX 11 into my WPF application I have to render some image. As of late I do get some misterious exceptions at various locations. One is the following, where I just copied the code of an old sample of SharpDX on how to import PNG/JPEGs with WIC and convert them to a Texture2D object.

Whenever I try to call BitmapSource.CopyPixels(int, DataPointer) I get an exception. Either a read-access violation at 0xF...F (-1) or write-access violation at 0x0...8. For further information check out the Stackoverflow thread.

Exception thrown at 0x00007FF894ECA25C (combase.dll) in MyApp.exe: 0xC0000005: Access violation writing location 0x0000000000000008.

Exception thrown at 0x00007FF8825283BD (WindowsCodecs.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Here's the full code in chronological call-order: Source

For now my best guess is that there's something faulty in SharpDX's codebase. As said, I used the same code as in the sample. All projects of my solution use the latest 4.0.1 #DX libraries.

That's the sample I used: Link

EDIT: Tried to step into the code and check it out. Resulted in this exception:

Unhandled exception at 0x00007FF885D99474 (msvcr120_clr0400.dll) in MyApp.exe: Fatal program exit requested.

xoofx commented 6 years ago

You are likely disposing/destroying something that should not, so remove all dispose/destroy from your program and proceed from there

Gavin-Williams commented 6 years ago

This is the same code I use to build textures from a bitmap source, and it works for me. there must be something else that's wrong.

Have you resolved this issue? Can we close this?

Skyppid commented 6 years ago

You can close this meanwhile. The issue came up because of something else. I can't remember right now, but I think the problem was that I mixed up things and used the wrong device.