非托管dll在Win 10上具有特殊的GAC吗? [英] Is the unmanaged dll have special GAC on win 10?

查看:54
本文介绍了非托管dll在Win 10上具有特殊的GAC吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有两种加载dll的路径:专用路径和全局程序集缓存路径(%SystemRoot%\ Miscrosoft.NET \ assembly)

I knew there are two path to load the dll: private path and global assembly cache path(%SystemRoot%\Miscrosoft.NET\assembly)

但是,我发现我的同事将一个不受管的dll放入了%SystemRoot%\ SysWow64 \和%SystemRoot%\ System32 \

but, I found my coworker put one unmanaged dll to %SystemRoot%\SysWow64\ and %SystemRoot%\System32\

应用程序运行得很好.

我想知道.net如何加载非托管dll的机制.

I want to know the mechanism that how the .net load the unmanaged dll.

推荐答案


嗨CrazyOldPotato,


Hi CrazyOldPotato,

>>我想知道.net如何加载非托管dll的机制.

托管代码不会编译为机器代码,而是编译为无法直接在计算机上运行但可以直接在计算机上运行的IL(中间语言).在CLR(公共语言运行时)上运行. IL与描述以下内容的元数据一起保存在称为程序集的文件中 您创建的代码的类,方法和属性(例如安全要求).安装了公共语言运行时的每台计算机都有一个计算机范围的CLI程序集缓存,称为通用语言基础结构的全局程序集缓存 (CLI).该全局程序集缓存存储了.NET程序集,这些程序专门指定供该计算机上的多个应用程序共享. CLR提供各种服务,例如安全性,内存管理,线程,垃圾回收,性能 改进,跨语言集成等.所以我们说应用程序由运行时管理到您正在运行的代码中.

The Managed code is not compiled to machine code but to an IL (intermediate language) which could not run directly on the computer but  run on CLR (Common Language Runtime). The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. Each computer wherein the common language runtime is installed has a machine-wide CLI assembly cache called the Global Assembly Cache for the Common Language Infrastructure (CLI). This Global Assembly Cache stores .NET assemblies specifically designated to be shared by several applications on that computer.  CLR offers a wide variety of services such as security, memory management, threading, Garbage collection, Performance improvements, cross-language integration, and so on. So we say the application is managed by the runtime to your running code.

用于将非托管代码编译为机器代码(例如本机代码API,例如Win32 API) 可以直接在发布Visual Studio .NET 2002之前使用的计算机上运行,​​Visual Basic 6,Visual C ++ 6,甚至 这么多年的C编译器,您可能仍然在硬盘驱动器上产生了所有产生的非托管代码.

For unmanaged code is compiled to machine code (such as native code APIs, such as Win32 API)  can be run directly on the computer which is you use to make before Visual Studio .NET 2002 was released, Visual Basic 6, Visual C++ 6, heck, even that many long years old C compiler you may still have kicking around on your hard drive all produced unmanaged code.

我们经常遇到一些需要调用非托管代码的库代码,有两种机制可以从托管代码调用非托管平面API:平台调用和C ++ interop.
对于Platform Invoke,C#代码可以通过两种方式直接调用非托管代码:

We often encounter some library code needs to call into unmanaged code, there are two mechanisms for calling into unmanaged flat APIs from managed code:  Platform Invoke  and C++ interop .
For Platform Invoke ,There are two ways that C# code can directly call unmanaged code:

•直接调用从DLL导出的函数.
•在COM对象上调用接口方法(有关更多信息,请参见COM Interop第1部分:C#客户端教程).

• Directly call a function exported from a DLL.
• Call an interface method on a COM object (for more information, see COM Interop Part 1: C# Client Tutorial).

更多详细信息,请参阅: https://msdn.microsoft.com/zh-CN/library/aa288468(v=vs.71).aspx

More details please refer  : https://msdn.microsoft.com/en-us/library/aa288468(v=vs.71).aspx

有关C ++互操作的更多详细信息,请参阅: https://msdn.microsoft.com/zh-CN/library/2x8kf7zx.aspx

For C++ interop, more details please refer  : https://msdn.microsoft.com/en-us/library/2x8kf7zx.aspx

以下是您可能感兴趣的一些主题:

Below is some of the topics you may be interested in :

全局程序集缓存
https://msdn.microsoft.com/en-us/library/yf1d93sz (v = vs.110).aspx

Global Assembly Cache
https://msdn.microsoft.com/en-us/library/yf1d93sz(v=vs.110).aspx

特殊文件夹和自定义文件夹
https://msdn.microsoft.com/en-us/library/s2esdf4x (v = vs.100).aspx

Special Folders and Custom Folders
https://msdn.microsoft.com/en-us/library/s2esdf4x(v=vs.100).aspx

托管执行过程
https://msdn.microsoft.com/en-us/library/k5532s8a (v = vs.110).aspx

Managed Execution Process
https://msdn.microsoft.com/en-us/library/k5532s8a(v=vs.110).aspx

方法:将本机DLL添加到全局程序集缓存中
https://msdn.microsoft.com/en-us/library/thzbdxx7.aspx

How to: Add Native DLL to Global Assembly Cache
https://msdn.microsoft.com/en-us/library/thzbdxx7.aspx

使用非托管DLL函数
https://msdn.microsoft.com/en-us/library/26thfadc (v = vs.110).aspx

Consuming Unmanaged DLL Functions
https://msdn.microsoft.com/en-us/library/26thfadc(v=vs.110).aspx

与非托管代码互操作
https://msdn.microsoft.com/en-us/library/sd10k43k (v = vs.110).aspx

Interoperating with Unmanaged Code
https://msdn.microsoft.com/en-us/library/sd10k43k(v=vs.110).aspx

希望这些对您有所帮助.

Hope these would be helpful to you.

最好的问候,

Yohann Lu

Yohann Lu


这篇关于非托管dll在Win 10上具有特殊的GAC吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆