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 / .NET Framework / Interop / December 2004

Tip: Looking for answers? Try searching our database.

C# to C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ravi Singh (UCSD) - 27 Dec 2004 17:34 GMT
Hello all

What would be the analogous c++ statement for this C# code

ComInterface ci = (ComInterfaceClass)Marshal.CreateWrapperOfType(
GenericType, typeof(ComInterfaceClass));

or
(ItemClass) Marshal.CreateWrapperOfType( myObj, typeof(ItemClass)

I tried
Marshal::CreateWrapperOfType(myObj, Interop::Lib::Item::GetType() )

But it keeps giving me an error illegal call of non-static member
function.

So what am I doing wrong.

-Ravi Singh
Alessandro Angeli [MVP::DigitalMedia] - 27 Dec 2004 17:42 GMT
> What would be the analogous c++ statement for this C# code
>
[quoted text clipped - 12 lines]
> But it keeps giving me an error illegal call of
> non-static member function.

typeof(class) is the same as the static method invocation
System::Type::GetType("class") while
System::Object::GetType() is an instance method and you need
an object instance to invoke it.

Signature

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net

Ravi Singh (UCSD) - 27 Dec 2004 18:19 GMT
Ahh,

I did __typeof() and that worked.

-Ravi Singh
Mattias Sj?gren - 27 Dec 2004 23:26 GMT
>typeof(class) is the same as the static method invocation
>System::Type::GetType("class")

Not quite. typeof() resolves the typename to a token at compile time,
whereas Type::GetType requires a lookup by name at runtime.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Alessandro Angeli [MVP::DigitalMedia] - 28 Dec 2004 00:10 GMT
> Not quite. typeof() resolves the typename to a token at
> compile time, whereas Type::GetType requires a lookup by
> name at runtime.

Quite right, I oversimplified.

Signature

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


Rate this thread:







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.