Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - /clr:safe

Reply
 
Old 06-18-2008   #1 (permalink)
ajk


 
 

/clr:safe

Hi

I am doing a C++/CLI dll that is supposed to be fully managed code. I
was wondering what exactly is the criteria for the DLL to be 100%
fully managed and usuable from C#? Do I need to compile using /
clr:safe or is /clr enough?

The reason I need to know this is that I would like to use pin_ptr<>
for some type conversions i.e. bytes to say decimal but /clr:safe
doesn't allow me to do much with that pointer.

tia
ajk

My System SpecsSystem Spec
Old 06-19-2008   #2 (permalink)
Jeroen Mostert


 
 

Re: /clr:safe

ajk wrote:
Quote:

> I am doing a C++/CLI dll that is supposed to be fully managed code. I
> was wondering what exactly is the criteria for the DLL to be 100%
> fully managed and usuable from C#?
These are two different things. In fact, to be useful from C#, a DLL does
not have to be managed at all.
Quote:

> Do I need to compile using / clr:safe or is /clr enough?
/clr is enough if you just want to be able to call the DLL without interop
wrapping (as unmanaged code would require). Your public interface should be
restricted to managed types, manipulating only managed types. What you do
internally is then of no concern to the outside world.
Quote:

> The reason I need to know this is that I would like to use pin_ptr<>
> for some type conversions i.e. bytes to say decimal but /clr:safe
> doesn't allow me to do much with that pointer.
>
Using /clr:safe restricts you to constructs that allow the DLL to be an
assembly containing only managed code. There are speed and safety benefits
to this, but it is by no means a requirement to be able to use the code from
other managed assemblies.

In fact, there's really not much point to writing pure managed code in
C++/CLI unless you happen to really like C++: the strength of C++/CLI is
exactly that it can mix managed and unmanaged constructs and thus glue the
two worlds together. If you want pure managed code, you might as well use C#.

--
J.
http://symbolsprose.blogspot.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
100% Safe ??? Vista account administration
Is it safe...now? Sound & Audio
How safe am I? Vista General
Is it safe? Vista General
Is It Safe? Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46