Set - 1

Question 11 :

How do you directly call a native function exported from a DLL? 

Answer :

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 example 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.


Question 12 :

How do I simulate optional parameters to COM calls?

Answer :

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.


Question 13 :

What do you know about .NET assemblies?

Answer :

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.


Question 14 :

What's the difference between private and shared assembly?

Answer :

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.


Question 15 :

What's a strong name? 

Answer :

A strong name includes the name of the assembly, version number, culture identity, and a public key token.