Hi,
To reproduce my problem I have created a solution with 4 projects:
1) CalledCpp - a cpp managed dll
2) CallerCpp - a cpp managed console project that depends on CalledCpp
3) CallerVB - a vb console project that depends on CalledCpp
4) CallerCS - a csharp console project that depends on CalledCpp
The main file of CalledCpp (CalledCpp.cpp) contains this code:
#include "stdafx.h"
#include "CalledCpp.h"
#define USE_INTERFACE
namespace CalledCpp
{
public interface class IoInterface
{
#if defined(USE_INTERFACE)
void read();
#endif
};
public ref class MyBase abstract : IoInterface
{
public:
static MyBase^ Create();
#if !defined(USE_INTERFACE)
virtual void read() abstract;
#endif
};
public ref class Derived : MyBase
{
public:
void read();
};
MyBase^ MyBase::Create()
{
return gcnew Derived();
}
void Derived::read()
{
System::Console::WriteLine("Derived::Read()");
}
}
/////////////////
The main file of CallerCpp (CallerCpp.cpp) contains this code:
#include "stdafx.h"
using namespace System;
int main()
{
CalledCpp::MyBase^ bas = CalledCpp::MyBase::Create();
bas->read();
}
////////////////
The main file of CallerCS (Program.cs) contains this code:
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
#endregion
namespace CallerCS
{
class Test
{
static void Main(string[] args)
{
CalledCpp.MyBase bas = CalledCpp.MyBase.Create();
bas.read();
}
}
}
//////////////////////////////
The main file of CallerVB (Module1.vb) contains this code:
Module Module1
Sub Main()
Dim bas As CalledCpp.MyBase = CalledCpp.MyBase.Create()
Call bas.read()
End Sub
End Module
////////////////////////////////////
Now, CallerCpp, CallerCS and CallerVB have a project reference to CalledCpp.
If I perform a RebuildAll only CallerCpp builds fine while CallerVB and
CallerCS build return the same error:
error CS0117: 'CalledCpp.MyBase' does not contain a definition for 'read'
If I undefine USE_INTERFACE all works fine.
TIA for any help.
Marco.
--
For direct reply change underscore to dot