Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > mscorlib.dll problem (Visual C++ 2005)

Reply
Thread Tools

mscorlib.dll problem (Visual C++ 2005)

 
 
Alex Hardin
Guest
Posts: n/a
 
      12-17-2005
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.

 
Reply With Quote
 
 
 
 
Jacek Dziedzic
Guest
Posts: n/a
 
      12-17-2005
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.
 
Reply With Quote
 
 
 
 
John Carson
Guest
Posts: n/a
 
      12-18-2005
"Alex Hardin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
Alex Hardin
Guest
Posts: n/a
 
      12-18-2005
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.

 
Reply With Quote
 
Michiel.Salters@tomtom.com
Guest
Posts: n/a
 
      12-19-2005

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments