I have encapsultated old C/C++ code in a mixed mode C++ module (Project 2).
In my C# app (project 3) I instanciate a managed C++ class. The behaviour of
the C/C++ class is defined by an interface (Project 1). I wanted to add a
getter property to a multi dimension array, but the assembly loader keeps
telling me that the property is not implemented...
When I make a single dimensional array out of it, it works fine...
I added a simplified example of what I did below. Can anybody tell me how I
can get this working???
Thanx, Hans.
file 'IMyInterface.cs' (Project 1)
namespace MyNamespace
{
public interface IMyInterface
{
double[,] MyProperty {get;}
}
}
file 'MyImplementation.h' (Project 2, MyImplementation.cpp is omitted)
using namespace MyNamespace;
[assembly:System::CLSCompliant(true)];
namespace MyNamespace
{
public __gc class MyImplementation: public MyNamespace::IMyInterface
{
private:
double m_MyMember __gc [,];
public:
__property double get_MyProperty() __gc[,] {return m_MyMember;}
}
}
file 'MyApp.cs' (Project 3)
namespace MyNamespace
{
...
...
void MyMethod()
{
IMyInterface myInterface = new MyImplementation(); // causes an
exception...
// How can I get this working?
}
}

Signature
This posting is provided "AS IS" with no warranties, and confers no
rights."Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
>I have encapsultated old C/C++ code in a mixed mode C++ module (Project 2).
> In my C# app (project 3) I instanciate a managed C++ class. The behaviour
[quoted text clipped - 45 lines]
> }
> }
I cannot repro your behavior. Could it be that you are not referencing all
your assemblies. This is how verified your repro. I just renamed your
MyImplementation.h to MyImplementation.cpp.
csc /t:library IMyInterface.cs
cl /clr:oldSyntax /LD MyImplementation.cpp
csc /r:MyImplementation.dll /r:IMyInterface.dll MyApp.cs
RESULT: Successful compile with no exception ?
Thanks,
Kapil
Hans - 03 May 2005 07:00 GMT
The code compiles alright, but when debugging, the assembly loader throws
exception System.TypeLoadException:
"Method get_MyProperty in type MyNamespace.MyImplementation from assembly
MyImplementation, Version=, Culture=, PublicKeyToken= does not have an
implementation."
When I change
> > double[ , ] MyProperty {get;}
to
double[ ] MyProperty {get;}
(at all places), the assembly loads without a problem...
Have you tried to execute the code or did you compile it only?
regards, Hans.
> >I have encapsultated old C/C++ code in a mixed mode C++ module (Project 2).
> > In my C# app (project 3) I instanciate a managed C++ class. The behaviour
[quoted text clipped - 58 lines]
> Thanks,
> Kapil
Kapil Khosla [MSFT] - 03 May 2005 22:11 GMT
> The code compiles alright, but when debugging, the assembly loader throws
> exception System.TypeLoadException:
[quoted text clipped - 75 lines]
> > Thanks,
> > Kapil
I did execute the app last time too and got no exception. I am working with
beta2 though, what compiler/IDE are you working on?
Thanks
Kapil
Hans - 04 May 2005 11:51 GMT
> > The code compiles alright, but when debugging, the assembly loader throws
> > exception System.TypeLoadException:
[quoted text clipped - 80 lines]
> Thanks
> Kapil
Developer studio 7.1.3088,
Microsoft Visual C# .NET 69461-335-0000007-18487,
Microsoft Visual C++ .NET 69461-335-0000007-18487
regards, Hans.
Hans - 11 May 2005 13:28 GMT
I keep getting
Message "Method get_MyProperty in type MyNamespace.MyImplementation from
assembly InterfaceImplementation, Version=1.0.1957.24022, Culture=neutral,
PublicKeyToken=null does not have an implementation."
Can anybody help me out???
> >I have encapsultated old C/C++ code in a mixed mode C++ module (Project 2).
> > In my C# app (project 3) I instanciate a managed C++ class. The behaviour
[quoted text clipped - 58 lines]
> Thanks,
> Kapil
Kapil Khosla [MSFT] - 13 May 2005 23:30 GMT
> I keep getting
> Message "Method get_MyProperty in type MyNamespace.MyImplementation from
[quoted text clipped - 65 lines]
> > Thanks,
> > Kapil
Hi Hans,
I finally got hold of Everett and tried your sample and you are right, I do
get the
same exception with Everett CLR.
The reason is due to a bug in the Everett CLR which has now been fixed with
later release. I could not really find a good work around in Everett. I am
pretty sure the
code has no issues in beta2 so if you can updgrade your solution to Beta2
that would be ideal.
Let me know if you have questions.
Kapil
> I have encapsultated old C/C++ code in a mixed mode C++ module (Project 2).
> In my C# app (project 3) I instanciate a managed C++ class. The behaviour of
[quoted text clipped - 43 lines]
> }
> }
Can you try reproing with the following
csc /t:library IMyInterface.cs
cl /clr:oldSyntax /LD MyImplementation.cpp
csc /r:MyImplementation.dll /r:IMyInterface.dll MyApp.cs
Your exact code works for me,
Thanks,
Kapil