
The following sections describe the main components and features of the .NET Framework in greater detail.
2.5 Client Application DevelopmentClient applications are the closest to a traditional style of application in Windows-based programming. These are the types of applications that display windows or forms on the desktop, enabling a user to perform a task. Client applications include applications such as word processors and spreadsheets, as well as custom business applications such as data-entry tools, reporting tools, and so on. Client applications usually employ windows, menus, buttons, and other GUI elements, and they likely access local resources such as the file system and peripherals such as printers.
Another kind of client application is the tradition ActiveX control (now replaced by the managed Window Forms control) deployed over the Internet as a Web page. This application is much like other client applications: it is executed natively, has access to local resources, and includes graphical elements.
In the past, developers created such applications using C? C++ in conjunction with the Microsoft Foundation Classes (MFC) or with a rapid application development (RAD) environment such as Microsoft visual Basic.
The .NET Framework incorporates aspects of these existing products into a single, consistent development environment drastically simplifies the development of client applications. The Windows Forms classes contained in the .NET Framework are designed to be used for GUI development. You can easily create command windows, buttons, menus, toolbars, and other screen elements with the flexibility necessary to accommodate shifting business needs.
For example, the .NET Framework provides simple properties to adjust visual attributes associated with forms. In some cases underlying operating system does not support changing these attributes directly, and in these cases the .NET Framework automatically recreates the forms. This is one of many ways in which the .NET Framework integrates the developer interface, making coding simpler and more consistent.
Unlike ActiveX controls, Windows Forms controls have semi-trusted access to a user’s computer. This means that binary or natively executing code can access some of the resources on the user’s system (such as GUI elements and limited file access) without being able to access or compromise other resources. Because of code access security, many applications that once needed to be installed on a user’s system cam now are safely deployed through the Web. Your applications can implements the feature of a local application while being deployed like a Webpage.
2.6 Server Application Development
Server-side applications in the managed world are implemented through runtime hosts. Unmanaged applications host the common language runtime. Which allows your custom managed code to control the behaviour of the server. This model provides you with all the features of the common language runtime and class while gaining the performance and scalability of the server.
The following illustration shows a basic network schema with managed code running in different server environments. Servers such as IIS and SQL Server can perform standard operations while your applications logic executes through the managed code.
Server-side managed code into the highly distributed environment of the Internet.
If you have used earlier versions of ASP technology, you will immediately notice the improvements that ASP.NET and Web Forms offers. For example, you can develop Web Forms pages in any language that supports the .NET Framework. In addition, your code no longer needs to share the same file with your HTTP text (although it can continue to do so if you prefer). Web Forms pages execute in native machine language because, like another managed application, they take full advantage of the runtime. In contrast, unmanaged ASP pages are ASP.NET is the hosting environment that enables developers to use the .NET Framework to target Web-based applications. However, ASP.NET is more that just a runtime host: it is a complete architecture for developing Web sites and Internet-distributed objects using managed code. Both Web Forms and XML Web services use IIS and ASP.NET as the publishing mechanism for applications, and both have a collection of supporting in the .NET Framework.
XML Web services, an important evolution in Web based technology, are distributed, server-side application component similar to common Web sites. However, unlike Web-based applications, XML Web services components have no UI and are not targeted for browsers such as Internet Explorer and Netscape Navigator. Instead, XML Web services consists of reusable software components designed to be consumed by other applications, such as traditional client applications, Web-based applications, or even other XML Web services.
As a result, XML Web services technology is rapidly moving application developing and deployment always scripted and interpreted. ASP.Net pages are faster, more functional, and easier to develop than unmanaged ASP pages because they interact with the runtime like any managed application.
The .Net Framework also provides a collection of classes and tools to aid in development and consumption of XML Web services. XML Web services applications. XML Web services are built on standards such as SOAP (a remote procedural-call protocol), XML (an extensible data format), and WSDL (the Web services Description Language). The .NET Framework is built on these standards to promote interoperability with non-Microsoft solutions.
WHAT IS .NET
.NET “is the XML Web services platforms, a way of working that allows you to create software as a service.” It’s a Microsoft vision based on distributed computing, the dream of sharing information over the Internet, no matter what operating system, devices, or programming language you’re using.
According to our favourite software giant, this .NET plan covers five core areas, not all of which have yet been fulfilled:
Development products
Server products (such as Windows 2000/2003 and SQL Server)
Foundation services (such as Passport and Alerts)
Devices (such as the Pocket PC)
Experience (such as MSN and Office .NET)
2.7 Exploring Visual Studio .NET
If you haven’t installed and configured Visual Studio .NET, head off to Appendix I and follow the instructions. When you’re done, it‘s time to go exploring. Ready?
Launch Visual Studio .NET by selecting Start Programs Microsoft Visual Studio .NET Microsoft Visual Studio .NET.
You should be looking at a colourful start page, which replaces the rather bland New or Open pop-up of Visual Basic 6 frame. With its online links down the left-hand side, this page is intended to turn into something of a customizable developer portal.
Click on the New Project button.
This is more the sort of screen you’re used to welcoming you in VB6. It allows you to select a new sort of project to create. However, the options here are most certainly different to those we’d find in the old school.
First off, you can create projects in any of the three or four default languages. Naturally, we’re concerned with only Visual Basic here, but, even so, the available projects look confusing. Let’s explain them now.
You’ve got the Windows Application, which is the equivalent of a standard EXE from the old school. Desktop applications will never die (more about these applications) in Next is the class library. Although COM has actually gone in .NET, this is your rough equivalent to an ActiveX DLL project. Moving on, and a Windows Control Library allows you to build your own controls, a sort of ActiveX control project.
Shortly after that, you have an ASP.NET Web application that mixes all the great Web capabilities of ASP with the Visual Basic ability to drag, droop, and code. It’s a project that allows you to build fully functional; Web sites in seconds.
An ASP.NET Web service is next on the list, a project that allows you to expose your code methods or functions over your network or the Internet. Other applications can then call these chunks of code and process the results. It you’ve ever dealt with sticky-sticky Simple Object Access Protocol (SOAP) in VB6, this is the native .Net implementation.
Moving on, the Web control library allows you to build “controls” to use on Web pages. These are HTML based and have absolutely nothing to do with ActiveX. Next on the list is a console application that allows you to build a DOS-like console program, which was incredibly difficult in VB6 days. Next, the Windows service project allows you to build your own services, which in the old days would require either the purchase of a third-party plug-in or a nightmarish amount of API code.
Evert users, or those that have downloaded “extras” from the visual Studio .NET site, may also find a couple of extra project types in their list. The Smart Device Application, for example, allows you to create programs to run on devices such as the Pocket PC. And the ASP.NET Mobile Web Application project type will enable you to create your own mini Web sites that are customized for less-powerful wireless devices, from mobile phones to microwaves.
You can ignore any remaining project types as they’re empty placeholders.
Let’s begin this part of the book by creating a simple Windows while looking at a couple of development environment changes.
Select the Windows Application icon.
Change the name to “Hello.NET”.
Note the Location folder and click on Ok.
You should now be starting at your new (and rather plain) Hello.Net project. Recognize anything?
In the middle window you should have your form, which is the screen your users will see when they run your final application. To the left, you have the toolbox, which holds controls ready to add that form. (Click View Toolbox if you can’t see it.) Check out the various tabs: you’ll find a whole bundle here, many more than intrinsic few you had with VB6.
These are part of the core .Net Framework, which means that all your users will automatically have them installed. So, if you do use something like the OpenFileDialog control in your application, you won’t need to go bundling an extra DLL to ensure that it works on the client machine. It will just work. Well, hurrah for that! You will find most of yours old favourites here too—with an occasional name change thrown in to warrant the purchase price, of course. The command Button Became Button1, for example. The Caption property of the Label turned into Text property. The Menu Editor turned into the Main Menu control. Still, nothing too serious. Casting your eye over to the bottom right of your screen now, you will find the trusty properties window. No real differences here—some things never change. You will find that your form has a few interesting properties though, such as Opacity.
Moving upward slightly, you will see the solution Explorer, which is exactly the same as our Project Explorer expects that it can host multiple projects as part of your solution (like a Project Group). The extra tabs under the properties and solution Explorer windows allow you to use the help and explore classes in your application.
Let’s move on.
Draw a button out onto your form.
Double –click on the button to open up the code window under a new tab.
The next line, Inherits System.Wndows.Forms.Form, tell VB.NET that this class “inherits” the functionality of a form, the functionality described in the
System.Windows.Forms.Form part of the .NET Framework
The following line has a gray chunk displaying the words “Windows Form Designer generated code”. This is a collapsed mound of code, while you can view in full by clicking the little symbol to its left.
After you’re done that, you’ll probably wish you hadn’t. This is your form in the nude. It includes description of what controls you have on the form, along with their positioning and initial properties. Task, move over, playboy.
After this, we see our actual Button Click subroutine__finally, something you recognize. Or is it? First off, you have a couple of extra arguments here providing extra (and often useless) event information. Also, in VB6, if changed the name of the Button1_Click method, it would no longer run the code behind that method when you clicked on Button1. In VB.NET, this isn’t the case: scroll to the end of the first line of Button1_Click here. See the Handles Keyword? This is what determines which methods run when an event occurs.
Anyway, it’s about time we added some code. And what simpler way to start than displaying the clicked Hello World in a message box. Not defined, right? Well, guess what? They changed that too. Type new .NET way of displaying a message box is using the “shared” Show functioning of the Message Box class.
8. Add the following code to respond to the click event of Button1: MessageBox.Show (“Hello World!”)
Actually, I’m lying. You can still use Message Box and all its related result constants, but Message Box is the now and improved way of displaying messages within Windows forms like this.
Let’s run our application now.
Press the F5 key or select Start from the Debug menu.
You’ll see a bunch of information fly past an “output” window as your code is compiled. Ignore it; it just means that your final EXE file is being slapped together.
Within a few seconds, your program should pop up. Yes, it has slightly different feel, and that Form icon definitely has to go. But, on the whole, it’s not all that alien, and a click of your Button control should produce the results you expect. Right? Well, that’s our first glimpse of the Visual Studio .NET interface. A speedy exploration, yes, but it should’ve answered a few of the initial questions every VB6 developer has. So, let’s recap; what differences have we seen so far? A whole bundle of new and exciting project types are now available.
We have a host of fresh intrinsic controls to play with. Most development files have a .VB extension. Form .VB files are really classes and include code that describes how the form is laid out. When your code compiles, a host of useless information spurts into the Output window. Oh, and I forgot to mention: you have pretty pastel-coloured menus, too. Now you know where all those research and development dollars went.
.
No comments:
Post a Comment