B
Bruce
I am using VC .NET 2003.
I created a simple unmanaged class in C++. The class is contained in a
library.
I then created a simple managed class wrapper that calls a function in
the unmanaged class. I am getting a System.NullReferenceException when
instantiating the unmanaged class. What is causing this error?
Unmanaged code:
class TestClass
{
public:
TestClass(void);
~TestClass(void);
int RetunTest(void);
};
TestClass::TestClass(void)
{
}
TestClass::~TestClass(void)
{
}
int TestClass::RetunTest(void)
{
return 10;
}
Managed Code:
#include "D:\Data\My Projects\VC\test\TestClass.h"
using namespace System;
namespace ManagedTest
{
public __gc class Class1
{
// TODO: Add your methods for this class here.
public:
Class1()
{
c = new TestClass(); //Error is occurring on this line
}
int CallUnmanged(void)
{
int x = c->RetunTest();
return x;
}
private:
TestClass *c;
};
}
I created a simple unmanaged class in C++. The class is contained in a
library.
I then created a simple managed class wrapper that calls a function in
the unmanaged class. I am getting a System.NullReferenceException when
instantiating the unmanaged class. What is causing this error?
Unmanaged code:
class TestClass
{
public:
TestClass(void);
~TestClass(void);
int RetunTest(void);
};
TestClass::TestClass(void)
{
}
TestClass::~TestClass(void)
{
}
int TestClass::RetunTest(void)
{
return 10;
}
Managed Code:
#include "D:\Data\My Projects\VC\test\TestClass.h"
using namespace System;
namespace ManagedTest
{
public __gc class Class1
{
// TODO: Add your methods for this class here.
public:
Class1()
{
c = new TestClass(); //Error is occurring on this line
}
int CallUnmanged(void)
{
int x = c->RetunTest();
return x;
}
private:
TestClass *c;
};
}