简体   繁体   中英

How can I distinguish between managed & unmanaged code in C#

As per MSDN,

Managed Code - Code that could be understood and managed by CLR

Unmanaged Code - Code that could not handled by CLR 

But I am wondering how do I identify which resource or class is CLR compliant & which Not.

I referred below links

If I am using EF (LINQ to Entities), it is translated to native SQL. SO all LINQ falls under Unmanaged Code category?

Thanks!

"unmanaged" here is referring to in-process execution of non-CLR code (don't confuse that with "CLR compliant", whatever that might mean); so - EF and LINQ are managed (or mostly managed), but they often talk indirectly to unmanaged dlls (think: C/C++ dlls, etc - nothing to do with the CLR) at some point - for example, many of the ADO.NET providers are really P/Invoke layers to an unmanaged database drivers - or unsafe code that talks to manually allocated raw memory in the local process (a chunk of memory allocated via Marshal.AllocHGlobal , for example). Usually these exist in a dual state: there's a managed layer that abstracts and hides the unmanaged layer - so application level code rarely talks to unmanaged code directly.

The fact that native SQL is involved is unrelated, as that isn't "managed" or "unmanaged" - it isn't in-process, so it is a different category altogether.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM