By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,261 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,261 IT Pros & Developers. It's quick & easy.

mscorlib.dll problem (Visual C++ 2005)

P: n/a
Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step", which was made for 2003.
Just so you know where I'm getting this example.

When I build this code, I get the following compile error.

1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option

And that is regarding this:

#using <mscorlib.dll>

And then when I had /clr to the options, it then says:

1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible

So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make this
code work?

////////////////////////////////////////////////////////////////////////

// Animal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;

cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;

Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);

return 0;
}

//////////////////////////////////////////////////////

I am using a regular Win32 console applications. Thanks alot.

Dec 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Alex Hardin wrote:
Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step", which was made for 2003.
Just so you know where I'm getting this example.


http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

HTH,
- J.
Dec 17 '05 #2

P: n/a
"Alex Hardin" <61**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com
Hey,
I just downloaded Visual C++ 2005 Express, and I'm reading through a
book called "Visual C++ .NET Step By Step",
Judging by the reviews on Amazon, it is a dreadful book.
which was made for 2003.
Just so you know where I'm getting this example.
When I build this code, I get the following compile error.

1>c:\documents and settings\editing\my
documents\alex\c++\animal\animal\animal.cpp(6) : fatal error C1190:
managed targeted code requires a '/clr' option

And that is regarding this:

#using <mscorlib.dll>

And then when I had /clr to the options, it then says:

1>cl : Command line error D8016 : '/RTC1' and '/clr' command-line
options are incompatible

So if I shut off /RTC1 in code generation, then it just says that
therer is another thing incompatible (/Gm I think) and it just keeps
going on with incompatibilities. Is there any way that I can make
this code work?

////////////////////////////////////////////////////////////////////////

// Animal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#using <mscorlib.dll>

using namespace System;

__gc class Animal
{
public:
int legs;
void SetName(String *name)
{ strName = strName->Copy(name); }
String* GetName() { return strName; }
private:
String *strName;
};
int _tmain()
{
Animal *cat, *dog;
cat = new Animal;
dog = new Animal;

cat->SetName("Cat");
cat->legs = 4;
dog->SetName("Dog");
dog->legs = 4;

Console::WriteLine("Animal 1");
Console::Write("Name: ");
Console::WriteLine(cat->GetName());
Console::Write("Legs: ");
Console::Write(cat->legs);

return 0;
}

//////////////////////////////////////////////////////

I am using a regular Win32 console applications. Thanks alot.


The example involves managed code, which is a non-standard Microsoft
extension to C++ (and hence off-topic on this
newsgroup). Incidentally, the version of managed code supported by VC++ 2003
(and discussed in the book you have) is effectively obsolete, replaced by
C++/CLI in VC++ 2005.

The correct place to ask about this stuff is

microsoft.public.dotnet.languages.vc
--
John Carson
Dec 18 '05 #3

P: n/a
Okay thanks, I did get the problem fixed on the other group. I didn't
read anything about the book, I just saw it at the library and picked
it up. I'll try and look for a 2005 book then. Or something. Thanks
again guys.

Dec 18 '05 #4

P: n/a

Alex Hardin wrote:
Okay thanks, I did get the problem fixed on the other group. I didn't
read anything about the book, I just saw it at the library and picked
it up. I'll try and look for a 2005 book then.


You probably don't want to look at all the 2005 extensions before
learning
the base language proper. Have a look at www.accu.org. It has a lot of
book
reviews, rated by experts. One of the better books is Accelerated C++,
by
A.Koenig. It's good for novices, either new to C++ or to programming in

general. If you're one of the latter, don't be fooled by the thin
appearance.
It's complete, but has little fluff.

HTH,
Michiel Salters

Dec 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.