Sam Gentile replies to my previous posting:
Umm, there is nothing managed about this "Managed C++" program and thus you will not get any of the CLR benefits. I think you may be confused about Managed C++ and this is common. As I say in my book, in Chapter 7, compiling with /clr will not make *any* of your data managed. It just changes compilation to emit IL in an assembly. All of the data is *still unmanaged* and coming from the unmanaged heap. That's why you have the problems above. Only the types you specifically mark with __gc or __value will become managed and the problems will go away.
My understanding is that managed code and managed types are orthogonal to each other. Managed code (produced when using the /clr option) consists of IL and metadata - which is what I see when I compile this sample program and look at its assembly using ILDASM, I don't see any native x86 unmanaged code. ...
and wonder what it is I'm missing. [Cook Computing]
All of it-)) You are incorrect. Just because it's in an assembly doesn't mean you have all managed code. Don't take my word for it? Lets see what Siva Challa and Artur Laksburg, two of the guys on the MC++ team, who wrote the bloody thing, at Microsoft Essential Guide To Managed Extensions... say: "Your classes do NOT automatically become managed when you compile your code with the /clr option. There are several reasons why this is the case. First, because the C++ object model is quite different than that of the CLR, not every unmanaged class can become managed. For example, templates and multiple inheritance cannot be expressed on the CLR. Second, some managed classes can only be created on the GC heap (these are called gc classes) while others can be created on the stack and, with some restrictions, on the C++ or global heap (these classes are called value types). If your managed class is being created both on the stack and on the heap, you cannot make it a gc class or a value type without limiting its functionality. Assuming your class meets all the requirements, you can make it managed by adding the __gc or __value keyword in front of the definition." Just what I said. I hope this is clear and you will correct the incorrect assertions you have on your site.
10:10:20 PM
|
|