DefaultDllImportSearchPathsAttribute 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定用于搜索提供平台调用函数的 DLL 的路径。
public ref class DefaultDllImportSearchPathsAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class DefaultDllImportSearchPathsAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Method, AllowMultiple=false)]
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class DefaultDllImportSearchPathsAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Method, AllowMultiple=false)>]
type DefaultDllImportSearchPathsAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Method, AllowMultiple=false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type DefaultDllImportSearchPathsAttribute = class
inherit Attribute
Public NotInheritable Class DefaultDllImportSearchPathsAttribute
Inherits Attribute
- 继承
- 属性
应用于程序集时,此属性指定默认情况下用于在程序集中的任何代码中搜索为平台调用提供函数的任何 DLL 的路径。 当应用于单个平台调用时,此属性将替代为程序集指定的默认搜索路径。
对于任何指定绝对路径的平台调用,都会忽略此属性。
使用此属性可防止 Win32 LoadLibraryEx
函数搜索当前工作目录。 这有助于保护应用程序免受恶意软件将 DLL 置于当前工作目录中的攻击,以便在平台调用 Win32 LoadLibraryEx
函数时,函数的默认搜索顺序会查找恶意 DLL,而不是要查找的系统 DLL。
公共语言运行时根据以下算法处理对 LoadLibraryEx 函数的调用:
如果特性应用于单个平台调用,请使用该特性实例指定的值。
否则,如果特性应用于包含平台调用的程序集,请使用该特性实例指定的值。
否则,搜索程序集目录,
LoadLibraryEx
然后使用 标志调用 函数LOAD_WITH_ALTERED_SEARCH_PATH
。
此属性对非 Windows 平台或 Mono 运行时没有影响。
Default |
初始化 DefaultDllImportSearchPathsAttribute 类的新实例,该实例指定在搜索目标平台调用时使用的路径。 |
Paths |
获取枚举值的按位组合,这些值指定函数在平台调用期间搜索的路径 |
Type |
在派生类中实现时,获取此 Attribute 的唯一标识符。 (继承自 Attribute) |
Equals(Object) |
返回一个值,该值指示此实例是否与指定的对象相等。 (继承自 Attribute) |
Get |
返回此实例的哈希代码。 (继承自 Attribute) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Is |
在派生类中重写时,指示此实例的值是否是派生类的默认值。 (继承自 Attribute) |
Match(Object) |
当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 (继承自 Attribute) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
_Attribute. |
将一组名称映射为对应的一组调度标识符。 (继承自 Attribute) |
_Attribute. |
检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 (继承自 Attribute) |
_Attribute. |
检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute) |
_Attribute. |
提供对某一对象公开的属性和方法的访问。 (继承自 Attribute) |
产品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |