How will you accomplish the task?

You work as the application developer at Domain.com.
You are working on an application and want to use platform invoke services to call an unmanaged function from managed code.
How will you accomplish the task?

You work as the application developer at Domain.com.
You are working on an application and want to use platform invoke services to call an unmanaged function from managed code.
How will you accomplish the task?

A.
Create a class to store DLL functions. Create prototype methods by using the managed code.

B.
Use COM to register the assembly. Reference the managed code from COM.

C.
Export a type library for the managed code.

D.
Import a type library as an assembly. Create instances of COM object.

Explanation:
It is good practice to wrap the messy P-Invoke code with a .net class. The main benefit is to keep the client code tidy as the messy and cryptic code will be hidden away. Also better for maintenance e.g dll name or version changes. The question explicitly says the unmanaged code should be called with platform invoke services. Importingexporting a type library is relevant for interoperation with COM.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


mr_tienvu

mr_tienvu

Correct answer is A