Problem inheriting managed C++ from C#

G

Guest

Hi.

I have an interface written in managed C++. I try to implement the interface
in C#. I try to override the function, but the compiler says no suitable
function can be found to override. If I remove this function the compiler
complains that it is not implemented. The code is below. I can implement the
interface both from within the original assembl and from a managed C++
assembly. Any ideas about what might be going on?

The c++ code:

#pragma once

#include "ProfileWrapper.h"
#include "ProfileSlab.h"
using namespace System;
namespace ReflectometryModelNative
{
public interface class IProfileConverter
{
public:
System::Int32 ConvertProfile(System::Int32 originalProfile);

};
}


the c# code:

public class MockProfileConverter :
ReflectometryModelNative.IProfileConverter
{
public MockProfileConverter()
{
}
public override int ConvertProfile(int a)
{
return a;
}
}
 
X

xiaodao

I have the same problem with you, but a bit differenet.

look my code:
C++:
using namespace System;

namespace CodeLibrary
{
public __gc class Class1Specify
{
// TODO: Add your methods for this class here.
};

public __gc __interface IPRo{
void dis();
};
}

C#:
public class CodeLibrarySub : CodeLibrary.IPRo
{
public void dis()
{
Console.Write("skdf");
}
}

your interface define does not work in my project, but I know its
correct from MSDN, confused:(!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top