How do you directly call a native function exported from a DLL?
Here’s a quick example of the DllImport attribute in action:using System.Runtime.InteropServices; \class C{[DllImport(\"user32.dll\")]public static extern int MessageBoxA(int h, string m, string c, int type);public static int Main(){return MessageBoxA(0, \"Hello World!\", \"Caption\", 0);
}
}
This shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA.
For more information, look at the Platform Invoke tutorial in the documentation.
How do I simulate optional parameters to COM calls?
You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.
What do you know about .NET assemblies?
Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.
What’s the difference between private and shared assembly?
Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.
What’s a strong name?
A strong name includes the name of the assembly, version number, culture identity, and a public key token.
0 comments:
Post a Comment