Tuesday, May 13, 2008

Explain how to use the PrintPreviewDialog control to display a preview of a printed document before it is printed.

You display a preview of a printed document with the PrintPreviewDialog control by first setting the PrintDocument property of the PrintPreviewDialog instance to the PrintDocument you want to preview, then by calling the PrintPreviewDialog.Show command to display the dialog box.

Explain the difference between Globalization and Localization.

Globalization refers to the application of culture-specific format to existing data. Localization refers to providing new culture-specific resources and retrieving the appropriate resources based on the culture setting.

Explain how to convert data in legacy code page formats to the Unicode format.

You can use the Encoding.Convert method to convert data between encoding types. This method requires instances of both encoding types and an array of bytes that represents the data to be converted. It returns an array of bytes in the target format. You can convert a string or array of chars to an array of bytes with the Encoding.GetBytes method and can convert an array of bytes back to chars with the Encoding.GetChars method.

Describe how to create localized versions of a form.

To create a localized version of a form, set the Localizable property to true. Then set the Language property to the language/region for which you want to create the localized form. Make any localization-related changes in the UI. The changed property values will automatically be stored in resource files and loaded when the CurrentUICulture is set to the appropriate CultureInfo.

Explain how to use the HelpProvider component to provide help for UI elements.

You can provide either a HelpString or a help topic for UI elements with the HelpProvider. The HelpProvider provides HelpString, HelpKeyWord, and HelpNavigator properties for each control on the form. If no value for the HelpProvider.HelpNameSpace is set, the HelpString will be provided as help. If the HelpNameSpace is set, the HelpProvider will display the appropriate help topic as configured by the HelpKeyWord and HelpNavigator properties. Help for a particular element is displayed when the element has the focus and the F1 key is pressed.

Briefly describe the five accessibility requirements of the Certified for Windows logo program.

The five requirements are

Support standard system settings. This requires your application to ­be able to conform to system settings for colors, fonts, and other UI elements.

Be compatible with High Contrast mode. This requirement can be met by using only the System palette for UI colors.

Provide documented keyboard access for all UI features. Key points in this requirement are shortcut keys and accessible documentation.

Provide notification of the focus location. This requirement is handled primarily by the .NET Framework.

Convey no information by sound alone. This requirement can be met by providing redundant means of conveying information.

Explain how to use the Begin and End methods on a Web Service to make an asynchronous method call.

Every public Web method on a Web Service can be called either synchronously or asynchronously. To make an asynchronous call to a Web method, you call the method named Begin, where is the name of the method. This method requires a delegate to an appropriate callback method and returns a value of IAsyncResult. This value is returned as a parameter in the callback method. To retrieve the data returned by the Web method, call End, supplying a reference to the IAsyncResult returned by Begin. This will allow you to retrieve the actual data returned by the Web method.

Briefly describe how to use the PrintDocument component to print a document. Discuss maintaining correct line spacing and multipage documents

The PrintDocument class exposes the Print method, which raises the PrintPage event. Code to render printed items to the printer should be placed in the PrintPage event handler. The PrintPage event handler provides the objects required to render to the printer in an instance of the PagePrintEventArgs class. Content is rendered to the printer using the Graphics object provided by PagePrintEventArgs. You can calculate correct line spacing by dividing the height of the MarginBounds property by the height of the font you are rendering. If your document has multiple pages, you must set the PagePrintEventArgs.HasMorePages property to true, which causes the PrintPage event to fire again. Because the PrintPage event handler retains no inherent memory of how many pages have been printed, you must incorporate all logic for printing multiple pages into your event handler.

Describe how to create a form or control with a nonrectangular shape.

Set the Region property of the form or control to a Region object that contains the irregular shape. You can create a Region object from a GraphicsPath object.

Describe the role of the LicenseProvider in control licensing.

The LicenseProvider controls license validation and grants run-time licenses to validly licensed components. The LicenseManager.Validate method checks for an available license file and checks against the validation logic provided by the specific implementation of LicenseProvider. You specify which LicenseProvider to use by applying the LicenseProviderAttribute.

Describe the general procedure for rendering text to a drawing surface.

You must first obtain a reference to a Graphics object. Next, create an instance of a GraphicsPath object. Use the GraphicsPath.AddString method to add text to the GraphicsPath. Then, call the Graphics.DrawPath or Graphics.FillPath to render the text.

Describe the roles of Graphics, Brush, Pen, and GraphicsPath objects in graphics rendering.

The Graphics object represents a drawing surface and encapsulates methods that allow graphics to be rendered to that surface. A Brush is an object that is used to fill solid shapes, and a Pen is used to render lines. A GraphicsPath object represents a complex shape that can be rendered by a Graphics object.

Briefly describe the three types of user-developed controls and how they differ.

The three types of user-developed controls are inherited controls, user controls, and custom controls. An inherited control derives from a standard Windows Forms control and inherits the look, feel, and functionality of that control. User controls allow you to combine standard Windows Forms controls and bind them together with common functionality. Custom controls inherit from Control and are the most development-intensive kind of control. Custom controls must implement all their own code for painting and inherit only generic control functionality. All specific functionality must be implemented by the developer

Briefly describe how a class is similar to a structure. How are they different?

Both classes and structures can have members such as methods, properties, and fields, both use a constructor for initialization, and both inherit from System.Object. Both classes and structures can be used to model realworld objects.

Classes are reference types, and the memory that holds class instances is allocated on the heap. Structures are value types, and the memory that holds structure instances is allocated on the stack.

Do you need to instantiate a class before accessing a Shared (static) member? Why or why not?

Because a Shared (static) member belongs to the type rather than to any instance of the type, you can access the member without first creating an instance of the type.

Briefly explain the difference between Public (public), Friend (internal), and Private (private) access levels as they apply to user-defined types and

In user-defined types, Public (public) classes can be instantiated by any element of the application. Friend (internal) classes can be instantiated only by members of the same assembly, and Private (private) classes can be instantiated only by themselves or types they are nested in. Likewise, a Public (public) member can be accessed by any client in the application, a Friend (internal) member can be accessed only from members of the same assembly, and Private (private) members can be accessed only from within the type.

Explain what constructors and destructors are and describe what they are used for.

The constructor is the method that initializes a class or structure and is run when a type is first instantiated. It is used to set default values and perform other tasks required by the class. A destructor is the method that is run as the object is being reclaimed by garbage collection. It contains any code that is required for cleanup of the object.

Briefly describe what members are, and list the four types of members.

Members are the parts of a class or a structure that hold data or implement functionality. The primary member types are fields, properties, methods, and events.

Briefly describe how garbage collection works.

The garbage collector is a thread that runs in the background of managed .NET applications. It constantly traces the reference tree and attempts to find objects that are no longer referenced. When a nonreferenced object is found, its memory is reclaimed for later use.

How do you enable your application to use .NET base class library members without referencing their fully qualified names?

Use the Imports keyword (Visual Basic .NET) or the using keyword (Visual C#) to make a .NET Framework namespace visible to your application.

Briefly explain what is meant by a reference type and a value type.

A value type holds all of the data represented by the variable within the variable itself. A reference type contains a reference to a memory address that holds the data instead of the actual data itself.

Briefly describe the major components of the .NET Framework and describe what each component does.

The .NET Framework consists of two primary parts: the common language runtime, which manages application execution, enforces type safety, and manages memory reclamation, and the .NET base class library, which consists of thousands of predeveloped classes that can be used to build applications.

Friday, May 9, 2008

What tasks does the common language runtime perform to locate and bind an assembly?

The common language runtime performs the following tasks, in the order listed, to locate and bind to assemblies:

Determines the correct assembly version

Checks for the previously loaded assembly

Checks the global assembly cache

Locates the assembly through the codebase setting or probing

What are Merge Module projects?

Merge Module projects enable you to install and deploy components consistently. Merge Module projects ensure that the correct version of a component is installed on the target computer. A Merge Module project contains a component such as a DLL along with dependent files, resources, registry entries, and setup logic. You cannot install merge modules directly. The modules are merged with an .msi file for each application that uses the component. This ensures that the component is installed consistently for all applications, eliminating problems such as version conflicts, missing registry entries, and improperly installed files. A merge module contains unique version information that the Windows Installer database uses to determine which applications can use the component, preventing the premature removal of a component. Therefore, a new merge module is created for every incremental version of a component. You should not update a merge module after including the module in an installer. The deployment tools in Visual Studio .NET make it easy to create Merge Modules and include them in installers for your applications.

Which attribute do you use to specify the version number of an assembly?

You use the AssemblyVersion() attribute to specify the version of an assembly.

What is the format of the assembly version stored in the AssemblyInfo file?

The assembly version number is a four-part number. The format of the version number is

<\major version>...

What are the deployment features of the .NET Framework?

The .NET Framework provides the following deployment features:

No-impact applications

Private components

Controlled code sharing

Side-by-side versioning

Xcopy deployment

On-the-fly updates

Integration with Microsoft Windows Installer

Enterprise deployment

Downloading and caching

Partially trusted code

What are application domains?

Application domains are the boundaries within which applications run. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To access the code running in another application domain, an application needs to use a proxy.

What are the different types of configuration files that the .NET Framework provides?

Machine configuration file. This file is located in the %runtime installation path%\Config directory. The machine configuration file contains settings that affect all the applications that run on the machine.

Application configuration file. This file contains the settings required to configure an individual application. ASP.NET configuration files are named Web.config, and application configuration files are named App.exe.config, where App.exe is the name of the executable.

Security configuration file. The security configuration files contain security permissions for a hierarchy of code groups. The security configuration files define the enterprise-level, machine-level, and user-level security ?policies. The Enterprisesec.config file defines the security policies for the enterprise. The machine-level Security.config file defines the security policy for the machine, whereas the user-level Security.config file defines the security policy for a user.

What are the different types of assemblies?

The different types of assemblies include

Static and dynamic assemblies

Private and shared assemblies

Single-file and multiple-file assemblies

What are the functions of the components of the common language runtime?

The components of the common language runtime provide the run-time environment and run-time services for .NET applications. These components also load the IL code of a .NET application into the runtime, compile the IL code into native code, execute the code, and enforce security. In addition, these components implement type safety and provide automatic memory management.

What are the development tools and operational systems that .NET provides to build, deploy, and integrate applications?

.NET provides the following development tools and operational systems:

Smart Client Software

.NET Server Infrastructure

XML Web Services

Microsoft Visual Studio .NET and the .NET Framework