473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

VC7 - Warning C4669 - mixing unmanaged an managed classes

Hi

I'm getting the following warning

warning C4669: 'reinterpret_cast' : unsafe conversion: 'CMFCShellDoc' is a
managed type object

CMFCShellDoc is derived from COleServerDoc which is NOT managed. The
CMFCShellDoc does have properties which is of type gcroot<managedClass*>.

My app works as expected - but do I have to take these warnings serious or
is it a bug??

I saw another posting about this but no usable reply was posted by MS

http://groups.google.com/groups?hl=d...ion%2B%252FCLR

Regards Morten
Nov 16 '05 #1
4 2134
Hi Morten,

Thanks for your focus on VC.NET,

My opinion is if you don't use the managed property of type
gcroot<managedClass*>, just take the warning message as helpful(probably)
reminder better than nothing.

By the way, I don't think its a bug, the CMFCShellDoc does really have one
managed property,

However, let's wait the community members' valuable ideas...
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 16 '05 #2
Hi Gary

So - we meet again :-)

I do use the gcroot<managedClass*> in my CMFCDoc class since this is the
only way as I can keep references to managed objects from unmanaged objects
besides using com interop.
So are you saying that the gcroot class template should not be used -
because it has some nasty side effects??

Regards morten

"Gary Chang [MSFT]" <v-******@online.microsoft.com> wrote in message
news:lE**************@cpmsftngxa06.phx.gbl...
Hi Morten,

Thanks for your focus on VC.NET,

My opinion is if you don't use the managed property of type
gcroot<managedClass*>, just take the warning message as helpful(probably)
reminder better than nothing.

By the way, I don't think its a bug, the CMFCShellDoc does really have one
managed property,

However, let's wait the community members' valuable ideas...
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. --------------------

Nov 16 '05 #3
Hi Gary

Can you please send me the project that you have developed - I would like to
see it work with my own eyes :-)

Regards Morten

"Gary Chang [MSFT]" <v-******@online.microsoft.com> wrote in message
news:lE**************@cpmsftngxa06.phx.gbl...
Hi Morten,

Thanks for your focus on VC.NET,

My opinion is if you don't use the managed property of type
gcroot<managedClass*>, just take the warning message as helpful(probably)
reminder better than nothing.

By the way, I don't think its a bug, the CMFCShellDoc does really have one
managed property,

However, let's wait the community members' valuable ideas...
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. --------------------

Nov 16 '05 #4
Hi Morten,

Thanks for your quickly response!
So are you saying that the gcroot class template should not be used -
because it has some nasty side effects??


What I mean is if you don't use the gcroot class template feature in your
program, you can ignore the warning message.

And mean time, I also consult a VC design engineer with your problem, his
opinion is:

"This warning should fire if the managed class(destination or source type
in the cast) has gc pointers (managed members) , It should not fire for a
class that only has a gcroot¡*since then the class is still unmanaged..

The original warning intends to inform the user that casting a class with
managed members is dangerous since no runtime check is being done..Well
anyways, u always better know what you are doing if you are reinterpret
casting instead of dynamic/static cast"

Hope that helps!
Best regards,
Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

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

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
0
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from...
1
by: Peteroid | last post by:
Why don't managed classes (i.e., _gc garbage-collected classes) support 'const', 'virtual', and 'static'? Is there a reason they can't, or is these possibly going to be supported in the future? ...
3
by: _BNC | last post by:
I have an old C DLL that I want to access via C#. I'm doing this via an outer DLL that wraps the old C DLL in an unmanaged C++ class, which is in turn wrapped in a Managed C++ class. Both these...
0
by: Ewart MacLucas | last post by:
generated some WMI managed classes using the downloadable extensions for vs2003 from mircrosoft downloads; wrote some test code to enumerate the physicall processors and it works a treat, but a...
2
by: amirbehzadan | last post by:
Hello, I am writing some C++ classes and want to export them as .dll files so other users can import them and use the methods I have provided in those classes. I have two types of classes :...
3
by: amirbehzadan | last post by:
Hello, I am writing some C++ classes and want to export them as .dll files so other users can import them and use the methods I have provided in those classes. I have two types of classes :...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.