Team LiB
Previous Section Next Section

Creating and Managing Components and .NET Assemblies

To ensure that a network share is valid, you should call the Exists method of the Directory class and ensure that it returns true.

You can use regasm to make a C# DLL available to other development environments such as Visual Basic 6, as in this example:

regasm /tlb:MyDll.tlb /codebase c:\MyDLL.DLL

To use a .NET component in Visual Basic 6, you need to register the component with Regasm.exe.

By changing the apply attribute of the publisherPolicy element in the Application.config.exe file to No, a publisher policy can be used to allow an application to run an updated version of an assembly. Otherwise, the application will always load the version of the assembly with which it was compiled.

In order to run an application that uses a specific version of an assembly, you must sign the assembly using sn.exe. This will give the assembly a strong name.

You can use Wsdl.exe to generate proxy classes for exposed Web Services and send them to your customers for use.

If you create a class with this code:

ClassA Test = new ClassB();
Test.MyMethod();

and ClassB is a derived class of ClassA, the class type that you are creating with the new class methods will be called.

The typeof keyword is used to tell if a class is derived from a base class.

The following are valid constructors for the MyObject class:

public MyCache()
public MyCache(int MyInt)

The following code:

object Test = new MyObject()

can be optimized like this:

MyObject Test = new MyObject()

The sealed keyword can prevent users from overriding or deriving a new class from this class.

PathTooLongException is a System.IO exception that can be used when dealing with file access.

When two people using Visual Source Safe (VSS) check out the same file and both have made changes, you should have one user check in his or her changes, and then have another user retrieve the latest code and resolve any conflicts.

You can use the ToolboxItemFilterAttribute to add a custom control's icon in the .NET IDE toolbox.

To end a print job, you should set the HasMorePages property of the P rintPageEventArgs class to false . This instructs the PrintDocument object to complete the print job and call the EndPrint event.

The CausesValidation property determines if the Validating event fires. If this property is set to true, it determines if the Validating event can fire the Validated and LostFocus events.

A form's Load event can be used to read configuration options from an XML file.

The ExecuteNonQuery method of SqlCommand is used to process T-SQL statements that delete, insert, and update. The method returns an int with the number of rows that were deleted, inserted, or updated.


Team LiB
Previous Section Next Section