Note The Appconfig file of the WCF Service Library project is also useful in that it shows you the barebones settings

In addition to the basic WCF Service Library template, the WCF project category of the New Project dialog box defines two WCF library projects that integrate Windows Workflow Foundation functionality into a WCF service as well as a template to build an RSS library (all of which are also seen in Figure 25-2). The next chapter will introduce you to Windows Workflow Foundation, so I'll ignore these particular WCF project templates for the time being (and I'll leave it to the interested reader to...

Info

The CLR, CTS, CLS, and base class library relationship Figure 1-1. The CLR, CTS, CLS, and base class library relationship What Visual Basic 2008 Brings to the Table Because .NET is such a radical departure from previous Microsoft technologies, it should be clear that legacy COM-based languages such as VB6 are unable to directly integrate with the .NET platform. Given this fact, Microsoft introduced a brand-new programming language, Visual Basic .NET (VB .NET), with the release of...

The Platform Independent Nature of NET

To close this chapter, allow me to briefly comment on the platform-independent nature of the .NET platform. To the surprise of most developers, .NET assemblies can be developed and executed on non-Microsoft operating systems (Mac OS X, numerous Linux distributions, and Solaris, to name a few). To understand how this is possible, you need to come to terms with yet another abbreviation in the .NET universe CLI (Common Language Infrastructure). When Microsoft released the .NET platform, it also...

The Role of the IDbData Adapter and IData Adapter Interfaces

Data adapters are used to push and pull DataSets to and from a given data store. Given this, the IDbDataAdapter interface defines a set of properties that are used to maintain the SQL statements for the related select, insert, update, and delete operations Public Interface IDbDataAdapter Inherits IDataAdapter Property DeleteCommand() As IDbCommand Property InsertCommand() As IDbCommand Property SelectCommand() As IDbCommand Property UpdateCommand() As IDbCommand End Interface In addition to...

Compiling Multiple Source Files Using vbcexe

The current incarnation of the TestApp.exe application was created using a single *.vb source code file. While it is perfectly permissible to have all of your .NET types defined in a single *.vb file, most projects are composed of multiple *.vb files to keep your code base a bit more flexible. Assume you have authored an additional class (again, using Notepad) contained in a new file named HelloMsg.vb MessageBox.Show(Hello Again) End Sub End Class Assuming you have saved this new file in the...

An Interesting Aside Some Additional Members of the System Environment Class

The Environment type exposes a number of extremely helpful methods beyond GetCommandLineArgs(). Specifically, this class allows you to obtain a number of details regarding the operating system currently hosting your .NET application using various shared members. To illustrate the usefulness of System.Environment, update your Main() method with the following logic Shared Function Main(ByVal args As String()) As Integer ' OS running this app Console.WriteLine(Current OS 0 , Environment.OSVersion)...

Fun with Buttons

The role of the System.Windows.Forms.Button type is to provide a vehicle for user confirmation, typically in response to a mouse click or keypress. The Button class immediately derives from an abstract type named ButtonBase, which provides a number of key behaviors for all derived types (such as CheckBox, RadioButton, and Button). Table 29-4 describes some (but by no means all) of the core properties ofButtonBase. FlatStyle Gets or sets the flat style appearance of the Button control, using...

Building NET Applications Using Sharp Develop

While Notepad is fine for creating simple .NET programs, it offers nothing in the way of developer productivity. It would be ideal to author *.vb files using an editor that supports (at a minimum) keyword coloring and integration with the VB compiler. Furthermore, we would hope to build our VB programs using a tool that supports rich IntelliSense capabilities, designers for building graphical user interfaces, project templates, and database manipulation tools. As luck would have it, numerous...

The Visual Studio WCF Project Templates

As will be explained in more detail later in this chapter, a WCF application is typically represented by three interrelated assemblies, one of which is a *.dll that contains the types that external callers can communicate with (in other words, the WCF service itself). When you wish to build a WCF service, it is perfectly permissible to select a standard Class Library project template (see Chapter 15) as a starting point and manually reference the WCF assemblies. Alternatively, you can create a...

Building a WCF Service

Now that you have a better understanding about the building blocks of a WCF application, let's create our first sample application to see how the ABCs are accounted for in code. Our first step is to define our WCF service library consisting of the contracts and their implementations. This first example will not use the Visual Studio WCF project templates, in order to keep focused on the specific steps involved in making a WCF service. To begin, create a new VB Class Library project named...

J

Mscorlib (+) < > Microsoft.Win32 l l- Microsoft.Win32.SafeHandles System 0- System .Coll ecti ons 0- System .Coll ecti ons. G en eri c 0- System .Coll ecti ons. Obj ectM od el 0- System. Conf i g u rati on. Assem bl i es 0- System. Depl oy m ent.Intern a I + System.Diagnostics 0- System. Dia gnostics. Cod eAn a lysis 0- System. Di a g n osti cs. Sym bol Store 0- System. GI oba I izati on 0 System.10 ft New System.IO.Stream, System .Tact. En coding) ft Read ByteO, Integer, Integer As Integer...

Registered Data Provider Factories

Before you build a full example of working with ADO.NET data provider factories, it is important to note that the DbProviderFactories type is able to fetch factories for only a subset of all possible data providers. The list of valid provider factories is recorded within the < DbProviderFactories> element within the machine.config file for your .NET 3.5 installation (which confusingly is located under Note that the value of the invariant attribute is identical to the value passed into the...

Late Binding to the CoCalc Coclass

Once you have generated an interop assembly (using tlbimp.exe or Visual Studio), your .NET applications are now able to make use of their types using early binding or late binding techniques. Given that you have already seen how to create a COM type using early binding at the opening of this chapter (via the VB 2008 New keyword), let's turn our attention to activating a COM object using late binding. As you recall from Chapter 16, the System.Reflection namespace provides a way for you to...

Configuring the Data Adapter Using the Sql CommandBuilder

When you are using a data adapter to modify a database based on the contents of a DataSet, the first order of business is to assign the UpdateCommand, DeleteCommand, and InsertCommand properties with valid command objects (until you do so, these properties return Nothing references). By valid command objects, I am referring to the set of command objects used in conjunction with the table you are attempting to update (the Inventory table in our example). To fill up our adapter with the necessary...

Advanced VB Programming Constructs

Chapter 9 Working with Interface Understanding Interface Defining Custom Implementing an Interacting with Types Supporting Resolving Name Clashes with the Implements Keyword 268 Building Enumerable Types (IEnumerable and IEnumerator) 273 Building Comparable Objects Using Interfaces As a Callback chapter 10 Collections, Generics, and Nullable Data Types 291 The Nongeneric Types of System.Collections.Specialized Understanding Boxing and Unboxing Type Safety and Strongly Typed The...

About the Author

ANDREW TROELSEN is a Microsoft MVP (Visual C ) and a partner, trainer, and consultant with Intertech Training (http www.Intertech.com), a .NET and J2EE developer education center. He is the author of numerous books, including Developer's Workshop to COM and ATL 3.0 (Wordware Publishing, 2000), COM and .NETInteroperability (Apress, 2002), Visual Basic .NET and the .NET Platform An Advanced Guide (Apress, 2001), and the award-winning C and the .NETPlatform (Apress, 2003). Andrew has also authored...

The Error Event

Another event that may occur during your page's life cycle is Error. This event will be fired if a method on the Page-derived type triggered an exception that was not explicitly handled. Assume that you have handled the Click event for a given Button on your page, and within the event handler (which I named btnGetFile_Click), you attempt to write out the contents of a local file to the HTTP response. Also assume you have failed to test for the presence of this file via standard structured...

Hit Testing Nonrectangular Images

Now, what if you wish to perform a hit test in a nonrectangular region, rather than a simple square Assume you updated your application to render an oddball geometric shape that will also sport an outline when clicked (see Figure 28-21). This geometric image was rendered on the Form using the FillPath() method of the Graphics type. This method takes an instance of a GraphicsPath object, which encapsulates a series of connected lines, curves, and strings. Adding new items to a GraphicsPath...

If myCar is the only reference to the Car object it may be destroyed when the method returns

Notice that the Car reference myCar has been declared within the MakeACar method and has not been passed outside of the defining scope. Thus, once this method call completes, the myCar reference is no longer reachable, and the associated Car object is now a candidate for garbage collection. Understand, however, that you cannot guarantee that this object will be reclaimed from memory immediately after MakeACar has completed. All you can assume at this point is that when the CLR performs the next...

Working with vbcexe Response Files

As you might guess, if you were to build a complex VB 2008 application at the command prompt, your life would be full of pain as you type in the flags that specify numerous referenced assemblies and .vb code files. To help lessen your typing burden, the VB 2008 compiler honors the use of response files. VB 2008 response files contain all the instructions to be used during the compilation of your current build. By convention, these files end in an .rsp response extension. Assume that you have...

Testing the Application

Now fire up your program and enter some XAML into your text area. Do be aware that this program does not allowyou to specify any code generation-centric XAML attributes such as Class or any event handlers . As a test, update the lt StackPanel gt scope as follows lt Rectangle Fill Green Height 40 Width 200 gt lt Button Content OK Height 40 Width 100 gt lt Label Content x Type Label gt lt StackPanel gt Once you click the button, you will see a window appear that renders your XAML definitions or...

Building and Consuming a Multifile Assembly

Now that you have constructed and consumed a single-file assembly, let's examine the process of building a multifile assembly. Recall that a multifile assembly is simply a collection of related modules which has nothing to do with the Visual Basic 2008 Module keyword that are deployed and versioned as a single logical unit. At the time of this writing, Visual Studio 2008 does not support a VB 2008 multifile assembly project template. Therefore, you will need to make use of the command-line...

Defining the Initial Class Type

Open the AutoLotDAL project in Visual Studio 2008, insert a new class type named InventoryDALDisLayer using the Project gt - Add New Item menu option, and ensure you have a public class type in your new code file, wrapped in a new namespace named AutoLotDisconnectedLayer. Unlike the connection-centric InventoryDAL type, this new class will not need to provide custom open close methods, as the data adapter will handle the details automatically. To begin, add a custom constructor that sets a...

This method can receive anything implementing IDraw3D

Sub DrawIn3D ByVal itf3d As IDraw3D Console.WriteLine - gt Drawing IDraw3D compatible type itf3d.Draw3D End Sub If we were to now call this method while cycling through the array of Shapes, only the IDraw3D-compatible types are sent into our new subroutine see Figure 9-5 for output . Dim itfPointy As IPointy For Each s As Shape In myShapes If TypeOf s Is IPointy Then itfPointy CType s, IPointy Console.WriteLine 0 has 1 points., s.PetName, itfPointy.Points Else Console.WriteLine 0 does not...

VB 2008 Attribute Shorthand Notation

If you were reading closely, you may have noticed that the actual class name of the lt Obsolete gt attribute is ObsoleteAttribute, not Obsolete. As a naming convention, all .NET attributes including custom attributes you may create yourself are suffixed with the Attribute token. However, to simplify the process of applying attributes, the VB 2008 language does not require you to type in the Attribute suffix. Given this, the following iteration of the HorseAndBuggy type is identical to the...

Understanding WCF Bindings

Once a contract or a set of contracts has been defined and implemented within your service library, the next logical step is to build a hosting agent for the WCF service itself. As mentioned, you have a variety of possible hosts to choose from, all of which must specify the bindings used by remote callers to gain access to the service type's functionality. Choosing a set of bindings is one area that makes WCF development quite different from .NET remoting and or XML web service development in...

The Repeat Button Type

The final ButtonBase-derived type to discuss is the RepeatButton type, also defined within System.Windows.Controls.Primitives. This type also has a default look and feel to a standard Button however, it supports the ability to continuously fire its Click event when the end user has the widget in a pressed state. The frequency in which it will fire the Cl ick event is dependent upon the values you assign to the Delay and Interval properties both of which are recorded in milliseconds . In...

The System Console Class

Almost all of the example applications created over the course of the initial chapters of this text make extensive use of the System.Console class. While it is true that a console user interface sometimes called a CUI is not as enticing as a graphical user interface GUI or web-based front end, restricting the early examples to console programs will allow us to keep focused on the syntax of Visual Basic and the core aspects of the .NET platform, rather than dealing with the complexities of...

Adding a Code Activity

The first activity you will add in the sequence is a Code activity. To do so, activate the designer, drag a Code activity component from the Windows Workflow Toolbox, and drop it onto the line connecting the starting and ending points of the workflow. Next, use the Properties window to rename this activity as ShowInstructionsActivity using the Name property. At this point, your designer should look like Figure 26-6. Figure 26-6. A not quite ready for prime time Code activity Figure 26-6. A not...

Designing the Status Strip

Statusstrip Visual Studio

Next, place a StatusStrip control onto the designer and rename this control to mainStatusStrip note this control automatically docks to the bottom of the designer window . Initially, a StatusStrip contains no panes whatsoever. To add panes, you may take various approaches Author the code by hand without designer support perhaps using a helper method named CreateStatusStrip that is called in the form's constructor . Add the items via a dialog box activated through the Edit Items link using the...

Note As an alternative you can configure a Grid View using the inline editor Click the smart tag for the Grid View and

If you examine the opening declaration of the GridView control, you will see that the DataSourceID property has been set to the SqlDataSource you just defined lt asp GridView ID GridView1 runat server AutoGenerateColumns False DataKeyNames CarID The SqlDataSource type is where a majority of the action is taking place. In the markup that follows, notice that this type has recorded the necessary SQL statements with parameterized queries no less to interact with the Inventory table of the Cars...

Table 2711 Members of the Tool StripMenu Item Type Member Meaning in Life

Checked Gets or sets a value indicating whether a check mark appears beside the text of the CheckOnClick Gets or sets a value indicating whether the ToolStripMenuItem should automatically appear checked unchecked when clicked Enabled Gets or sets a value indicating whether the ToolStripMenuItem is enabled Let's extend the previous pop-up menu to display a check mark next to the currently selected menu item. Setting a check mark on a given menu item is not at all difficult just set the Checked...

Building a Polymorphic Interface with Must Override

When a class has been defined as an abstract base class via the MustInherit keyword , it may define any number of abstract members. Abstract members can be used whenever you wish to define a member that does not supply a default implementation. By doing so, you enforce a polymorphic interface on each descendant, leaving them to contend with the task of providing the details behind your abstract methods or properties. Simply put, an abstract base class's polymorphic interface simply refers to...

Table 71 Core Members of the System Exception Type System Exception Property Meaning in Life

Data This property retrieves a collection of key value pairs represented by an object implementing IDictionary that provides additional, user-defined information about the exception. By default, this collection is empty. HelpLink This property returns a URI to a help file describing the error in full InnerException This read-only property can be used to obtain information about the previous exception s that caused the current exception to occur. The previous exception s are recorded by passing...

Exploring the CIL

Recall that an assembly does not contain platform-specific instructions rather, it contains platform-agnostic CIL. When the .NET runtime loads an assembly into memory, the underlying CIL is compiled using the JIT compiler into instructions that can be understood by the target platform. If you double-click the TurboBoost method of the SportsCar class, ildasm.exe will open a new window showing the CIL instructions, looking something like the following .method public hidebysig virtual instance...

The VB Try Cast Keyword

On a final note, VB also offers one final manner to perform runtime type conversions using TryCast . Again, syntactically, TryCast looks identical to CType .The difference is that TryCast returns Nothing if the arguments are not related by inheritance or interface implementation, rather than throwing a runtime exception. Thus, rather than wrapping a call to CType or DirectCast within Try Catch logic, you can simply test the returned reference within a conditional statement. This being said,...

System.data.sqlserverce Version 3.5.0.0 Culture Neutral Publickeytoken 89845dcd8080cc91

lt add name Odbc Data Provider invariant System.Data.Odbc description .Net Framework Data Provider for Odbc System.Data, Version 2.0.0.0, Culture neutral, PublicKeyToken b77a5c561934e089 gt lt add name OleDb Data Provider invariant System.Data.OleDb description .Net Framework Data Provider for OleDb System.Data, Version 2.0.0.0, Culture neutral, PublicKeyToken b77a5c561934e089 gt lt add name OracleClient Data Provider description .Net Framework Data Provider for Oracle...

The RCW Hiding Low Level COM Interfaces

The final core service provided by the RCW is to consume a number of low-level COM interfaces. Because the RCW tries to do everything it can to fool the .NET client into thinking it is communicating with a native .NET type, the RCW must hide various low-level COM interfaces from view. For example, when you build a COM class that supports IConnectionPointContainer and maintains a subobject or two supporting IConnectionPoint , the coclass in question is able to fire events back to the COM client....

Using the Web Centric WCF Service Project Template

Using the File gt - New gt - Web Site menu option, create a new WCF Service named VbAutoLot-WCFService, exposed from the following URI http localhost VbAutoLotWCFService see Figure 25-19 . Be sure the Location drop-down list has HTTP as the active selection. Once you have done so, set a reference to the AutoLotDAL.dll assembly you created in Chapter 22 via the Website gt - Add Reference menu option . Much like a WCF Service Library project, you have been given some example starter code located...

Note Despite the name the Sql DataSource provider can be configured to communicate with anyADONET data provider ODBC

With a few simple mouse clicks, you can configure the GridView to automatically select, update, and delete records of the underlying data store. While this zero-code mindset greatly simplifies the amount of boilerplate code, understand that this simplicity comes with a loss of control and may not be the best approach for an enterprise-level application. This model can be wonderful for low-trafficked pages, prototyping a website, or smaller in-house applications. To illustrate how to work with...

Building a Reusable WF Code Library

These first examples allowed you to play around with various WF activities at design time, interact with the workflow runtime engine by passing custom parameters , and get into the overall WF mind-set using a console-based WF host. While this is great from a learning point of view, I bet you can easily envision building workflow-enabled Windows Forms applications, WPF applications, or ASP.NET web applications. Furthermore, I am sure you can imagine the need to reuse a workflow across numerous...

The Two Faces of ADONET

The ADO.NET libraries can be used in two conceptually unique manners connected or disconnected. When you are making use of the connected layer, your code base will explicitly connect to and disconnect from the underlying data store. When you are using ADO.NET in this manner, you typically interact with the data store using connection objects, command objects, and data reader objects. The disconnected layer, which is the subject of Chapter 23, allows you to manipulate a set of DataTable objects...

Public Fields Private Fields and Public Properties

Notice that in each of these classes, I have defined the field data using the Public keyword, just to simplify the example. Of course, private data exposed using public properties would be preferable from an OO point of view. Also, for the sake of simplicity, I have not defined any custom constructors on these types, and therefore all unassigned field data will receive the expected default values. OO design principles aside, you may wonder how the various formatters expect a type's field data...

The Role of the Me Keyword

Like earlier additions of Visual Basic, VB 2008 supplies a Me keyword that provides access to the current class instance. One possible use of the Me keyword is to resolve name clashes, which can arise when an incoming parameter is named identically to a data field of the type. Of course, ideally you would simply adopt a naming convention that does not result in such ambiguity however, to illustrate this use of the Me keyword, update your Motorcycle class with a new public String field named...

Adonet Part I The Connected Layer

As you would expect, the .NET platform defines a number of namespaces that allow you to interact with machine local and remote relational databases. Collectively speaking, these namespaces are known as ADO.NET. In this chapter, once I frame the overall role of ADO.NET, I'll move on to discuss the topic of ADO.NET data providers. As you will see, the .NET platform supports numerous data providers, each of which is optimized to communicate with a specific database management system Microsoft SQL...

Transforming XML Code Comments via NDoc

Now that you have generated an .xml file that contains your source code comments, you may be wondering exactly what to do with it. Sadly, Visual Studio 2008 does not provide a built-in utility that transforms XML data into a more user-friendly help format such as an HTML page . If you are comfortable with the ins and outs of XML transformations, you are, of course, free to manually create your own style sheets. A simpler alternative, however, are the numerous third-party tools that will...

Note The code comments that are placed within the Session End event handler will make much more sense when we examine

Like the HttpApplicationState type, the HttpSessionState may hold any System.Object-derived type, including your custom classes. For example, assume you have a new web application SessionState that defines a new class named UserShoppingCart within a file named UserShoppingCart.vb Public Class UserShoppingCart Public desiredCar As String Public desiredCarColor As String Public downPayment As Single Public isLeasing As Boolean Public dateOfPickUp As DateTime Public Overrides Function ToString As...

Anonymous Types Containing Anonymous Types

You don't control the name of the anonymous type. Anonymous types always extend System.Object. Anonymous types cannot support events, custom methods, custom operators, or custom overrides. Anonymous types are always implicitly sealed. Anonymous types are always created using the default constructor. However, when programming with the LINQ technology set, you will find that in many cases this syntax can be very helpful when you wish to quickly model the overall shape of an entity rather than...

Establishing the ABCs Within an Appconfig File

When you are building a host for a WCF service type, you will follow a very predictable set of steps some via configuration and some via code 1. Define the endpointfor the WCF service being hosted within the host's configuration file. 2. Programmatically make use of the ServiceHost type to expose the service types available from this endpoint. 3. Ensure the host remains running to service incoming client request. Obviously, this step is not required if you are hosting your service types using a...

Creating Custom Conversion Routines

VB provides two keywords, Widening and Narrowing, that can be used when redefining how your class or structure responds to the CType operator. The difference between these conversion routines can be summarized as follows Narrowing conversions do not always succeed at runtime, and may result in loss of data. If Option Strict is enabled, CType must be used for all narrowing conversions. Widening conversions always succeed at runtime and never incur data loss. To illustrate, assume a new Console...

Note In Chapter 4 you were introduced to the structure type Structures are always implicitly sealed Therefore you can

As you would guess, there are many more details to inheritance that you will come to know during the remainder of this chapter. For now, simply keep in mind that the Inherits keyword allows you to establish base derived class relationships, while the NotInheritable keyword prevents inheritance from occurring. Figure 6-1. The base class libraries define numerous sealed types. Figure 6-1. The base class libraries define numerous sealed types.

Survey of the GDI Namespaces

The .NET platform provides a number of namespaces devoted to two-dimensional graphical rendering. In addition to the basic functionality you would expect to find in a graphics toolkit colors, fonts, pens, brushes, etc. , you also find types that enable geometric transformations, antialiasing, palette blending, and document printing support. Collectively speaking, these namespaces make up the .NET facility we call GDI , which is the native rendering toolkit of Windows Forms. Table 28-1 gives a...

The Rectangle and RectangleF Types

Rectangles, like Points, are useful in many applications GUI based or otherwise . One of the more useful methods of the Rectangle type is Contains . This method allows you to determine whether a given Point or Rectangle is within the current bounds of another object. Later in this chapter, you'll see how to make use of this method to perform hit testing of GDI images. Until then, here is a method making use of the Rectangle type call this method from within Main to test Sub UseRectangle...

The ByRef Parameter Modifier

Some methods need to be created in such a way that the caller should be able to realize any reas-signments that have taken place within the method scope. For example, you might have a method that needs to change incoming character data, assign an incoming parameter to a new object in memory, or simply modify the value of a numerical argument. For this very reason, VB 2008 supplies the ByRef keyword. Consider the following update to the PrintMessage method Sub PrintMessage ByRef msg As String...

Building a Strongly Typed Data Context

While our first example is strongly typed as far as the database query is concerned, we do have a bit of a disconnect between the DataContext and the Inventory entity class it is maintaining. To remedy this situation, it is typically preferable to create a class that extends the DataContext type that defines member variables for each table it operates upon. Insert a new class called AutoLotDatabase, specify you have imported the System.Data.Linq namespace, and implement the type as follows...

Documenting VB 2008 Source Code via XML

To wrap this chapter up, the final task is to examine VB 2008-specific comment tokens that yield XML-based code documentation. If you have worked with the Java programming language, you may be familiar with the javadoc utility. Using javadoc, you are able to turn Java source code into a corresponding HTML representation. The VB 2008 documentation model is slightly different, in that the code comments to XML conversion process is the job of the VB 2008 compiler via the doc option rather than a...

The Object Browser Utility

Visual Studio 2008 also provides a utility to investigate the set of referenced assemblies within your current project. Activate Object Browser using the View menu, and then select the assembly you wish to investigate see Figure 2-13 . Object Browser VsiOOSExample Modul l.vb Start Page lt Search gt EjD- a Microsoft.VisualBasic mscorlib h Microsoft.Win32 i- M i crosoft.Wi n32. SafeH a n d I es System System. Col lections System .Coll ecti ons. G en eri c System .Coll ecti ons. Obj ectM od el...

The Default Response File vbcrsp

The final point to be made regarding response files is that the VB 2008 compiler has an associated default response file vbc.rsp , which is located in the same directory as vbc.exe itself e.g., If you were to open this file using Notepad, you would find that numerous .NET assemblies have already been specified using the r flag. As you would expect, you will come to understand the role of many of these .NET libraries over the course of the text. However, to set the stage, here is a look within...

Finalizing the UI Design

The final aspect of our UI design is to define a splittable Grid that defines two columns. On the left will be the Expander that will display a list of spelling suggestions, wrapped within a lt StackPanel gt . On the right will be a TextBox that supports multiple lines and has enabled spell checking. The entire lt Grid gt will be mounted to the left of the parent lt DockPanel gt . Add the following XAML markup to complete the definition of our Window's UI lt Grid DockPanel.Dock Left Background...

The Role of the IDbData Parameter and IData Parameter Interfaces

Notice in the previous code sample that the Parameters property of IDbCommand returns a strongly typed collection that implements IDataParameterCollection. This interface provides access to a set of parameter objects, each of which implements IDbDataParameter Public Interface IDbDataParameter Inherits IDataParameter Property Precision As Byte Property Scale As Byte Property Size As Integer End Interface IDbDataParameter extends the IDataParameter interface to obtain the following additional...

Programmatically Creating a resx File

As mentioned, a .resx file is a block of XML data that assigns name value pairs for each resource in your application. The ResXResourceWriter class provides a set of members that allow you to create the .resx file, add binary and string-based resources, and commit them to storage. To illustrate, let's create a simple Windows Forms application ResXWriter that will generate a .resx file containing an entry for the happyDude.bmp file first seen in the Dragginglmages example and a single string...

Using a Type Library to Build an Interop Assembly

To be sure, the VB6 compiler generates many other IDL attributes under the hood, and you see additional bits and pieces where appropriate. However, at this point, I am sure you are wondering exactly why I spent the last several pages describing the COM IDL. The reason is simple when you add a reference to a COM server using Visual Studio 2008, the IDE reads the type library to build the corresponding interop assembly. While VS 2008 does a very good job of generating an interop assembly, the Add...

O

Object logical resources, 1198 Object Browser, 308 Object class, 200 object contexts boundaries, 531 context 0, 532 context-agile, 532-533 context-bound, 532-533 overview, 517 program example, 533 Object data types, 314 object draft, 634 object generations, 239 object graph definition, 635 garbage collection, 238 reachable objects, 238 relationships, 635 simple example, 635 object initializer syntax, 8, 399-403 calling custom constructors with, 401-402 initializing inner types, 402-403 Object...

Building a Visual Basic 60 Test Client

Now that the .NET assembly has been properly configured to interact with the COM runtime, you can build some COM clients. You can create a simple VB6 Standard .exe project type named VB6_DotNetClient and set a reference to the new generated type library via the dialog box launched using the Project gt - References menu option see Figure 19-20 . Common Language Runtime Execution Engine 2.0 Lib ICompatiJI l.OType Library . jComPlus 1.0 Catalog Replication Type Library ComponentOne VSFIexGrid 8.0...

Building a Reusable Data Access Library

As you have just seen, the ExecuteReader method extracts a data reader object that allows you to examine the results of a SQL Select statement using a forward-only, read-only flow of information. However, when you wish to submit SQL commands that result in the modification of a given table, you will call the ExecuteNonQuery method of your command object. This single method will perform inserts, updates, and deletes based on the format of your command text. Note Technically speaking, a nonquery...

The SkinID Property

Sometimes you wish to define a set of possible UI look and feels for a single widget. For example, assume you want to define two possible UIs for the Button type within the CrazyOrange theme. When you wish to do so, you may differentiate each look and feel using the SkinID property lt asp Button runat server BackColor FF8000 gt lt asp Button runat server SkinID BigFontButton Font-Size 30pt BackColor FF8000 gt Now, if you have a page that makes use of the CrazyOrange theme, each Button will by...

Extend IBasic Math with subtraction method

Public Subtract ByVal itf As IBasicMath, _ ByVal x As Integer, ByVal y As Integer As Integer End Module However, this will result in coding errors. When you extend an interface with new members, you must also supply an implementation of these members This seems to fly in the face of the very nature of interface types, as interfaces do not provide implementations, only definitions. Nevertheless, we are required to define our MathExtensions module as follows

Creating the Auto Lot Database

As we work through this chapter we will execute queries against a simple SQL Server test database named AutoLot. In keeping with the automotive theme used throughout this text, this database will contain three interrelated tables Inventory, Orders, and Customers that contain various bits of data representing order information for a fictional automobile sales company. The assumption in this text is that you have a copy of Microsoft SQL Server 7.0 or higher or a copy of Microsoft SQL Server 2005...

Visual Studio 2008 Code Snippet Technology

Visual Studio 2008 as well as Visual Basic 2008 Express also has the capability to insert complex blocks of VB 2008 code using menu selections, context-sensitive mouse clicks, and or keyboard shortcuts using code snippets. Simply put, a code snippet is a predefined block of Visual Basic 2008 code that will expand within the active code file. As you would guess, code snippets can greatly help increase productivity given that the tool will generate the necessary code statements rather than us ....

Customizing Serialization Using Attributes

Although the previously examined approach to customizing the object serialization process is still possible under .NET 3.5, the preferred manner to do so is to define methods that are attributed with any of the new serialization-centric attributes lt OnSerializing gt , lt OnSerialized gt , lt OnDeserializing gt , or lt OnDeserialized gt . The roles of each of these new attributes are documented in Table 21-3. Table 21-3. Custom Serialization Attributes Serialization Attribute Meaning in Life...

Partial Catalog of Additional NET Development Tools

To conclude this chapter, I would like to point out a number of .NET development tools that complement the functionality provided by your IDE of choice. Many of the tools mentioned here are open source, and all of them are free of charge. While I don't have the space to cover the details of these utilities, Table 2-2 lists a number of the tools I have found to be extremely helpful as well as URLs you can visit to find more information about them. Table 2-2. Select .NETDevelopment Tools FxCop...

The Class View Utility

The next tool to examine is the Class View utility, which you can open from the View menu. The purpose of this utility is to show all of the types in your current project from a more object-oriented perspective rather than a file-based view of Solution Explorer . The top pane displays the set of namespaces and their types, while the bottom pane displays the currently selected type's members see Figure 2-12 . Q Microsoft.VisualBasic -Q mscorlib 0 System Na System.Core Ma System.Data - Q...

Introduction and Welcome

The initial release of the .NET platform circa 2001 caused quite a stir within the Visual Basic programming community. One the one hand, many die-hard VB6 developers were up in arms at the major differences between VB6 and Visual Basic .NET VB .NET . Individuals in this group were a bit stunned to see that VB .NET was not in fact VB7 i.e., the same syntax and programming constructs as VB6 with some new features thrown in for good measure , but something altogether different. The truth of the...

The Philosophy of NET

Every few years or so, the modern-day programmer must be willing to perform a self-inflicted knowledge transplant to stay current with the new technologies of the day. The languages C , Visual Basic 6.0, Java , frameworks OWL, MFC, ATL, STL , architectures COM, CORBA, EJB , and APIs including .NET's Windows Forms and GDI libraries that were touted as the silver bullets of software development eventually become overshadowed by something better or at the very least something new. Regardless of...