static managed member in unmanaged code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
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.
 
Back
Top