Click here to Skip to main content
15,885,141 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionPreselecting files in a CFileDialog Pin
Hayden Fisher14-Feb-11 21:31
Hayden Fisher14-Feb-11 21:31 
QuestionSpliting a String in C++/CLI Pin
T.RATHA KRISHNAN14-Feb-11 20:03
T.RATHA KRISHNAN14-Feb-11 20:03 
AnswerRe: Spliting a String in C++/CLI Pin
Ger Hayden14-Feb-11 21:59
Ger Hayden14-Feb-11 21:59 
GeneralRe: Spliting a String in C++/CLI Pin
T.RATHA KRISHNAN14-Feb-11 22:13
T.RATHA KRISHNAN14-Feb-11 22:13 
GeneralRe: Spliting a String in C++/CLI Pin
Ger Hayden15-Feb-11 6:01
Ger Hayden15-Feb-11 6:01 
GeneralRe: Spliting a String in C++/CLI Pin
Richard MacCutchan15-Feb-11 23:24
mveRichard MacCutchan15-Feb-11 23:24 
AnswerRe: Spliting a String in C++/CLI Pin
John Schroedl15-Feb-11 10:16
professionalJohn Schroedl15-Feb-11 10:16 
QuestionBadImageFormat exception because of just class definition. Pin
progDes10-Feb-11 1:44
progDes10-Feb-11 1:44 
Hi all!

I have big experience in the unmanaged C++. And have almost no experience in all these NET things. So, I started a project using managed C++ yesterday. Looks, like it will put me to the grave...

For the context. I'm writing a plugin for ClearCanvas application. My plugin already have some classes that are inherited from the classes in the ClearCanvas SDK. Plugin is loading and working well.

Now imagine the situation.
I define a new class that inherits the simple interface. The inheritance model is:

IDisposable->IRenderingSurface->MyClass

IRenderingSurface is just a simple interface that declares 4 properties without implementation of them.

So I implement my class like this:

ref class VolumeRenderingSurface :
           public ClearCanvas::ImageViewer::Rendering::IRenderingSurface
       {
       public:
           // Constructor.
           VolumeRenderingSurface(System::IntPtr windowID, int width, int height);
           // Destructor
           ~VolumeRenderingSurface();

           /// Window ID property
           property System::IntPtr WindowID
           {
               virtual System::IntPtr get() {return m_windowID;}
               virtual void set(System::IntPtr id) {m_windowID = id;}
           }
           /// Context ID property
           property System::IntPtr ContextID
           {
               virtual System::IntPtr get() {return m_contextID;}
               virtual void set(System::IntPtr id) {m_contextID = id;}
           }
           /// Client rectangle property property
           property System::Drawing::Rectangle ClientRectangle
           {
               virtual System::Drawing::Rectangle get() {return m_clientRectangle;}
               virtual void set(const System::Drawing::Rectangle rect) {m_clientRectangle = rect;}
           }
           /// Clip rectangle property property
           property System::Drawing::Rectangle ClipRectangle
           {
               virtual System::Drawing::Rectangle get() {return m_clipRectangle;}
               virtual void set(const System::Drawing::Rectangle rect) {m_clipRectangle = rect;}
           }
       private:
           System::IntPtr m_windowID;
           System::IntPtr m_contextID;
           System::Drawing::Rectangle m_clientRectangle;
           System::Drawing::Rectangle m_clipRectangle;
       };


The constructor and destructor are defined but empty. I even DONT use this class anywhere, just define it.

And I try it. Everything is compiled without warnings, but when ClearCanvas attempts to load plugin - it fails.
"first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll"

Well, next point. If I comment the inheritance from interface it works!

In my project, I have few classes that are inherited exactly the same (I mean IDisposable->ISomeSimpleInterface->SomeClass) and they work!

What a hell!? Smile | :)

Here is the code for IRenderingSurface interface, it's in C#. Nothing interesting:

    public interface IRenderingSurface : IDisposable
{
    IntPtr WindowID
    {
        get;
        set;
    }
    IntPtr ContextID
    {
        get;
        set;
    }
    Rectangle ClientRectangle
    {
        get;
        set;
    }
    Rectangle ClipRectangle
    {
        get;
        set;
    }
}


Thank you.
AnswerRe: BadImageFormat exception because of just class definition. Pin
progDes10-Feb-11 17:09
progDes10-Feb-11 17:09 
QuestionAdding Member Functions to the .CPP Pin
Ger Hayden10-Feb-11 0:30
Ger Hayden10-Feb-11 0:30 
QuestionAdding a member function in VC++ Express 2010 Pin
Ger Hayden10-Feb-11 0:27
Ger Hayden10-Feb-11 0:27 
QuestionInline processor assembly language in C++/CLI Pin
anti.AS7-Feb-11 21:54
anti.AS7-Feb-11 21:54 
AnswerRe: Inline processor assembly language in C++/CLI Pin
John Schroedl8-Feb-11 5:42
professionalJohn Schroedl8-Feb-11 5:42 
QuestionDifference between IJW and #pragma unmanaged ? Pin
anti.AS7-Feb-11 5:10
anti.AS7-Feb-11 5:10 
AnswerRe: Difference between IJW and #pragma unmanaged ? Pin
Nish Nishant7-Feb-11 5:24
sitebuilderNish Nishant7-Feb-11 5:24 
GeneralRe: Difference between IJW and #pragma unmanaged ? Pin
anti.AS7-Feb-11 9:08
anti.AS7-Feb-11 9:08 
GeneralRe: Difference between IJW and #pragma unmanaged ? Pin
Nish Nishant7-Feb-11 9:16
sitebuilderNish Nishant7-Feb-11 9:16 
GeneralRe: Difference between IJW and #pragma unmanaged ? Pin
anti.AS7-Feb-11 9:36
anti.AS7-Feb-11 9:36 
QuestionWhat is Difference between Managed C++, C++/CLI and C++.Net Pin
Pranit Kothari5-Feb-11 4:26
Pranit Kothari5-Feb-11 4:26 
AnswerRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
Richard MacCutchan5-Feb-11 5:28
mveRichard MacCutchan5-Feb-11 5:28 
QuestionRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
Pranit Kothari5-Feb-11 5:59
Pranit Kothari5-Feb-11 5:59 
AnswerRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
Richard MacCutchan5-Feb-11 21:16
mveRichard MacCutchan5-Feb-11 21:16 
GeneralRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
Pranit Kothari6-Feb-11 3:20
Pranit Kothari6-Feb-11 3:20 
AnswerRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
John Schroedl5-Feb-11 8:02
professionalJohn Schroedl5-Feb-11 8:02 
GeneralRe: What is Difference between Managed C++, C++/CLI and C++.Net Pin
Pranit Kothari5-Feb-11 17:44
Pranit Kothari5-Feb-11 17:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.