Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Null reference exception under Windows 8.1 #222

Closed
pulse-matt opened this issue Dec 4, 2013 · 6 comments
Closed

Null reference exception under Windows 8.1 #222

pulse-matt opened this issue Dec 4, 2013 · 6 comments

Comments

@pulse-matt
Copy link

: System.NullReferenceException: Object reference not set to an instance of an object.
at SharpDX.ComObjectShadow.QueryInterfaceImpl(IntPtr thisObject, Guid& guid, IntPtr& output)
at SharpDX.ComObjectShadow.ComObjectVtbl.QueryInterfaceImpl(IntPtr thisObject, IntPtr guid, IntPtr& output)
at SharpDX.DirectWrite.TextLayout.Draw_(IntPtr clientDrawingContext, IntPtr renderer, Single originX, Single originY)
at SharpDX.DirectWrite.TextLayout.Draw(Object clientDrawingContext, TextRenderer renderer, Single originX, Single originY)

Under Windows 8.0 all is OK.
Using version 2.4.2 and 2.5.0 of SharpDX.

@ArtiomCiumac
Copy link
Contributor

Is there a sample project or a code fragment where the issue can be reproduced?

@pulse-matt
Copy link
Author

I was afraid you were going to ask. I'll see if I can put one together.

@pulse-matt
Copy link
Author

Here is a gist with a sample program: https://gist.github.com/pulse-matt/7796669

I'm using 2.5.0 of SharpDX "DirectX11_1-Signed-net40"

@pulse-matt
Copy link
Author

The above Gist runs OK in Windows 8. But crashes in Windows 8.1.

@xoofx
Copy link
Member

xoofx commented Dec 4, 2013

TextRenderer inherits from ICallbackBase which inherits from Dispose(). It is stated in the documentation that the Shadow object (stored in the property of ICallbackBase) should be disposed when disposing a ICallbackBase object, but in your implementation, you are not implementing correctly the Shadow property and not releasing it. You get a NullPointerException because of the Shadow is not stored and return null in any case. All samples in SharpDX that are using Direct2D callbacks are using CallbackBase.

Simply inherit from CallbackBase and TextRenderer and this should fix your issue.

@xoofx xoofx closed this as completed Dec 4, 2013
@pulse-matt
Copy link
Author

That fixed it. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants