Re: Multi dimensional arrays in C# and in C++



"Kapil Khosla [MSFT]" wrote:

>
>
> "Hans" wrote:
>
> > 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.
> >
> > "Kapil Khosla [MSFT]" wrote:
> >
> > >
> > >
> > > --
> > > 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";
> > >
> > > "Hans" <Hans@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> > > news:07068F9C-C5E4-453E-87A2-597A9E8A7741@xxxxxxxxxxxxxxxx
> > > >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?
> > > > }
> > > > }
> > > >
> > >
> > >
> > > 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
> > >
> > >
> > >
>
>
> 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

Developer studio 7.1.3088,
Microsoft Visual C# .NET 69461-335-0000007-18487,
Microsoft Visual C++ .NET 69461-335-0000007-18487

regards, Hans.
.



Relevant Pages

  • Re: templated SinglyLinkedList implementation
    ... > compiles as is but when I display the output, all of the values are the same ... > const unsigned int NUMELEMS; ... useful for exception safety and pretty much nothing else. ... when you make a copy of an auto_ptr, the source is rendered useless. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Problems supporting Windows XP themes
    ... The program worked for 3 compiles and then after the 4th compile it failed again. ... Here is the stack trace. ... is it from an exception? ...
    (microsoft.public.dotnet.framework)
  • Re: Delphi 7 vs Delphi 2005
    ... The app runs fine when it compiles. ... compile and no exception is thrown. ... BTW it is a single thread app. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: size of a sizeof(pointer)
    ... It compiles to a pseudoassembly ... > This really is the exception that proves the point. ... Nor is C the ideal language for such an environment - you need ...
    (comp.lang.c)