Newbie Problem

M

Michael Bray

Question from a co-worker braving Managed C++ (I only do C#):

I’m having trouble including an ArrayList in a MFC application. My
intention is to call some C# DLLs from a VC++ extended stored procedure.
So, I thought I’d test in a simple dialog box application where its
easier to debug.

I created a Visual C++ Project -> MFC Application -> dialog interface

I added the following line in the OnBnClickedOk() method

ArrayList* myAL = new ArrayList();

I added the following three lines after the #pragma in the TestDlg.h
file

#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;

Compilation yielded the following error

fatal error C1190: managed targeted code requires '#using
<mscorlib.dll>' and '/clr' option

I added the /clr option to the Property Page -> Configuration Properties
-> C/C++ -> Command Line -> Additional Options section

Command line error D2016 : '/RTC1' and '/clr' command-line options are
incompatible

I changed Both to Default in the Property Page -> Configuration
Properties -> C/C++ -> Code Generation -> Basic Runtime Checks section

Command line error D2016 : '/Gm' and '/clr' command-line options are
incompatible

I changed Yes to No in the Property Page -> Configuration Properties ->
C/C++ -> Code Generation -> Enable Minimal Rebuild section

Command line error D2016 : '/ZI' and '/clr' command-line options are
incompatible

I changed Program Database for Edit & Continue to Program Database in
the Property Page -> Configuration Properties -> C/C++ -> General ->
Debug Information Format section

error C3828: 'System::Collections::ArrayList': placement arguments not
allowed while creating instances of managed classes

The error occurs in the ArrayList variable definition, in particular the
new ArrayList() portion.


Thanks!

-mdb
 
R

Ronald Laeremans [MSFT]

Place the line

#undef new

after the includes.

In debug mode you are pulling in a #define of new to DEBUG_NEW which uses
oplacement syntax to add information on the source line that made the
allocation.

Ronald Laeremans
Visual C++
 
R

ryan

Hi, isn't it better to create an .NET Windows Form, wherein you can use ArrayList Class ?

You can mail me if you wish, I can program somewhat C++ .NET 2003, maybe I can help via MSN: (e-mail address removed)

I wish you good luck, and I wish you succeed - No! I know you will succeed.


Have a good day further,
ryan

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
G

Guest

Hi Michae
i'm working with console applicatio
i have the same problem and i solve it in the following way
1) Go To ---Project Property->Configuration Property --->c/c++ --->/cl
2) Go To ---Project Property->Configuration Property --->Code Generation-->Basic Runtime Checks-->Default
3) Go To ---Project Property->Configuration Property --->Code Generation-->Enable Minimal Rebuild--> N
4) Go To ---Project Property->Configuration Property --->c/c++ -->General-->Debug Information Format-->Program Database (/Zi
5) Go To ---Project Property->Configuration Property --->Code Generation-->Runtime Library--><inherit from project defaults

those settings solve the proble

have a nice day
Gabi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top