Click to See Complete Forum and Search --> : Managed class library


Vintersorg
December 16th, 2005, 02:50 AM
Hi.

I'm not very experienced with managed c++, but i'm trying to create a .NET library for later use in Visual Basic.

I have 2 problems:

1. I would like to use a class as return type, the dll will compile, but the function will not be accessible/visible in visual basicm if i change returntype to datetime or other standard .NET class it will work fine, but not with a class defined in my own namespace.

Namespace gfxEngine

public ref class SE_Camera
{

public:
void rotate(int x,int y, int z)
{

}
};

public ref class GfxEngine
{
public:
gfxEngine::SE_Camera createCamera()
{
SE_Camera Cam;
return Cam;
}
};

The method createCamera will not be visible.. If i use dateTime as type it will work fine. I know the code actually does nothing.. but to keep it simple..

2. The other problem appears if i want to expose the SE_Camera class in the GfxEngine class.. In a standard class i would do it this way:

class GfxEngine
{

public:
SE_Camera Cam;
}

It will compile if i do it the same way, but not be visible as a member in Visual Basic.

I've been searching the web for tutorials/code using managed class libraries, but can't really find what i'm looking for.

I'm using Visual C++ 2005.

NoHero
December 16th, 2005, 02:19 PM
Your Managed C++ syntax is completly wrong. I suggest you to get a good book on it!

namespace gfxEngine
{

public ref class SE_Camera
{
public:
void rotate(int x,int y, int z)
{

}
};

public ref class GfxEngine
{
public:
SE_Camera^ createCamera()
{
SE_Camera ^ Cam = gcnew SE_Camera;
return Cam;
}
};
}

Only value types are used without the ^ modificator, that's why DateTime - which is a value type - works.

Vintersorg
December 19th, 2005, 04:51 AM
Yeah, i figured it out during the weekend..

Didn't matter much though.. The whole idea was to make an interface to a unmanaged class.. But the unmanaged class can not be a private member of the ref-class...