Sign in to follow this  
Paul C Skertich

CreateVertexShader is returning with System.NullReferenceException.

Recommended Posts

When I build the Managed Assembly C++ file it compiles fine. In C# - where I'm designing the level editor is when the exception happens. Only if I don't comment out the part where it compile shader file. I looked at it carefully and the ID3D10Blob isn't placing anything because it shows up as
"Undefined Value" or perhaps the D3D11CompileFromFile isn't loading the HLSL file.

I'm using oldsyntax CLI for my custom Engine wrapper just to design the level in C#.

Here's a small snipplet.

[CODE]
namespace Engine {
namespace Shaders {

__gc public class Shader {

private:
LPCWSTR *shaderfile;

public:

Shader() {

}

void Load() {
// load and compile the two shaders
ID3D10Blob *VS, *PS;


D3DX11CompileFromFile((LPCWSTR)"basicShader.hlsl", 0, 0, "VShader", "vs_5_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile((LPCWSTR)"basicShader.hlsl", 0, 0, "PShader", "ps_5_0", 0, 0, 0, &PS, 0, 0);

// encapsulate both shaders into shader objects
dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);
dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);

....
[/CODE]

The error happens when

[CODE]
dev->CreateVertexShader(VS->GetBufferPoint(),....);
[/CODE]

when I hover my mouse over &pVS it shows up Undefined Value. I can only assume the Blobby isn't doing it's job.

It's not pain I like - it's only that it challenges me to think! :D

Share this post


Link to post
Share on other sites
What I've read the LPCTSTR that the D3DX11CompileFromFile uses is a const TCHAR *. So, I changed the part Load(const TCHAR *file) and it compiled file. However, when I enter C# this gives me there's a overloaded argument. I've been at this whole thing pretty much all day.

Share this post


Link to post
Share on other sites
I'm still cracking at it. When the program gives me the error after I change the ID3DBlob10 *VS to a __value ID3DBlob10. It returns that &PS can not obtain value. Additionally, it says PS - IUnknown. I'm assuming that IUnknown is a interface for DIrectX C++.

I just updated the engine C++ managed code and it compiles fine. In C# is giving me crap.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this