Click to See Complete Forum and Search --> : System DateTime (un)managed code???
ipsteal
August 18th, 2003, 11:04 AM
Hi,
I am trying to create a class with one of its members of type System.DateTime however, when i build, it says "Cannot declare a managed X in an unmanaged Y"
What does this mean and how do I fix it?
My declaration currently looks like this:
using namespace System;
class Y
{
public:
Y(void);
~Y(void);
DateTime X;
};
Please help asap! Thank you
Andreas Masur
August 18th, 2003, 11:18 AM
[Moved thread]
MooNull
August 18th, 2003, 10:39 PM
The answer is simple: You cannot, by any means, declare a member in an unmanaged class to be of a managed type.
I, of course, reserve the right to be wrong.
Why not just declare the class as managed (__gc)? Or is that the point...?
Do reply if you truly MUST wrap a managed datetime object in an unmanaged class. I have an idea to make the conversion work.
ipsteal
August 19th, 2003, 09:52 AM
if declaring the class as managed will make it work, then i'll do that, of course i have no idea what that means and how to do it? i am new to this stuff. i actually wrote this whole project in vb .net last week and then my boss comes over to me and tells me she changed her mind and wants it in vc++ .net and i've never used it. im typically a unix/linux programmer but taught myself enough vb to get a summer job since im still in school, but havent gotten around to learning vc++ yet.
thanks
ipsteal
Andreas Masur
August 19th, 2003, 10:16 AM
Well...is there any valid reason why your boss wants to have it in C++ now? With .NET (thus VB .NET, C# etc.) you can only produce managed applications. Porting it to managed C++ does not make any difference since basically this independence from the language is one of the feature of the whole .NET design. Your managed application will be compiled into an intermediate language which in turn will then be run by the CLR (Common Language Runtime).
MooNull
August 19th, 2003, 07:40 PM
Certaintly do talk to your boss...
If you still find that you need to do the project in VC++, and still have any problems about managed applications or otherwise, do post. I'd be happy to help.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.