Jump to content

  • Log In with Google      Sign In   
  • Create Account


Stuck on "The type arguments for method cannot be inferred from the usage" error.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 CdrTomalak   Members   -  Reputation: 272

Like
0Likes
Like

Posted 02 September 2012 - 01:07 PM

I'm scratching my head over trying to implement some code to share textures between D3D10 and D3D11 in SlimDX.
This method is causing the problem:

[source lang="csharp"] public void InitialiseTextureSharing() { // A DirectX10 Texture2D sharing the DirectX11 Texture2D sharedResource = new SlimDX.DXGI.Resource(textureD3D11); textureD3D10 = device10_1.OpenSharedResource(sharedResource.SharedHandle); // This fails to compile! }[/source]

I get the following error from the compiler:

The type arguments for method 'SlimDX.Direct3D10.Device.OpenSharedResource<T>(System.IntPtr)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

The wierd thing (to me) is, this code is being ported straight from someone elses which is supposed to work. The original code is:
[source lang="csharp"] // A DirectX10 Texture2D sharing the DirectX11 Texture2D SlimDX.DXGI.Resource sharedResource = new SlimDX.DXGI.Resource(textureD3D11); SlimDX.Direct3D10.Texture2D textureD3D10 = device10_1.OpenSharedResource(sharedResource.SharedHandle);[/source]

The difference with my implementation is I am instantiating the 'sharedResource' and 'textureD3D10' objects in the SlimDX Form.

I certainly didn't expect a compilation error. The code I am basing this on is from: http://www.aaronblog.us/?p=36
... which is all about drawing text in SlimDX with DX11.

I'm totally stumped on this. I've had a look at posts which contain solutions to similar issues, but adapting this to mine is beyond me at present.
Any pointers would be uber-appreciated.

UPDATE:
Signature of OpenSharedResource from SlimDX API docs:
http://slimdx.org/docs/html/M_SlimDX_Direct3D11_Device_OpenSharedResource__1.htm
... and Resource:
http://slimdx.org/docs/html/T_SlimDX_DXGI_Resource.htm

Edited by CdrTomalak, 02 September 2012 - 03:31 PM.


Sponsor:

#2 Mike.Popoloski   Crossbones+   -  Reputation: 2901

Like
1Likes
Like

Posted 03 September 2012 - 12:23 AM

You need to provide the type argument for the method call. This is standard C#; a generic method that doesn't take a parameter with a generic type can't infer the types automatically. Return values aren't enough for inference. So your call should look like:

OpenSharedResource<Texture2D>(sharedResource.SharedHandle);
Mike Popoloski | Journal | SlimDX

#3 CdrTomalak   Members   -  Reputation: 272

Like
0Likes
Like

Posted 03 September 2012 - 03:11 PM

Cheers Mike. This did the trick!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS