Solved

How to : #using <mscorlib.dll>

Posted on 2004-09-07
9
1,736 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 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