Sign in to follow this  

Managed/Unmanaged Problem... Help!

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, I am trying to wrap my C++ classes in Managed C++ so I can call them from C#, which works great for regular parameters (int, float), but when I define...
	public ref class Vector3
	{
	public:
		Vector3(float in_x, float in_y, float in_z) {x=in_x; y=in_y; z=in_z;}

		float x, y, z;
	};

	public ref class MCamera
	{
	private:
	public:
		MCamera(Vector3 in_source) {}
	};

and then try and call this from C# with...
            m_camera = new MCamera(new Vector3(0.0f, 0.0f, 0.0f));

I get the compile error... D:\Documents and Settings\rprice\My Documents\Visual Studio 2005\Projects\Terraformer4\Terraformer4\Form1.cs(40,24): error CS1501: No overload for method 'MCamera' takes '1' arguments The c++ assembly compiles find and the constructor looks good in the object browser for the assembly. Why is C# not recognizing this as having parameters? The following works fine in C# too...
            Vector3 test = new Vector3(0.0f, 0.0f, 0.0f);
            test.x = 1.0f;

I am really confused... help! Thanks Rael

Share this post


Link to post
Share on other sites
im not sure cause i havnt used managed c++ before but i think this

public ref class MCamera
{
private:
public:
MCamera(Vector3 in_source) {}
};

should be this

public ref class MCamera
{
private:
public:
MCamera(Vector3^ in_source) {}
};

so the compiler can distinguish passing a Vector3 (what ur code said) and a managed pointer to a Vector3 (what u do in the c# code).

Hope that helps

Share this post


Link to post
Share on other sites

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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