?
Solved

How to : #using <mscorlib.dll>

Posted on 2004-09-07
9
Medium Priority
?
1,828 Views
Last Modified: 2009-12-16
I Get the Error::
fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option
when I try to use

#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;

VS.net 2003 with a MFC c++ project

What Am I Missing??

0
Comment
Question by:MCofer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 12000438
Do you have set the '/clr' compiler options in your project settings?
0
 

Author Comment

by:MCofer
ID: 12000542

How do I set the '/clr' option in VS.net 2003?
0
 
LVL 86

Expert Comment

by:jkr
ID: 12000559
I don't have a VS.NET here right now, but there should be a text field at the bottom when you choose the 'C++' tab in your project settings. Add it there.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MCofer
ID: 12000642
That allowed me to compile but now i get the following

msvcrt.lib(checkclr.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
msvcrt.lib(secchk.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
mfcs71.lib(dllmodul.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
atls.lib(atlbase.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
InsIbsFile.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
mfcs71.lib(stdafx.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
atls.lib(atlbase.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators

What is this telling me?
0
 
LVL 86

Expert Comment

by:jkr
ID: 12000698
That could have plenty of reasons - check out http://support.microsoft.com/default.aspx?scid=kb;en-us;814472 ("PRB: Linker Warnings When You Build Managed Extensions for C++ DLL Projects") and the linker warning reference page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vctbsLinkerToolsWarningLNK4210.asp ("Linker Tools Warning LNK4210")
0
 
LVL 19

Accepted Solution

by:
drichards earned 1000 total points
ID: 12000819
Also, go into the Configuration Properties/Genreal page of the project properties and set "Use managed Extensions" to Yes.  This will add /clr and change a few other settings required for managed C++.
0
 

Author Comment

by:MCofer
ID: 12000972
I was simply wanting to use StreamReader in an MFC DLL
the "use managed extensions" only works with /NOENTRY set and this results in the problems shown erlier
I can always go bact to using scanf and fgets to read my file

Any other Ideas?
0
 
LVL 86

Expert Comment

by:jkr
ID: 12001026
Thank you for appreciating my efforts. That really motivates me...
0
 
LVL 19

Expert Comment

by:drichards
ID: 12001386
>>  I was simply wanting to use StreamReader in an MFC DLL
If all you want to do is use one slick feature of .NET class library in an otherwise regular C++ dll, it's generally a good idea to resist the temptation.  Besides being a half-breed executable, it causes a host of difficulties with compilation and linking (as you've experienced).  You should either plan to port the whole app to managed C++ or just leave it as wholly unmanaged code.  There is rarely a good reason to mix it up.

Also, here's an article explaining the linker warning and what you can do about it:

http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;814472&product=vcNET
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question