BadImageFormat exception because of just class definition.
-
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.
-
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.
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 :)