Solved

How to : #using <mscorlib.dll>

Posted on 2004-09-07
9
1,663 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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 clear a vector as well as how to detect empty vectors in C++.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now