Multimobile Development: Building Applications for any Smartphone
TypeLoadException with MFC
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.libraries.


Klaus Schlegel
GOOD ANSWER
I wrote a MFC Dialog Application with a TreeCtrl. With unmanaged C++ every
think works fine, but after I enabled managed extensions the application
crashed with a TypeLoadExeption. After I removed the CTreeCtrl::InsertItem
calls from InitDialog I can start the application again.

Do someone have an idea ?

Reply to this message...
Vote that this is a GOOD answer... (56 votes from other users already)
 
 
    
Ronald Laeremans [MSFT]
GOOD ANSWER
Hi Klaus,

Can you report a bug on that with a repro?

Ronald Laeremans
Visual C++ compiler team

"Klaus Schlegel" <Click here to reveal e-mail address> wrote in message
news:#$OwX$cIBHA.1740@tkmsftngp03...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (48 votes from other users already)
 
 
    
Anson Tsao [MSFT]
GOOD ANSWER
The problem is because struct _TREEITEM{} is not defined in the common
control header files.
To fix the problem define the following in your stdafx.h

struct _TREEITEM
{};

More info:
HTREEITEM is defined as typedef struct _TREEITEM* HTREEITEM; for typesafety.
In native C++, not having struct _TREEITEM define is not a problem, but in
managed C++
functions that return HTREEITEM (such as CTreeCtrl::InsertItem()) will
throw TypeLoadException when the CLR is trying to resolve struct _TREEITEM*.

Anson Tsao
Microsoft Visual C++ Libraries

"Ronald Laeremans [MSFT]" <Click here to reveal e-mail address> wrote in message
news:OCS3XZ3IBHA.1948@tkmsftngp05...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (65 votes from other users already)
 
 
 
System.TypeLoadException




Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Copyright © AMX Software Ltd 2008-2012. Portions copyright © Matthew Baxter-Reynolds 2001-2012. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734

Hi! 10 years ago I founded .NET 247. I am working on a new and exciting replacement for the site. Please join me on Twitter to discuss.

Thanks,
Matthew Baxter-Reynolds (@mbrit)

Follow mbrit on Twitter