Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. BadImageFormat exception because of just class definition.

BadImageFormat exception because of just class definition.

Scheduled Pinned Locked Moved Managed C++/CLI
c++graphicsoop
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    progDes
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • P progDes

      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.

      P Offline
      P Offline
      progDes
      wrote on last edited by
      #2

      Wow, I found a problem. Although this is my (no big) mistake, the result is just unexpected. virtual void set(const System::Drawing::Rectangle rect) {m_clientRectangle = rect;} Should be replaced with: virtual void set(System::Drawing::Rectangle rect) {m_clientRectangle = rect;} No const! Well I know const doesnt mean here anything. I've tried to use const reference from the very beginning. Then it failed to compile, I removed reference, but forgot to remove const. As a result - 5 hours wasted because of const that actualy doesnt mean anything! Fairy .NET :)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups