PDA

View Full Version : سوال: CLR چیست؟



mazaher5723
جمعه 01 دی 1391, 22:01 عصر
سلام اساتید
CLR چیه؟
مطالعه این کتاب چه سودی داره؟
بدرد چی می خوره؟

دوستان و اساتید محترم ممنونم میشم جواب منو بدین
گیر کردم

danialafshari
شنبه 02 دی 1391, 01:25 صبح
سلام دوست عزیز

خلاصه :
(Common Language Runtime)CLR
یک موتور اجرایی است که با هدف اصلی اجرای هدایت شده کدها در .Net ایجاد گردیده است. CLR به مدیریت اجرا، ارتقای نسخه و امنیت تمامی کدها در .Net می‌پردازد. به همین دلیل کدهای .Net یا C#‎ اغلب تحت عنوان کدهای مدیریت شده، شناخته می‌شوند.(Managed Code) تمامی کدهایی که به CLR مرتبط هستند، تحت عنوان "مدیریت شده" و کدهایی توسط CLR مدیریت نشده‌اند، بلکه مستقیماً به کد ماشین تبدیل می‌شوند، تحت عنوان "مدیریت نشده" بیان می‌شوند.
کدهای مدیریت شده، به کد ماشین کامپایل نمی‌شوند، بلکه به زبان سطح میانی مایکروسافت(MSIL) کامپایل شده و مورد استفاده قرار می‌گیرند. این زبان سطح میانی را می‌توان زبانی شبیه به زبان اسمبلی تصور کرد. IL در حافظه بارگذاری می‌شود و بلافاصله بوسیلة CLR در حافظه به کد ماشین کامپایل می‌گردد.

این مقاله رو دانلود کنی و بخونی کامل متوجه میشی

موفق باشی

mazaher5723
شنبه 02 دی 1391, 14:23 عصر
مهندس ممنون از لطفتون ولی بدرد چی می خوره؟؟؟؟؟
مثلا می خواد طراحی و پیاده سازیشو توضیح بده؟

tooraj_azizi_1035
شنبه 02 دی 1391, 19:08 عصر
بدرد این می خوره که اجرای کد شما رو مدیریت کنه.
کدی که شما در دات نت به یه زبون می نویسی ابتدا به intermediate language تبدیل میشه. Common language همین IL هست که گفتم.
مدیریت کد شامل type-safety، exception handling و code access security و ... میشه.
باید این متن رو بخونی تا بفهمی به چه دردی میخوره:

The .NET Framework provides a run-time environment called the common language runtime, which runs the code and provides services that make the development process easier.
Compilers and tools expose the common language runtime's functionality and enable you to write code that benefits from this managed execution environment. Code that you develop with a language compiler that targets the runtime is called managed code; it benefits from features such as cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.
Caution
Compilers and tools are able to produce output that the common language runtime can consume because the type system, the format of metadata, and the runtime environment (the virtual execution system) are all defined by a public standard, the ECMA Common Language Infrastructure specification. For more information, see ECMA C# and Common Language Infrastructure Specifications.
To enable the runtime to provide services to managed code, language compilers must emit metadata that describes the types, members, and references in your code. Metadata is stored with the code; every loadable common language runtime portable executable (PE) file contains metadata. The runtime uses metadata to locate and load classes, lay out instances in memory, resolve method invocations, generate native code, enforce security, and set run-time context boundaries.
The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Objects whose lifetimes are managed in this way are called managed data. Garbage collection eliminates memory leaks as well as some other common programming errors. If your code is managed, you can use managed data, unmanaged data, or both managed and unmanaged data in your .NET Framework application. Because language compilers supply their own types, such as primitive types, you might not always know (or need to know) whether your data is being managed.
The common language runtime makes it easy to design components and applications whose objects interact across languages. Objects written in different languages can communicate with each other, and their behaviors can be tightly integrated. For example, you can define a class and then use a different language to derive a class from your original class or call a method on the original class. You can also pass an instance of a class to a method of a class written in a different language. This cross-language integration is possible because language compilers and tools that target the runtime use a common type system defined by the runtime, and they follow the runtime's rules for defining new types, as well as for creating, using, persisting, and binding to types.
As part of their metadata, all managed components carry information about the components and resources they were built against. The runtime uses this information to ensure that your component or application has the specified versions of everything it needs, which makes your code less likely to break because of some unmet dependency. Registration information and state data are no longer stored in the registry where they can be difficult to establish and maintain. Instead, information about the types you define (and their dependencies) is stored with the code as metadata, making the tasks of component replication and removal much less complicated.
Language compilers and tools expose the runtime's functionality in ways that are intended to be useful and intuitive to developers. This means that some features of the runtime might be more noticeable in one environment than in another. How you experience the runtime depends on which language compilers or tools you use. For example, if you are a Visual Basic developer, you might notice that with the common language runtime, the Visual Basic language has more object-oriented features than before. The runtime provides the following benefits:
Performance improvements.
The ability to easily use components developed in other languages.
Extensible types provided by a class library.
Language features such as inheritance, interfaces, and overloading for object-oriented programming.
Support for explicit free threading that allows creation of multithreaded, scalable applications.
Support for structured exception handling.
Support for custom attributes.
Garbage collection.
Use of delegates instead of function pointers for increased type safety and security. For more information about delegates, see Common Type System.

MOR_MS
پنج شنبه 05 بهمن 1391, 17:05 عصر
سلام
من به تازگي برنامه ام رو تغير دادم و به بentity framwework برگردوندم پروژه ركورد هاش بيش از يك ميلون خواهد شد در اين پست (http://barnamenevis.org/showthread.php?378706-%DA%A9%D8%A7%D8%B1%D8%A7%DB%8C%DB%8C-Entity-Framework-%D8%AF%D8%B1-%D9%BE%D8%B1%D9%88%DA%98%D9%87-%D9%87%D8%A7%DB%8C-%D8%A8%D8%B2%D8%B1%DA%AF&highlight=entity)دوستان گفتن براي پروژه هاي بزگ به مشكل برميخويرم كه خيلي دلسرد شدم ميخواستم ببينم استفاده از CLR چگونه است آيا بايد تمام كد ها را عوض منم ؟ نحوه استفاده در پروژه ام چگونه است ؟
(http://barnamenevis.org/showthread.php?378706-%DA%A9%D8%A7%D8%B1%D8%A7%DB%8C%DB%8C-Entity-Framework-%D8%AF%D8%B1-%D9%BE%D8%B1%D9%88%DA%98%D9%87-%D9%87%D8%A7%DB%8C-%D8%A8%D8%B2%D8%B1%DA%AF&highlight=entity)

FastCode
پنج شنبه 05 بهمن 1391, 20:05 عصر
مثل اینه که بگی از گوشت کوبیده استفاده کنم یا گوشت کوب
تا CLR نباشه برنامه ای نیست

Programmer 1
سه شنبه 10 بهمن 1391, 14:04 عصر
سلام
من به تازگي برنامه ام رو تغير دادم و به بentity framwework برگردوندم پروژه ركورد هاش بيش از يك ميلون خواهد شد در اين پست (http://barnamenevis.org/showthread.php?378706-%DA%A9%D8%A7%D8%B1%D8%A7%DB%8C%DB%8C-Entity-Framework-%D8%AF%D8%B1-%D9%BE%D8%B1%D9%88%DA%98%D9%87-%D9%87%D8%A7%DB%8C-%D8%A8%D8%B2%D8%B1%DA%AF&highlight=entity)دوستان گفتن براي پروژه هاي بزگ به مشكل برميخويرم كه خيلي دلسرد شدم ميخواستم ببينم استفاده از CLR چگونه است آيا بايد تمام كد ها را عوض منم ؟ نحوه استفاده در پروژه ام چگونه است ؟
(http://barnamenevis.org/showthread.php?378706-%DA%A9%D8%A7%D8%B1%D8%A7%DB%8C%DB%8C-Entity-Framework-%D8%AF%D8%B1-%D9%BE%D8%B1%D9%88%DA%98%D9%87-%D9%87%D8%A7%DB%8C-%D8%A8%D8%B2%D8%B1%DA%AF&highlight=entity)
دوست من CLR محیط اجرای برنامه های دات نته اصلا با بحث performance پروژه بانک اطلاعاتی شما در ارتباط نیست (البته شاید هم بخواهید مستقیما با کد IL برنامه تون رو بنویسید!) ، شما اگه می خواهید کارایی برنامه تون رو بالا ببرید باید کد برنامه تون رو بهینه سازی کنید ، مثلا Ado.net با توجه به اینکه نزدیکترین لایه ارتباطی با بانک اطلاعاتیه به جای Entity Framework توصیه میشه برای پروژتون استفاده کنید تا دست شما در تغییر کد آزاد تر باشه ، همچنین سعی کنید بیشتر پردازش مرتبط با بانک رو به انجین بانک اطلاعاتی تون مثل Sql Serverو ... بسپارید ، مثلا از Stored procedure ها استفاده کنید و برای جستجو از View ها و ایندکس های بانک استفاده کنید ، شما باید دنبال بهینه سازی کدی که نوشتید باشید نه دنبال معجزه! ، مطمئن باشید اگه پروژتون رو به Ado.net هم برگردونید و روی بهینه سازیش کار نکنید باز هم با مشکل کاهش سرعت و کارایی مواجه خواهید شد ، مشکل کاهش پرفرمنس فقط بخشیش به ORM مورد استفاده بر میگرده و بخش اعظمی از اون مرتبط با نحوه کد نویسی ماست. دات نت یک جعبه ابزار بزرگه که میتونید ازش به خوبی استفاده کنید و اپلیکیشن های مفید و کارایی بسازید و دیگران رو تشویق به استفاده از دات نت کنید! و یا آنچنان ازش بد استفاده کنید که نه تنها خودتون بلکه هر کسی که با برنامه تون کار کنه نظرش در مورد دات نت کاملا برگرده!.