Solved

How to : #using <mscorlib.dll>

Posted on 2004-09-07
9
1,782 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
Independent Software Vendors: 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 250 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

724 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