Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

invalid operand for __typeof, expected a fully defined managed type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ghost - 20 May 2005 18:02 GMT
Hi all, I wrote a program in C# and now I have to "translate" it i
visual C++ (MFC) using .NET, but I had a little problem:

*ERRORS*
error C3181: 'CTestDlg' : invalid operand for __typeof, expected
fully defined managed type

error C3363: 'void CTestDlg::BtnAboutClick(System::Object __g
*,System::EventArgs __gc *)' : cannot create a delegate handler fo
'System::EventHandler' from a non-member function or a member of a
unmanaged class

error C2227: left of '->Add' must point to class/struct/union

*SOURCE LINES*
ResourceManager* resources = new ResourceManager(__typeof(CTestDlg));

btnAbout->Click += new EventHandler(this, &CTestDlg::BtnAboutClick);

Control::Controls->Add(btnAbout);

My .h file is:

class CTestDlg: public CDialog
{
//lots of code.....
}

I'm wasting my time on these errors but I don't know how can I fi
them, could someone help me?
Thank you for the help (I hope :D


Antti Keskinen - 22 May 2005 08:59 GMT
Hello !

The Visual Studio series has one crucial advantage over other IDEs: it tends
to state very specifically what the error is. The first error gives you a
hint: "use of __typeof expects a fully defined _managed_ type" and the
second error confirms it: "... from a non-member function or a member of an
_unmanaged_ class".

Putting it in plain english, the class CTestDlg is not defined as a managed
type, period. If you're writing for the C++/CLI syntax, the following
declaration would make it managed:

ref CTestDlg : public CDialog
{
// code
}

If you're writing for Managed Extensions for C++, the declaration is:

__gc class CTestDlg : public CDialog
{
// code
}

Remember that creating a managed version of your class also removes the need
to explicitly delete a created object of this type. Also other programming
qwirks get implied when an unmanaged class is moved to the managed
environment, like the need for a different type of declaration syntax (which
might impose problems if the instance is created by the MFC framework). This
means, in english that if you use the doc/view architecture of MFC, you must
create and upkeep the doc/views manually, because MFC isn't a managed
framework.

Hope this helps,
-Antti Keskinen

-------------------------------------------

> Hi all, I wrote a program in C# and now I have to "translate" it in
> visual C++ (MFC) using .NET, but I had a little problem:
[quoted text clipped - 33 lines]
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.