Using the IDE Features

You'll find that you need to use wrapper DLLs regularly when creating connections between the .NET Framework and the Win32 API. Using wrapper DLLs enhances code reuse and enables you to use other languages as needed. Of course, this means adding a reference to the external DLL so that you can access the code it contains from within your application. The following steps tell how to add such a reference (the same procedure works whether you use Visual Basic or C#).

1. Right-click the References folder in Solution Explorer and choose Add Reference from the context menu. You'll see an Add Reference dialog box similar to the one shown in Figure 2.8. Notice that there are separate tabs for .NET, COM, and Project related references. Generally, you won't find custom DLLs on any of these tabs, but it always pays to look.

Figure 2.8: The Add Reference dialog box enables you to add custom _references to your application.

2. Locate and select the reference you want to add to your application. Add the reference to the Selected Components list by highlighting it and clicking Select. If you don't see the DLL, you'll need to add it manually as described in Step 3. Otherwise, you can skip Step 3 and proceed to Step 4.

3. Click Browse and you'll see a Select Component dialog box. Use this dialog box as you would any file open dialog box to locate the file containing the executable code. Once you locate the file, highlight it and click Open.

4. Click OK. You should see the new reference added to the Reference folder.

5. Add a statement to use the new reference to your application. For C# developers this means adding a using statement to the beginning of the file. For Visual Basic developers this means adding an Imports statement to the beginning of the file.

Figure 2.8: The Add Reference dialog box enables you to add custom _references to your application.

2. Locate and select the reference you want to add to your application. Add the reference to the Selected Components list by highlighting it and clicking Select. If you don't see the DLL, you'll need to add it manually as described in Step 3. Otherwise, you can skip Step 3 and proceed to Step 4.

3. Click Browse and you'll see a Select Component dialog box. Use this dialog box as you would any file open dialog box to locate the file containing the executable code. Once you locate the file, highlight it and click Open.

4. Click OK. You should see the new reference added to the Reference folder.

5. Add a statement to use the new reference to your application. For C# developers this means adding a using statement to the beginning of the file. For Visual Basic developers this means adding an Imports statement to the beginning of the file.

Was this article helpful?

0 0

Post a comment