DllImportAttribute Constructor (String^)

 

Initializes a new instance of the DllImportAttribute class with the name of the DLL containing the method to import.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public:
DllImportAttribute(
	String^ dllName
)

Parameters

dllName
Type: System::String^

The name of the DLL that contains the unmanaged method. This can include an assembly display name, if the DLL is included in an assembly.

If an unmanaged DLL file is included in an assembly, for example, by using the linker or the /linkresource compiler option, you can specify the assembly display name as part of dllName. For example, if an unmanaged DLL named unmanaged.dll is included in a managed assembly named MyAssembly, the attribute might be specified as shown in the following code.

[DllImport("unmanaged.dll, MyAssembly, Version= 1.0.0.0,"
 "Culture=neutral, PublicKeyToken=a77e0ba5eab10125")]
int SomeFuncion1(int parm);

The following code example shows how to use the DllImportAttribute attribute to import the Win32 MessageBox function. The code example then calls the imported method.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: