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++ / March 2005

Tip: Looking for answers? Try searching our database.

static managed member in unmanaged code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klynt@noemail.nospam - 02 Mar 2005 04:23 GMT
Is it possible to declare a static managed member in managed code?

gcroot<MyClass*> instance
works,
but
static gcroot<MyClass*> staticinstance does not.

Any suggestions?
Klynt@noemail.nospam - 02 Mar 2005 04:43 GMT
Correction:  Is it possible to declare a static managed member in UNMANAGED
code?

> Is it possible to declare a static managed member in managed code?
>
[quoted text clipped - 4 lines]
>
> Any suggestions?
Gary Chang[MSFT] - 02 Mar 2005 07:40 GMT
Hi Klynt,

>Correction:  Is it possible to declare a static managed member in
>UNMANAGED code?

AFAIK, the gcroot is used to wrapped an managed object in a unmanaged
object(class), but the code of gcroot<...> declaration should be compiled
as managed code, for the gcroot copy constructor needs to create a new GC
handle and use managed types and call managed functions.

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ??C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Gary Chang[MSFT] - 04 Mar 2005 08:58 GMT
By the way, do you mean is it possible to declare a static managed member
in UNMANAGED object(class) and instance it
like the following code snippet:

class UnManagedClass {
public:
   CppClass() {}

   static gcroot<String*> str;    
};
..
UnManagedClass::str = new String("Hello");

Then I think you will get the LNK2020 : unresolved token error while
compiling the above code, if you still monitor this thread and have concern
on the problem, please reply this message and I will contact the
corresponding support specialist for you.

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ??C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

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.