By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

problem using MFC in clr

P: n/a
ma
Hello;

I want to use some classes that I wrote (MFC based) in my .net
application. I did the following steps to achieve this:

1- I create a winform application. (The program compile and run
successfully).

2- I changed project setting as documented by MS:
(http://msdn2.microsoft.com/en-us/library/ms235211.aspx ) (The program
compile and run successfully).

3- I add the following line to stdafx.h

#include <afxwin.h> // MFC core and standard components

At this point, the program compiles but when I am trying to run it, I am
getting a heap error. The error message is assertion failed at line 1414 in
file dbgheap.c

What is the problem and how can I solve it?

Best regards



Mar 21 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi ma,
"ma" <ma@nowhere.com> wrote in message
news:uJ****************@TK2MSFTNGP12.phx.gbl...
Hello;

I want to use some classes that I wrote (MFC based) in my .net
application. I did the following steps to achieve this:

1- I create a winform application. (The program compile and run
successfully).

2- I changed project setting as documented by MS:
(http://msdn2.microsoft.com/en-us/library/ms235211.aspx ) (The program
compile and run successfully).

3- I add the following line to stdafx.h

#include <afxwin.h> // MFC core and standard components

At this point, the program compiles but when I am trying to run it, I am
getting a heap error. The error message is assertion failed at line 1414
in file dbgheap.c

What is the problem and how can I solve it?

Best regards


I had similar problems in the beta phases of VC2005. My feeling was that
these problems were solved with the VC release, but I can reproduce the bug,
so it seems isn't.

From what I can see so far, this might be a bug in the CRT initialization
code. It seems that DLL and EXE initialization is confused for some reason I
don't know yet.

I try to find out something more about it and let you know.

Marcus Heege
Mar 23 '06 #2

P: n/a
Hi ma!
I want to use some classes that I wrote (MFC based) in my .net
application. I did the following steps to achieve this:

1- I create a winform application. (The program compile and run
successfully).

2- I changed project setting as documented by MS:
(http://msdn2.microsoft.com/en-us/library/ms235211.aspx ) (The program
compile and run successfully).

3- I add the following line to stdafx.h

#include <afxwin.h> // MFC core and standard components


You should report this bug at
http://lab.msdn.microsoft.com/productfeedback/

And post the link to your bug-report here, so we can vote for it!

Greetings
Jochen
Mar 24 '06 #3

P: n/a
ma
Hello,
I report it and this is the link:
http://lab.msdn.microsoft.com/Produc...ckId=FDBK47757

the title is:
usning MFC in winform application generate heap error

Best regards
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote in message
news:es*************@TK2MSFTNGP12.phx.gbl...
Hi ma!
I want to use some classes that I wrote (MFC based) in my .net
application. I did the following steps to achieve this:

1- I create a winform application. (The program compile and run
successfully).

2- I changed project setting as documented by MS:
(http://msdn2.microsoft.com/en-us/library/ms235211.aspx ) (The program
compile and run successfully).

3- I add the following line to stdafx.h

#include <afxwin.h> // MFC core and standard components


You should report this bug at
http://lab.msdn.microsoft.com/productfeedback/

And post the link to your bug-report here, so we can vote for it!

Greetings
Jochen

Mar 24 '06 #4

P: n/a
Hi ma!
I report it and this is the link:
http://lab.msdn.microsoft.com/Produc...ckId=FDBK47757


Validated and voted...

Also changed the title to include a "_CrtIsValidHeapPointer"; so it can
be easier found by others...

Thanks!

Greetings
Jochen
Mar 24 '06 #5

P: n/a
Hi ma!
I report it and this is the link:
http://lab.msdn.microsoft.com/Produc...ckId=FDBK47757


It seems that this bug should have been fixed in the RTM...
See also:

atlstr.h and /clr
http://lab.msdn.microsoft.com/produc...e-e0a40ba72821

An error arises at launching if an ATL header is included in the Managed
C++/CLI application project.
http://lab.msdn.microsoft.com/produc...b-739aae0855a5

Greetings
Jochen
Mar 24 '06 #6

P: n/a
Hi ma!
I report it and this is the link:
http://lab.msdn.microsoft.com/Produc...ckId=FDBK47757


There is a work-around for this problem:

1. Change the "entry point" in you linker settings from "main" to
"wWinMainCRTStartup"
2. Add "#include <afxwin.h>" to your "stdafx.h"
3. Replace your "main" method with the following:
class CMFCApp : public CWinApp
{
public:
virtual BOOL InitInstance()
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(fal se);
// Create the main window and run it
Application::Run(gcnew Form1());
return FALSE;
}
} theApp;

See also: FDBK47757#1: Replace "main" with CWinApp
http://lab.msdn.microsoft.com/Produc...ID=FDBK47757#1

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Mar 24 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.