Solved

How to : #using <mscorlib.dll>

Posted on 2004-09-07
9
1,716 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to understand recursion 12 226
FMX StringGrid1->Canvas->FillRect Problem 3 153
How to copy an image file into clipboard C/C++? 1 170
Header of docx file 17 103
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

810 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