<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3141210599755322353</id><updated>2011-11-27T16:39:40.191-08:00</updated><category term='.Net'/><title type='text'>Microsoft .net Tutorial</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-1120073435881470599</id><published>2008-08-25T03:15:00.000-07:00</published><updated>2008-12-22T21:25:46.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Deploying .NET Applications - III</title><content type='html'>&lt;p class="mybody" align="justify"&gt;Merge Modules are a feature of Windows        Installer that provides a standard method for delivering components,        ensuring that the correct version of a component is installed. Merge        Modules is something that we would give to a developer and not the end        user. For example, if we want to distribute our DLL to another developer,        we’ll create a Merge Module for it and distribute our DLL in a Merge        Module. While deploying a finished product the developer will include this        Merge Module in his MSI project and give it to the end user. Merge Modules        are used to install components that are shared by multiple applications.&lt;br /&gt;     &lt;br /&gt;      Now let us proceed with creation of a Merge Module. Here we have assumed        that a Class Library stands created and the .DLL named ‘mylib.dll’ is        ready. To create a merge module we need to select Merge Module from the        project templates available and name it, say &lt;b&gt;mergesetup&lt;/b&gt;. On doing        so we are taken to the File System Editor. The File System Editor is shown        in the following figure.&lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;      &lt;img src="file:///D:/Documents%20and%20Settings/shesu04/Desktop/temp/csart5501.jpg" width="399" border="0" height="245" /&gt;       &lt;table width="100%" border="0" cellpadding="0" cellspacing="0" height="42"&gt;         &lt;tbody&gt;&lt;tr&gt;           &lt;td width="100%" height="79"&gt;           &lt;p class="mybody" align="justify"&gt;The File System Editor has two            folders—Common Files Folder and Module Retargetable Folder falling            under ‘File System on Target machine’. Files present in a Merge Module            are generally sharable files hence Common Files Folder is a good            option to deploy the files. Whichever file we copy in this folder gets            deployed to the Common Files folder of the target machine. Here too we            have an option of adding special folders to the File System Editor by            right clicking on the left pane and selecting the desired folder.            Files deployed in these folders would get deployed to corresponding            folders on the target machine.&lt;br /&gt;         &lt;br /&gt;          The other folder, i.e. the Module Retargetable Folder, offers a lot of            flexibility in deciding where files should be installed. Let us see            how. Now suppose the author of the merge module is not sure where the            developer wants the file to get deployed on the end user’s machine. In            such a case the author of the Merge Module must copy this undecided            file into the Module Retargetable Folder and set a default location            for this file using the Properties window. This gives the developer a            chance to change or retarget the location of the file later while            deploying the whole application to the end user. Let us see how it is            done.&lt;br /&gt;         &lt;br /&gt;          For this we need to copy ‘mylib.dll’ in the Module Retargetable Folder            and set the DefaultLocation property of the Module Retargetable Folder            to &lt;b&gt;[GAC]&lt;/b&gt;. Next we must build the Merge Module. On doing so a            ‘mergesetup.msm’ file would get created in the debug folder. We can            now give this ‘.msm’ file to the developer.&lt;br /&gt;         &lt;br /&gt;          Now assume that the developer creates a Setup project called ‘msimerge.msi’.            To add the Merge Module to the project he needs to right click on the            project name in the Solution Explorer and select Add | Merge Module.            He can then browse for ‘mergesetup.msm’ and add it to his project. Now            to retarget the file all he needs to do is open the Properties window            of the ‘mergesetup.msm’ and set the &lt;b&gt;Module Retargetable Folder &lt;/b&gt;           property to any desired location. For example, if he wants the file to            get installed in Common Files Folder and not GAC as specified by the            author of the Merge Module then he might change the property. The &lt;b&gt;           Module Retargetable Folder&lt;/b&gt; property falls under the &lt;b&gt;           MergeModuleProperties&lt;/b&gt; in the Properties window.&lt;br /&gt;         &lt;br /&gt;          Now whenever the end user installs the ‘msimerge.msi’, ‘mylib.dll’            gets installed in the Common Files Folder. Note that the developer can            (and surely will) add his own application and associated files in            ‘msimerge.msi’ along with ‘mergesetup.msm’ for deployment.&lt;br /&gt;         &lt;br /&gt;          &lt;b&gt;CAB Projects&lt;br /&gt;          &lt;/b&gt;&lt;br /&gt;          Unlike the other deployment project types, there are no editors            provided for working with CAB projects. Files and project outputs can            be added to a CAB project through Solution Explorer, and properties            can be set in the Properties window or in the Project Property pages.&lt;br /&gt;         &lt;br /&gt;          For .NET deployment, a CAB file can contain only one assembly, and the            CAB file must be assigned the same name as the contained assembly, but            with the ‘.cab’ extension. For example, if we create a cabinet file            for ‘mylib.dll’, we need to name the cabinet file as ‘mylib.cab’.            Creating a cab file is very simple. Let us see how to create it.&lt;br /&gt;         &lt;br /&gt;          To create a Cabinet or CAB project we select the Cabinet Project            template from the New Project dialog and name it, say &lt;b&gt;mylib&lt;/b&gt;. To            add files to this project, we need to right click on the project name            and select Add | Files. This would add the specified files in the            project and on building the project the ‘mylib.cab’ file would get            created which can be deployed to target machines. Double clicking on            the cab file extracts the files compressed in it.&lt;br /&gt;         &lt;br /&gt;          &lt;b&gt;Deploying Windows Applications On Web&lt;br /&gt;          &lt;/b&gt;&lt;br /&gt;          We have discussed two cases here. First we have explained the method            by which a Windows application (.exe) can be executed directly on the            web and second by which an installer (.msi) of the Windows Application            can be downloaded from the web. For both the scenarios we have assumed            that ‘windowsapp1.exe’ stands created. And for both we first need to            create a Web Setup project.&lt;br /&gt;         &lt;br /&gt;          To create a Web Setup project we selected the Web Setup Project from            the project templates and named it &lt;b&gt;websetup&lt;/b&gt;. On doing so, the            File System Editor of websetup would get opened. Now we need to add            ‘windowsapp1.exe’ to the Web Application Folder as shown in the            following figure. &lt;/p&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;           &lt;td width="100%" height="79"&gt;           &lt;p align="center"&gt;&lt;img src="file:///D:/Documents%20and%20Settings/shesu04/Desktop/temp/csart5502.jpg" width="387" border="0" height="322" /&gt;&lt;/p&gt;&lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;       &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;Next we need to change two of the        properties of the Web Application Folder. First we have to set the &lt;b&gt;       AllowDirectoryBrowsing&lt;/b&gt; property to &lt;b&gt;True&lt;/b&gt;. This property        determines whether users can see a hypertext listing of files and        subdirectories in a virtual directory. If it is set to &lt;b&gt;True&lt;/b&gt;, users        can browse for it. Next we have to set the &lt;b&gt;VirtualDirectory&lt;/b&gt;        property to myweb. Now we need to build websetup and copy the        ‘websetup.msi’ file to the web server. On double clicking the MSI file the        project would get installed. To test the project we need to start Internet        Explorer and type the ‘http:\\computername\myweb’ URL. You will see the        name of the ‘windowsapp1.exe’ file in the browser window. On clicking        filename the EXE would get executed. For the second scenario we need to        follow the same steps as given above, but instead of copying the EXE to        the Web Application Folder, we need to copy an MSI (winsetup.msi) project,        which includes the EXE to the folder. Then on deploying and installing        ‘websetup.msi’ we would get the window displaying the name of the        ‘websetup.msi’ file. On clicking it we would be presented with a dialog        box that gives us options to install or download the MSI. On installing or        downloading the MSI we would be able to execute the Windows application.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Setup Wizard&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      As told to you earlier the Setup Wizard helps us to start the deployment        projects. The wizard guides us through the steps of creating setup program        that contains all information required for installation. The steps in the        Setup Wizard are self-explanatory. As soon as we select Setup Wizard, give        the project a name (say wizsetup) and press OK, we are presented with a        Welcome dialog.&lt;br /&gt;     &lt;br /&gt;      On clicking ‘Next’ we are presented with the Step 2 window of the wizard.        It asks us type of project we intend to make. Suppose we select the first        option and click ‘Next’, we get the third dialog box. Here the Wizard asks        us to add the files we wish to deploy. We can add the files by clicking on        the ‘Add’ button and browsing for the desired files. On clicking the        ‘Next’ button the Wizard presents us with the summary of the project. We        had selected the first option and hence on clicking the ‘Finish’ button        the Wizard takes us to the File System Editor of the project. We can now        build the project as we would build any deployment project.       &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-1120073435881470599?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/1120073435881470599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=1120073435881470599' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1120073435881470599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1120073435881470599'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/deploying-net-applications-iii.html' title='Deploying .NET Applications - III'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-3414541765636668974</id><published>2008-08-25T03:12:00.000-07:00</published><updated>2008-12-22T21:25:46.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Deploying .NET Applications - II</title><content type='html'>&lt;p class="mybody" align="justify"&gt;Sometimes our application may require        some pre-requisites before installation. For example, our application may        demand that Internet Explorer 5.0 or higher must be installed on the        target machine. This calls for a check that must be satisfied for        successful installation of the application. We can apply Launch Conditions        in such cases. If the condition specified during this step (here, Internet        Explorer installed) is not fulfilled then the installation halts. Note        that here this step is intended to demonstrate the concept of launch        conditions and ‘windowsapp1.exe’ has no actual dependency on Internet        Explorer.&lt;br /&gt;     &lt;br /&gt;      To add launch conditions we need to right click on the project in the        solution explorer and select View | Launch Conditions. On doing so a        Launch Condition Editor will get opened. Next we need to right click on        the &lt;b&gt;Requirements on Target Machine &lt;/b&gt;node and we would be presented        with 5 options to choose from—Add File Launch Condition, Add Registry        Launch Condition, Add Windows Installer Launch Condition, Add .NET        Framework Launch Condition, and Add Internet Information Services Launch        Condition. As the names suggest we can check for the specified entities on        the target machine and if these entities are present on the target        machine, the installation proceeds otherwise it halts.&lt;br /&gt;     &lt;br /&gt;      Here we have added the Add File Launch Condition. On doing so two nodes        called &lt;b&gt;Search For File1 &lt;/b&gt;and &lt;b&gt;Condition1 &lt;/b&gt;would get added in        the &lt;b&gt;Search Target Machine&lt;/b&gt; and &lt;b&gt;Launch Conditions&lt;/b&gt; nodes        respectively falling under the &lt;b&gt;Requirements on Target Machine&lt;/b&gt; node.        We changed the properties shown in the following table for the &lt;b&gt;Search        For File1&lt;/b&gt; entity.&lt;br /&gt;     &lt;br /&gt; &lt;/p&gt;       &lt;div align="center"&gt;         &lt;table width="95%" border="1"&gt;           &lt;tbody&gt;&lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Property&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Changed to...&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Used&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;           &lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; Name&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; Search For Internet Explorer&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; Specifies the name used in Launch              Condition Editor.&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;           &lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; FileName&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; Iexplore.exe&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; Specifies the name of a file to              search for.&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;           &lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; Folder&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; [ProgramFilesFolder]&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; Specifies the folder where a file              search will start.&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;           &lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; Depth&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; 3&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; Specifies the number of levels of              subfolders to search for a file.&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;           &lt;tr&gt;             &lt;td width="14%"&gt;             &lt;p class="mybody" align="justify"&gt; MinVersion&lt;/p&gt;&lt;/td&gt;             &lt;td width="31%"&gt;             &lt;p class="mybody" align="justify"&gt; 5.00&lt;/p&gt;&lt;/td&gt;             &lt;td width="55%"&gt;             &lt;p class="mybody" align="justify"&gt; Specifies the minimum version              number for a file in the file search.&lt;/p&gt;&lt;/td&gt;           &lt;/tr&gt;         &lt;/tbody&gt;&lt;/table&gt;       &lt;/div&gt;       &lt;p class="mybody" align="justify"&gt;Now we need to specify the launch        condition. To do so we must set the &lt;b&gt;Condition&lt;/b&gt; property of the &lt;b&gt;       Condition1&lt;/b&gt; entity to &lt;b&gt;FILEEXISTS1&lt;/b&gt;. Note that in the Properties        window of &lt;b&gt;Search For File1&lt;/b&gt; the &lt;b&gt;Property&lt;/b&gt; property is set to       &lt;b&gt;FILEEXISTS1&lt;/b&gt;. We can also specify a message through the Properties        window that would be displayed if the condition evaluates to false (i.e.        if file is not found) at installation time.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Changing Icons&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      We can change icons for our application using the Properties window. To        change the icon for the shortcuts we must select the shortcut file and set        the &lt;b&gt;Icon&lt;/b&gt; property of the file to any&lt;b&gt; .ico&lt;/b&gt; file. Note that we        need to first copy this file to the Application Folder to make it        available.&lt;br /&gt;     &lt;br /&gt;      On the same lines we can change the icon of the setup file that would be        displayed in the Add/Remove Programs Window. To do so, we must right click        on &lt;b&gt;winsetup&lt;/b&gt; in Solution Explorer and select Properties. This would        display the Properties window of the whole solution. Here we need to set        the &lt;b&gt;AddRemoveProgramsIcon&lt;/b&gt; to any desired file.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Adding File Associations&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      Suppose our application creates files having the user–defined extension        (for example, we can serialize data in a file having the &lt;b&gt;.mine&lt;/b&gt;        extension) and now we wish that on double clicking such a file it should        automatically get opened in our application. To achieve this we must use        file associations. File Associations allows the developer to associate        user-defined file types with his or her application. Assume that we need        to deploy a file called &lt;b&gt;myfile.mine &lt;/b&gt;with our application. To deploy        it along with the application we first need to copy it in the Applications        Folder. After installation whenever the user double clicks on this file it        should get opened with &lt;b&gt;windowsapp1.exe&lt;/b&gt;. Note that here too we have        made an assumption for demonstration purpose that our application is        creating files having &lt;b&gt;.mine&lt;/b&gt; extension. Actually &lt;b&gt;windowsapp1.exe       &lt;/b&gt;is too simple and does not do any serialization or file I/O.&lt;br /&gt;     &lt;br /&gt;      Now to associate this file with our application we must right click on the        project name in the Solution Explorer and select View | File Types. On        doing so we are presented with the File Types Editor. Next we need to        right click on the node and select Add File type. Now we need to give any        file name (here we have used &lt;b&gt;file1&lt;/b&gt;) along with the extension (&lt;b&gt;.mine&lt;/b&gt;)        in the Properties window. This ensures that any file with the &lt;b&gt;.mine &lt;/b&gt;       extension would get opened with our application. Note that we need not        specify the dot ( . ) while mentioning the extension. After this we have        to set the &lt;b&gt;Command&lt;/b&gt; property of the file to &lt;b&gt;windowsapp1.exe&lt;/b&gt;.        The File Types Editor along with the Properties window is shown in the        following figure.&lt;br /&gt;     &lt;br /&gt;      Now on re-building the project and running the installer, &lt;b&gt;myfile.mine       &lt;/b&gt;would get deployed along with the application. And moreover whenever        the user double clicks on this file it gets opened with our application.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Adding Custom Actions&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      Custom actions allow us to run code at the end of an installation to        perform actions that cannot be handled during installation. For example,        if we wish to create a database after installation and before running the        deployed application, we need to add the DLL or EXE, which would create a        database, as a custom action. We can add custom actions through the Custom        Actions Editor. The Custom Actions Editor can be opened by right clicking        on the project name and selecting View | Custom Actions. The Custom        Actions Editor is shown in the following figure. &lt;/p&gt;      &lt;br /&gt;     &lt;br /&gt;                                     &lt;p class="mybody" align="justify"&gt;This editor contains four folders,            each corresponding with a phase of installation—Install, Commit,            Rollback, and Uninstall. Custom actions are run in the same order that            they are displayed in the editor. They can be reordered by dragging            with the mouse or through the Cut and Paste commands on the Edit menu.            All the Custom Actions run at the end of installation. In addition to            the custom actions we add, there are 5 pre-defined custom actions            included in Visual Studio .NET—Event Log, Message Queue, Performance            Counter, Service, and Service Process components. We can also add            these pre–defined Custom Actions in our project.&lt;br /&gt;         &lt;br /&gt;          &lt;b&gt;Deploying to Special Folders&lt;/b&gt;&lt;br /&gt;         &lt;br /&gt;          In addition to the folders mentioned in the previous            section—Application Folder, User’s Desktop, and User’s Programs            Menu—we can add more folders to the File System Editor through the            ‘Add Special Folders’ menu. If we right click on the left pane of the            File System Editor we get a popup menu offering fourteen folders from            which we can select the ones that we can add.&lt;br /&gt;          On selecting a folder from this menu it gets added to the ‘File System            on Target Machine’ tree. This provision is made so that we can deploy            our files to these specific folders on the target machine. For            example, if we have a signed assembly and we wish to deploy it in the            Global Assembly Cache of the target machine, all we need to do is add            the Global Assembly Cache folder in the File System Editor and copy            our signed assembly to it. On installing the application on the target            machine one can find the assembly installed in the Global Assembly            Cache.&lt;br /&gt;         &lt;br /&gt;          That brings us to the end of discussion on how we can customize our            MSI project according to the requirement of the application we want to            deploy. If we wish to deploy the application on the development            computer while building it, we have to right click on the project name            in the Solution Explorer and select Install. And if we wish to deploy            it on another computer then, as it might be very obvious to you by            now, we need to distribute the &lt;b&gt;winsetup.msi&lt;/b&gt; file.  &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-3414541765636668974?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/3414541765636668974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=3414541765636668974' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/3414541765636668974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/3414541765636668974'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/deploying-net-applications-ii.html' title='Deploying .NET Applications - II'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-1046750533934762087</id><published>2008-08-25T03:08:00.000-07:00</published><updated>2008-12-22T21:25:46.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Deploying .NET Applications</title><content type='html'>&lt;p class="mybody" align="justify"&gt;Though distributing libraries in the       form of DLLs was a major step forward, it suffered from the now in-famous       DLL hell. COM could avoid this but it had no versioning mechanism.       Moreover a COM component had foot-prints at so many places that if one of       them got modified/corrupted, the application used to break down. .NET has       come up with more sophisticated approaches for deployment and versioning.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Deployment Issues&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      Deployment is a process by which you distribute a finished application or       component to be installed on other computers. In Visual Studio .NET,       deployment is based on Microsoft Windows Installer technology. Microsoft       Windows Installer is a service shipped with Windows Me, Windows 2000, and       Windows XP. It is used for installation and configuration of applications       to be installed. Every .NET application is deployed in the form of one or       more assemblies. Assemblies may be deployed as regular standalone files       (DLL or EXE files), or they may be deployed using CAB, MSI, or MSM files.       The simplest way of deploying a private assembly is to use an XCOPY, i.e.       copying the assembly in the desired folder. On the other hand we can       deploy shared assemblies by installing them in the Global Assembly Cache       of the target machine by using the &lt;b&gt;Gacutil.exe&lt;/b&gt;.&lt;br /&gt;     &lt;br /&gt;      To help programmers develop setup and deployment solutions, Visual Studio       .NET provides several templates and wizards. We can create a setup or       deployment project by selecting ‘Setup and Deployment Projects’ in the       ‘New Project’ dialog box shown in the following figure.       &lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;     &lt;br /&gt;      &lt;/p&gt;&lt;p&gt;Let us first discuss the types of projects shown in the dialog box and       see the usage of each. Later we have illustrated how to deploy different       types of applications using these projects.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Setup Project&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      A setup project builds a Windows Installer file or an MSI file with the &lt;b&gt;.msi       &lt;/b&gt;extension. This file is used to install the specified files and       resources on the target machine automatically. The &lt;b&gt;.msi &lt;/b&gt;file       contains the application, any dependent files, information about the       application such as registry entries, and instructions for installation.       When the &lt;b&gt;.msi &lt;/b&gt;file is distributed and run on another computer, you       can be assured that everything necessary for installation is included; if       for any reason the installation fails (for example, the target computer       does not have the required operating system version), the installation       will be rolled back and the computer returned to its pre-installation       state.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;CAB Project&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      A CAB project creates a cabinet file with the &lt;b&gt;.cab&lt;/b&gt; extension. It is       much like a Zip file, compressing a number of specified files into an easy       to use and easy to deploy package. The resulting cabinet (&lt;b&gt;.cab&lt;/b&gt;)       file can then be deployed or downloaded. The files present in the &lt;b&gt;.cab&lt;/b&gt;       file can be extracted by double-clicking the &lt;b&gt;.cab&lt;/b&gt; file.&lt;br /&gt;     &lt;br /&gt;      Merge Module Project&lt;br /&gt;     &lt;br /&gt;      A Merge Module project produces a merge module file having a &lt;b&gt;.msm&lt;/b&gt;       extension. A Merge Module is a single package that contains all files,       resources, registry entries, and setup logic necessary to install a       component.&lt;br /&gt;     &lt;br /&gt;      Merge Modules are used to install components that are shared by multiple       applications. The basic distinction between a Merge Module (&lt;b&gt;.msm&lt;/b&gt;)       and a Windows Installer (&lt;b&gt;.msi&lt;/b&gt;) is based on the user using these       components. Whatever we wish to deploy directly to the end user of the       application (executable files, documents, HTML pages) should be packaged       in a Windows Installer, whereas, whatever we wish to deploy to the       developer (DLLs, controls, resources) should be packaged in a Merge       Module. The developer can then repack it in a Windows Installer for       distribution to the end user. It is possible to put multiple components       into a single Merge Module but it's best to create a Merge Module for each       component in order to handle versioning problems. Once you have       distributed a Merge Module it should never be modified; instead you should       create a new Merge Module for each successive version of your component.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Web Setup Project&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      Web Setup Project helps us to deploy web-based applications. In addition       to this any Windows application or its installer can be deployed to a web       server so that users can later download and run them from a web site. In       order to deploy web-based application we will have to build a Web Setup       Project, copy it to the web server and run the installer to install it on       the server.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Setup Wizard&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      The Setup Wizard is used to help us start creating any of the       above-discussed projects in a fast and simple manner. We just have to       follow some simple steps the wizard leads us through and the wizard does       the initial job for us. Next we may extend the project further as per our       requirements. Now let us understand the projects discussed above in       detail.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Setup Projects&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      We know that a Setup Project creates an &lt;b&gt;.msi &lt;/b&gt;file, which actually       installs the application on the target computer. To demonstrate this we       plan to deploy a simple Windows application using the Setup Project. Here       we have assumed that the Windows application stands created and the .EXE       named &lt;b&gt;windowsapp1.exe&lt;/b&gt; is ready. To deploy this Windows application       we need to select ‘New | Project’ and select ‘Setup and Deployment       project’ from the available options. Next we must select ‘Setup       Project’ as the project template and specify the name (say &lt;b&gt;winsetup&lt;/b&gt;)       and the location of the setup project and click OK. Then we are taken to       the File System Editor. The File System Editor is shown in the following       figure.       &lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;      &lt;/p&gt;&lt;p&gt;The File System Editor has three folders—the Application Folder, the       User’s Desktop folder and the User’s Programs Menu folder. These       folders actually represent the folders on the target machine. For example,       whatever you put in User’s Desktop will be deployed on the desktop of       the target machine. From the three folders in the file system editor,       files from Application Folder would be deployed in the Program Files       folder; typically it is ‘C:\Program Files\Company Name\Application       Name’ of the target machine. User’s Desktop folder contains files and       folders that would appear on the desktop of the target machine on a       per-user basis. Typically the path is ‘C:\Documents and Settings       \username\Desktop’. User’s Programs Menu folder contains user’s       program groups that would usually get deployed in ‘C:\Documents and       Settings \username\Start Menu\Programs’.&lt;br /&gt;     &lt;br /&gt;      Now we need to add the Windows application EXE file into this project. For       this we must right click on the Application Folder. A menu is popped. We       must select Add | File and on doing so an ‘Add Files’ dialog is       popped. Now we need to browse for ‘windowsapp1.exe’ file so that it       gets added to the Application Folder. We can add the EXE to User’s       Desktop and User’s Programs Menu as well but while doing so we must keep       in mind that these two folders are on per-user basis. This means that only       the user who installs the application would be able to access the file on       his desktop and not the other users.&lt;br /&gt;     &lt;br /&gt;      This completes the basic steps needed to build an installer. We can now       build this project and an installer called ‘winsetup.msi’ would get       created in the debug folder. Now all we need to do is to distribute this       installer and on running the installer on the target machine the       application would get installed there.&lt;br /&gt;     &lt;br /&gt;      On running the installer we get a series of screens depicting different       stages of installation. Note that if our application needs more files than       just the ‘windowsapp1.exe’ then we can copy them to any of the       above-mentioned folders.&lt;br /&gt;     &lt;br /&gt;      There is much more to a Setup Project than what we discussed above. We saw       the simplest form and there are several more features that we need to       explore. All the deployment capabilities discussed below are not mandatory       and we can customize our installation process according to the needs of       our application.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Adding Shortcuts&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      We can add shortcuts to our application in any of the 3 folders. For this       we need to right click on the application file (‘windowsapp1.exe’)       that we added to the project and select ‘Create shortcut to       windowsapp1.exe’. On doing so a shortcut for our application would get       created. Now we must drag this shortcut in the User’s Desktop Folder. If       we wish to add a shortcut in User’s Programs Menu also, we need to       create another shortcut in the same manner discussed above and drag it in       the folder. On building and installing the application, the shortcuts get       added in the specified folders of the target machine.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Adding Registry Entries&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      We can make a provision that some registry entries would be added for a       particular application during installation of the application. We can then       access these entries later through our application’s code at run-time.       To add the registry entries we must right click on &lt;b&gt;winsetup&lt;/b&gt; in the       Solution Explorer and select View | Registry. On doing so we will be       presented with the Registry Editor shown in the following figure.       &lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;      &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;Suppose we wish to add a key-value pair       to HKEY_CURRENT_USER | Software | [Manufacturer]. For this we must right       click on it and select New | Key. We can rename the key as per our wish.       To add a value we need to right click on the newly formed key and select       the type of value we wish to add, i.e. whether it should be a String       value, a DWORD value, a Binary value, etc. We can set it to some value       using the Properties Window. Now if we build &lt;b&gt;winsetup&lt;/b&gt; and install       the application, the entry would be made in the registry. We can verify       this by executing the Registry Editor RegEdit through the ‘Start |       Run’ dialog box.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Adding Custom Installation Dialog Boxes&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      Once the MSI file is built and we double click on it, the installation       starts. The user is presented with five dialog boxes during installation.       These dialog boxes are predefined dialog boxes that get added to our       project by default. We can customize these dialogs or new dialog boxes to       our project using the User Interface Editor. This editor can be opened by       right clicking on the project in Solution Explorer and selecting ‘View |       User Interface’.&lt;br /&gt;     &lt;br /&gt;      The User Interface Editor shows a tree control containing two       sections—Install and Administrative Install. The Install section       contains dialog boxes that will be displayed when any end user runs the       installer. Administrative installation is a feature of Microsoft Windows       Installer that allows us to install a source image of an application on a       network share. Users in a workgroup who have access to the network share       can then install the application from the source image. The User Interface       Editor allows us to specify a different set of installation dialog boxes       that will be displayed when an administrator installs the application to a       network share via the command line as shown below:        &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;&lt;br /&gt;      Msiexec.exe /a Setup1.msi       &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;This will start the installer of our       application and dialog boxes specified for the Administrative Install will       be displayed.&lt;br /&gt;     &lt;br /&gt;      The default set of predefined dialog boxes is displayed in the User       Interface Editor; we can rearrange or delete these if we wish. The default       set of dialog boxes varies according to the type of deployment project.       Predefined dialog boxes are divided into three categories:&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Start Dialog Boxes&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      Start dialog boxes are displayed before the installation begins. Commonly       they are used to gather customer information or to allow the user to       change the installation directory.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Progress Dialog Boxes&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      A progress dialog box is displayed to provide feedback on the progress of       an installation.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;End Dialog Boxes&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      End dialog boxes are displayed once the installation has finished       successfully. Common uses are notifying the user that the installation is       complete or to allow the user to launch the application.&lt;br /&gt;     &lt;br /&gt;      We can remove dialog boxes from the default set as per our wish or       reposition them using the right click | Move Up/Move Down options. Note       that all combinations are not possible here. For example, we cannot remove       the Progress dialog box and place it in the Start dialog boxes category       after the Welcome dialog box.&lt;br /&gt;     &lt;br /&gt;      Now in addition to these dialog boxes we can add and configure our own       custom dialog boxes that would get displayed during the installation. To       do so we need to right click on the desired category and select ‘Add       Dialog’. On doing so the Add Dialog Box gets displayed.&lt;br /&gt;     &lt;br /&gt;      Here we are presented with several ready-made dialog boxes that we may       want to get displayed during installation. Following table indicates the       use of these dialog boxes.&lt;br /&gt;     &lt;br /&gt;      &lt;/p&gt;&lt;div align="center"&gt;         &lt;table width="84%" border="1"&gt;           &lt;tbody&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Dialog Box&lt;/b&gt;&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Purpose&lt;/b&gt;&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; RadioButtons (2 buttons)&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Gives the user a choice                 between two options through two radio buttons.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; RadioButtons (3 buttons)&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Gives the user a choice                 between three options through three radio buttons.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; RadioButtons (4 buttons)&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Gives the user a choice                 between four options through four radio buttons.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkboxes A, B, or C&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Gives the user a choice                 to add 1, 2, 3 or 4 checkboxes in the same dialog.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Customer Information&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Used to retrieve                 information including name, company, and serial number.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Textboxes A, B, or C &lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Used to retrieve custom                 information using 1, 2 or 3 text boxes.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; License Agreement&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Displays a license                 agreement for the user to read and acknowledge.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Read Me&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Allows the user to view                 any Read me file in .rtf format.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Register User&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Allows the user to                 submit registration information.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="28%"&gt;                 &lt;p class="mybody" align="justify"&gt; Splash&lt;/p&gt;               &lt;/td&gt;               &lt;td width="72%"&gt;                 &lt;p class="mybody" align="justify"&gt; Displays a Splash Screen                 in &lt;b&gt;.bmp&lt;/b&gt; format during installation.&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;           &lt;/tbody&gt;         &lt;/table&gt;       &lt;/div&gt;       &lt;p class="mybody" align="justify"&gt;Out of the several dialog boxes listed       in this table we would discuss only the ones that are likely to be used       more commonly. These include the Checkbox dialog box, Read Me Dialog box       and the Splash dialog box.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;The Checkbox Dialog Box&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      Suppose during installation we plan to ask the user whether he wants to       add the ‘Disclaimer.txt’ file along with ‘windowsapp1.exe’ or not.       To control this we plan to add the Checkbox dialog box. If the user checks       the Checkbox, the text file gets installed. To add this custom dialog box       we have followed the same steps discussed above and added the Checkboxes       (A) Dialog. This dialog box would get added as the last dialog box of the       Start dialog boxes category. So we can move it up by two positions. Next       we have changed some properties of the Checkboxes (A) dialog box. These       are shown in the following table.&lt;br /&gt;     &lt;br /&gt;      &lt;/p&gt;&lt;div align="center"&gt;         &lt;table width="75%" border="1"&gt;           &lt;tbody&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; &lt;b&gt;Property&lt;/b&gt;&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt;&lt;b&gt; Changed to...&lt;/b&gt;&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; BannerText&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Disclaimer&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; BodyText &lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Do you want to install                 the Disclaimer text file?&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox1Label&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Install Disclaimer&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox1Value&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Unchecked&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox1Visible&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; True&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox2Visible &lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; False&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox3Visible&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; False&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;             &lt;tr&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; Checkbox4Visible&lt;/p&gt;               &lt;/td&gt;               &lt;td width="50%"&gt;                 &lt;p class="mybody" align="justify"&gt; False&lt;/p&gt;               &lt;/td&gt;             &lt;/tr&gt;           &lt;/tbody&gt;         &lt;/table&gt;       &lt;/div&gt;       &lt;p class="mybody" align="justify"&gt;Note that we have changed the visible       property of the remaining checkboxes to &lt;b&gt;false&lt;/b&gt; because we need just       one checkbox. Now we need to add a folder in the Application Folder named       Disclaimer. For this we must right click on the Application Folder and       select ‘Add | Folder’. This would add a new folder we have renamed it       to &lt;b&gt;Disclaimer&lt;/b&gt;. Next we added a text file called       ‘Disclaimer.txt’ to this folder. Hence the Application Folder would       contain the ‘windowsapp1.exe’ along with the Disclaimer folder holding       the ‘Disclaimer.txt’ file. Then comes the most important step of       setting the &lt;b&gt;Condition&lt;/b&gt; property of the ‘Disclaimer.txt’ file so       that it would only get installed when the checkbox is checked. To do this       we need to open the Properties Window of the ‘Disclaimer.txt’ and set       its Condition property to &lt;b&gt;CHECKBOXA1=1&lt;/b&gt;. On building the &lt;b&gt;winsetup.msi&lt;/b&gt;       project, and double clicking it we are presented with this dialog box in       the second step of the installation process. The Disclaimer dialog box is       shown in the following figure.&lt;/p&gt;       &lt;p align="center"&gt;&lt;br /&gt;      &lt;/p&gt;&lt;p&gt;&lt;b&gt;The Read Me Dialog box&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      This dialog box displays the Read Me file during installation procedure       and installs it along with the application. To demonstrate this we must       add the Read Me dialog box in the Start dialog boxes category. Next we       need to associate a Rich Text File (rtf) with this dialog box. For this we       have to create a ‘ReadMe.rtf’ file and add it to the Applications       Folder. Next we have to set the &lt;b&gt;ReadmeFile &lt;/b&gt;attribute of the Read Me       Dialog box to this file. We can browse for this file and since we had       added it to the Applications Folder we will find it there. Note that we       cannot browse beyond the three folders (Application Folder, User’s       Program and User’s Programs Menu), hence if we wish to make any file       available in the project we have to first get it copied in one of these.       Now after re-building the project and installing it we are presented with       this Read Me dialog box as the 5th step of installation and this file gets       copied along with the folder.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;The Splash Dialog Box&lt;br /&gt;      &lt;/b&gt;&lt;br /&gt;      We added the Splash dialog box just after the Welcome dialog box. The User       Interface Editor after addition of all the dialog boxes is shown in the       following figure.       &lt;/p&gt;&lt;p align="center"&gt;&lt;br /&gt;      &lt;/p&gt;&lt;p&gt;To display a splash screen in the Splash dialog box, all we need to do       is to set the &lt;b&gt;SplashBitmap&lt;/b&gt; property of the dialog to a ‘.bmp’       file. To make the file available we must first add it to the Application       Folder. On re-building this project and running the installer we are       presented with the Splash dialog box.&lt;br /&gt;     &lt;br /&gt;      In the next part we would see how to add launch conditions to the setup       project.   &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-1046750533934762087?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/1046750533934762087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=1046750533934762087' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1046750533934762087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1046750533934762087'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/deploying-net-applications.html' title='Deploying .NET Applications'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-4945493841090367084</id><published>2008-08-25T02:25:00.000-07:00</published><updated>2008-12-22T21:25:46.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>What is .NET?</title><content type='html'>&lt;span style="font-family:Arial;font-size:85%;"&gt;Though not documented there are two nightmares known in the programming world. One is the development nightmare and another is the distribution nightmare. Let�s elaborate on this. &lt;/span&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt; Suppose we wish to develop an Internet application that allows businesses to communicate vital information with each other across existing communication lines. Let�s look at typical solution that can be offered to this problem using Microsoft technologies. If the application is an n-tier application then we would need HTML, DHTML &amp;amp; Java Script in the front-tier; VBScript, ASP, MTS, C++, VB, COM in the middle-tier and SQL, ADO in the back-tier. Developers possessing sufficient skill in all of these areas are few and costly. In short, a perfect recipe for development nightmare.Even if the developers are able to successfully develop the applications, they would be required to spend hours battling component version conflicts (popularly known as DLL Hell) when the time comes to install their products. Assured distribution nightmare, in short. &lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Sun�s solution to this problem could be to use Java applets and servlets in the front-tier, Enterprises Java Bean (EJB) or CORBA or RMI in the middle-tier, and JDBC and a suitable database in the back-tier. The common theme here is every developer should learn Java language. This is a far-fetched dream. Though an attempt to make every programmer a Java programmer has met with more than a lukewarm success, the ground reality is that there would be several languages in existence, each camp having its own faithful band of programmers.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;.Net is an attempt to bring order to this chaos. .Net is a development platform that makes it easier for programmers using different languages to quickly create robust internet applications. Let�s now see how .Net makes Internet development easier.&lt;/span&gt;&lt;/p&gt; &lt;h1 align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;Language Of Choice&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;A developer can pick the .Net language that he likes most, write components in it, and share the compiled binary version of his component with other developers using other .Net languages. As on date there are 22 languages including VB, C++, C#, COBOL, etc. from which the programmer can choose. Microsoft has made the specifications for .Net development platform freely available to compiler vendors in the form of Common Language Specification (CLS). Vendors can develop compilers that produce standard binary code confirming to the CLS.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Easy DeploymentDeployment in a .Net environment involves a mere file copy. There are no versioning problems as all the version information is included in the metadata (data about data) that is distributed with the component. Even different versions of the same component can run side by side on the same machine.&lt;/span&gt;&lt;/p&gt; &lt;h1 align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;Less Plumbing Code&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;VS.Net development environment eliminates a lot of hand coding by providing wizards and liberal use of drag &amp;amp; drop functionality. .Net also provides standard classes that developers can use to create powerful applications quickly.]&lt;/span&gt;&lt;/p&gt; &lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;   &lt;tbody&gt;&lt;tr&gt;     &lt;td width="13%"&gt;&lt;hr size="4" color="#990033"&gt;&lt;/td&gt;     &lt;td width="19%" bg style="color:#cc0099;"&gt;&lt;span style="font-family:Comic Sans MS;font-size:100%;color:#ffffff;"&gt;.Net       Framework&lt;/span&gt;&lt;/td&gt;     &lt;td width="68%"&gt;&lt;hr size="4" color="#990033"&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;.Net is actually wrapper around the operating system. Software developed with .Net doesn�t have to worry about operating system tasks like File Handling and Memory Allocation. Even though Microsoft doesn�t say so, this appears to be a silent preparation for the future where the software developed for .Net would be portable to a wide variety of Hardware and OS. Beta version of VS.Net supports all versions of Win2000, Windows NT4, Win9X and Windows ME. .Net makes development of Internet applications as easy as Desktop applications. Secondly, it provides a very high level of integration of front, middle and back-tier. The following figure shows major components of .Net framework. &lt;/span&gt;&lt;/p&gt; &lt;p align="center"&gt;&lt;img src="http://www.kicit.com/freebies/csharp_net_source_code/What_is_.Net/net1.gif" width="381" border="0" height="267" /&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Figure 1.1: .Net Framework &lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt; Let�s now understand these three components.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;The Common Language Runtime&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;A runtime is an environment in which programs are executed. For example, to execute a program written in VB6, the machine must have a VB runtime (msvbvm.dll) installed. Similarly VC++ programs and Java programs too require unique runtime components. Since different languages require different runtime the developer�s life becomes more difficult. Imagine a situation where an ActiveX control has been developed in VB. While downloading this component a user may also have to download the VB runtime if it is not already installed on the machine. And imagine what would be the solution if Windows weren�t installed on the machine.&lt;br /&gt;&lt;br /&gt;To avoid such problems .Net introduces a single Common Language Runtime (CLR) that all .Net languages share. The following figure shows how CLR works&lt;/span&gt;&lt;/p&gt; &lt;p align="center"&gt;&lt;img src="http://www.kicit.com/freebies/csharp_net_source_code/What_is_.Net/net2.gif" width="398" border="0" height="321" /&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;br /&gt;Figure 1.2: Execution Process Under .Net Framework&lt;br /&gt;&lt;br /&gt;Once our code is written, we compile it, and the compiler translates it to Microsoft Intermediate Language (MSIL). MSIL is a CPU-independent set of instructions that can be efficiently converted to native (CPU dependent) code. MSIL code is a language independent code. The Linker then links the IL code converted by one language compiler with the IL code compiled by another language compiler. The result is an EXE or DLL, containing the IL code, which is saved to disk. VS.Net comes with different language compilers to generate IL code. Then on execution, the IL code and any requested functionality from the .Net base classes is brought together. The JIT compiler process the combined code creating managed native code (Code that targets the runtime is called managed code. The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used.), which is passed to the CLR.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;Net Base Classes&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;.Net supplies a library of base classes that developers can use to implement applications quickly. Developers can either use them by building objects from these classes and invoking the class methods. Alternately they can derive new classes from these standard classes. &lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt; These classes include:&lt;/span&gt;&lt;/p&gt; &lt;ol type="a"&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Classes and types related to basic database     management.&lt;/span&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Classes to debug an application and to trace the     execution.&lt;/span&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Types that allow reading/writing to files and other data     streams.&lt;/span&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Members to calculate common mathematical     quantities.&lt;/span&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Capability to inspect     metadata.&lt;/span&gt;   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;Types, which enable security     capabilities.&lt;/span&gt; &lt;/p&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;b&gt;User and Program Interfaces&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;This forms the top layer in the .Net architecture. This includes Windows Forms, Windows Application Services, Web Forms and Web Services. Windows forms (often called as WinForms) offer a new way to create standard Win32 desktop applications. Web Forms provide a powerful, form-based user-interface for the web. Web Services provide a mechanism for programs to communicate over the Internet using SOAP (Simple Object Access Protocol). These services are similar to COM/DCOM services that were used for object brokering &amp;amp; interfacing. However, Web Services allow integration with non-Microsoft platform as well.&lt;br /&gt;The potential of Web Services is unlimited. For example, a software company may provide a Web Service to calculate income tax. Any company that wants to calculate income tax can subscribe to this Web Service. The customer company need not deploy the income tax calculator. It simply needs to access the Web Service. The company offering the service can dynamically update it to accommodate new taxation rates. The subscribers won�t have to do anything to get the new updates. In future a collection of such Web Services may replace packaged software. Other Web Services that can be developed include weather information, stock quotes, shipping status, news items, etc. I think you get the picture now.�&lt;/span&gt;        &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-4945493841090367084?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/4945493841090367084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=4945493841090367084' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/4945493841090367084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/4945493841090367084'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/what-is-net.html' title='What is .NET?'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-916136198615043942</id><published>2008-08-25T02:24:00.000-07:00</published><updated>2008-12-22T21:25:46.888-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Printing Through .NET</title><content type='html'>Any sophisticated application would definitely have support for printing. .NET facilitates printing with the help of a       &lt;b&gt; PrintDocument&lt;/b&gt; component. Along with this we can make use of the various dialog boxes that are commonly used for printing.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;The &lt;i&gt; PrintDocument&lt;/i&gt; Component&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;      .NET supports printing through methods and properties of the &lt;b&gt; PrintDocument&lt;/b&gt; component. The       &lt;b&gt; PrintDocument&lt;/b&gt; component is available in the Toolbox and when added to a form, it appears in the component tray at the bottom of the Windows Forms Designer. This is because the &lt;b&gt;PrintDocument&lt;/b&gt; component is not visible at runtime.&lt;br /&gt;      &lt;b&gt;&lt;br /&gt;      &lt;/b&gt;The &lt;b&gt; PrintDocument&lt;/b&gt; class represents the &lt;b&gt; PrintDocument&lt;/b&gt; component and falls under the       &lt;b&gt; System.Drawing.Printing&lt;/b&gt; namespace. Typically in a printing application we call the       &lt;b&gt; Print( )&lt;/b&gt; method of the &lt;b&gt; PrintDocument&lt;/b&gt; class. It also contains properties such as       &lt;b&gt; DefaultPageSettings&lt;/b&gt;, which gets or sets page settings that are used as defaults for all pages to be printed,       &lt;b&gt; PrinterSettings&lt;/b&gt;, which gets or sets the printer that prints the document. The class contains events like       &lt;b&gt; BeginPrint&lt;/b&gt;, &lt;b&gt; EndPrint&lt;/b&gt; and &lt;b&gt; PageEvent&lt;/b&gt;. BeginPrint is raised when the       &lt;b&gt; Print( )&lt;/b&gt; method is called and before the first page of the document is printed. Here we can do any initializations if needed.       &lt;b&gt; EndPrint&lt;/b&gt; event is raised when the last page of the document has been printed. We can do cleaning up jobs here. The       &lt;b&gt; PrintPage&lt;/b&gt; event is raised when it’s time to print the current page. We can write code in the handler of this event to do the desired printing. Hence the order of events raised when &lt;b&gt; Print( )&lt;/b&gt; method is called is &lt;b&gt; BeginPrint&lt;/b&gt;, &lt;b&gt; PrintPage&lt;/b&gt; and then       &lt;b&gt; EndPrint&lt;/b&gt;. In the following sections, we have programmed simple examples that illustrate how to use the       &lt;b&gt; PrintDocument&lt;/b&gt; component to achieve printing.&lt;br /&gt;     &lt;br /&gt;      &lt;b&gt;Printing A Salary Slip&lt;/b&gt;&lt;br /&gt;     &lt;br /&gt;Let us see an example where we wish to print salary slip of an employee. Here we have created a Windows Form Application named &lt;b&gt; Salaryslip&lt;/b&gt;. We have added 5 textboxes to the form to gather information about the employee—a ‘Name’ textbox named name, a ‘Month’ textbox named month, a ‘Gross Salary’ textbox named &lt;b&gt; sal&lt;/b&gt;, a ‘Tax’ textbox named &lt;b&gt; tax&lt;/b&gt; and a ‘Total’ textbox named       &lt;b&gt;total&lt;/b&gt;. We have added these textboxes to collect information about an employee like his name, his salary, the tax he needs to pay, etc. Next we have calculated his salary according to the tax. We have also added two buttons to the form—a ‘Print’ button named &lt;b&gt; print&lt;/b&gt; and a ‘Calculate’ button named &lt;b&gt;cal&lt;/b&gt;. As soon as the user clicks on the       &lt;b&gt; Calculate&lt;/b&gt; button the salary gets calculated and if he clicks on the Print button the salary slip gets printed. Next we have added the       &lt;b&gt; PrintDocument&lt;/b&gt; component to our form. It gets added in the component tray. We have changed the name of the component from       &lt;b&gt; PrintDocument1&lt;/b&gt; to &lt;b&gt; mypdoc&lt;/b&gt;.&lt;br /&gt;     &lt;br /&gt;      We have added an event handler called &lt;b&gt; cal_Click( )&lt;/b&gt; to handle the &lt;b&gt; Click&lt;/b&gt; event of the       &lt;b&gt; Calculate&lt;/b&gt; button. This handler is shown below:&lt;br /&gt;     &lt;br /&gt;         &lt;p class="myprog" align="justify"&gt;private void cal_Click ( object sender, System.EventArgs e )&lt;br /&gt;      {       &lt;/p&gt;&lt;p class="myprog1in" align="justify"&gt;int t = int.Parse ( sal.Text ) - int.Parse ( tax.Text ) ;&lt;br /&gt; total.Text = t.ToString( ) ;       &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;}       &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;Here we have subtracted the tax from the gross salary and stored it in an integer variable called t. Then we have set the       &lt;b&gt; Text&lt;/b&gt; property of the textbox named &lt;b&gt; total&lt;/b&gt; to &lt;b&gt; t&lt;/b&gt; (we converted       &lt;b&gt; t&lt;/b&gt; from an integer to a string). On clicking the &lt;b&gt; Print&lt;/b&gt; button the event handler called       &lt;b&gt; print_Click( )&lt;/b&gt; would get called. This handler is shown below:&lt;br /&gt;     &lt;br /&gt;      &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;private void print_Click ( object sender, System.EventArgs e )&lt;br /&gt;      {       &lt;/p&gt;&lt;p class="myprog1in" align="justify"&gt;mypdoc.Print( ) ;       &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;}       &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;In this handler we have simply called the       &lt;b&gt; Print( )&lt;/b&gt; method of the &lt;b&gt; PrintDocument&lt;/b&gt; class. Whenever the &lt;b&gt; Print( )&lt;/b&gt; method is called the events are raised. We have not added handlers for the       &lt;b&gt; BeginPrint&lt;/b&gt; and &lt;b&gt; EndPrint&lt;/b&gt; handlers. We have added a handler for the       &lt;b&gt; PrintPage&lt;/b&gt; event. If we double click on &lt;b&gt; mypdoc&lt;/b&gt; in the component tray of the Windows Form Designer, the       &lt;b&gt; mypdoc_PrintPage( )&lt;/b&gt; event handler gets added automatically to the code. This handler is shown below:&lt;br /&gt;     &lt;br /&gt;      &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;private void mypdoc_PrintPage ( object sender, System.Drawing.Printing.PrintPageEventArgs e )&lt;br /&gt;      {       &lt;/p&gt;&lt;p class="myprog1in" align="justify"&gt;Graphics g = e.Graphics ;&lt;br /&gt; SolidBrush b = new SolidBrush ( Color.Black ) ;&lt;br /&gt; Pen p = new Pen ( Color.Black, 3 ) ;&lt;br /&gt; Font f = new Font ( "Arial", 10 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawString ( "Name", f, b, 30, 50 ) ;&lt;br /&gt; g.DrawString ( empname.Text, f, b, 130, 50 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawString ( "Month", f, b, 30, 70 ) ;&lt;br /&gt; g.DrawString ( month.Text, f, b, 130, 70 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawString ( "Gross Salary", f, b, 30, 100 ) ;&lt;br /&gt; g.DrawString ( sal.Text, f, b, 130, 100 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawString ( "Tax", f, b, 30, 120 ) ;&lt;br /&gt; g.DrawString ( tax.Text, f, b, 130, 120 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawString ( "Total", f, b, 30, 140 ) ;&lt;br /&gt; g.DrawString ( total.Text, f, b, 130, 140 ) ;&lt;br /&gt;     &lt;br /&gt; Font f1 = new Font ( "Arial", 15, FontStyle.Bold ) ;&lt;br /&gt; g.DrawString ( "KNK Pvt Ltd", f1, b, 50, 10 ) ;&lt;br /&gt;     &lt;br /&gt; g.DrawRectangle ( p, 14, 4, 180, 175 ) ;&lt;br /&gt; p.Width = 2 ;&lt;br /&gt; g.DrawRectangle ( p, 22, 95, 165, 75 ) ;       &lt;/p&gt;&lt;p class="myprog" align="justify"&gt;} &lt;/p&gt;&lt;p class="mybody" align="justify"&gt;&lt;b&gt;PrintPageEventsArgs&lt;/b&gt; provides data for the       &lt;b&gt; PrintPage&lt;/b&gt; event. Using this class we have retrieved the &lt;b&gt; Graphics&lt;/b&gt; object using which we will do the painting. Next we have created       &lt;b&gt;Pen&lt;/b&gt;, &lt;b&gt; Brush&lt;/b&gt; and &lt;b&gt; Font&lt;/b&gt; objects. Then using these objects we have printed the strings.&lt;br /&gt;      Run the program. Enter the salary and tax and click the &lt;b&gt; Calculate&lt;/b&gt; button. The result would get displayed in the       &lt;b&gt; Total&lt;/b&gt; text box. Figure 1 shows the form with salary details.&lt;br /&gt;&lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;   &lt;tbody&gt;&lt;tr&gt;     &lt;td width="100%"&gt;       &lt;p align="center"&gt;&lt;br /&gt;     &lt;br /&gt;      Figure 1&lt;/p&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;       &lt;/p&gt;&lt;p class="mybody" align="left"&gt;As soon as we click the &lt;b&gt; Print&lt;/b&gt; button, the ‘Printing’ dialog indicating the number of page that is getting printed gets displayed. The salary slip that gets printed is shown in Figure 2. &lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;   &lt;tbody&gt;&lt;tr&gt;     &lt;td width="100%"&gt;       &lt;p align="center"&gt;&lt;br /&gt;     &lt;br /&gt; Figure 2&lt;/p&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;       &lt;/p&gt;&lt;p class="mybody" align="center"&gt;         &lt;/p&gt;          &lt;p align="justify"&gt; &lt;/p&gt;  &lt;!--webbot bot="Include" U-Include="../footer.htm" TAG="BODY" startspan --&gt; &lt;div align="center"&gt;   &lt;center&gt;   &lt;/center&gt; &lt;/div&gt; &lt;!--webbot bot="Include" endspan i-checksum="27678" --&gt; &lt;p align="justify"&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-916136198615043942?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/916136198615043942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=916136198615043942' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/916136198615043942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/916136198615043942'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/printing-through-net.html' title='Printing Through .NET'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3141210599755322353.post-1803864058838529806</id><published>2008-08-25T02:19:00.000-07:00</published><updated>2008-12-22T21:25:46.889-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>The .NET Framework</title><content type='html'>Not in the distant past we used different programming models for developing Windows desktop application and web based application. Programming a Windows desktop application using VB or VC++ was pretty different than programming a web based application using technologies like ASP, COM, etc. With the launch of .NET this differentiation has been obscured. .NET offers a consistent programming model irrespective of the type of application that we intend to build. Using .NET compliant languages we can create every sort of application, be it a Windows desktop application, a web application, a database application, a DLL, a setup and deployment project, a distributed application, etc.&lt;br /&gt;&lt;br /&gt;Many of Microsoft’s new technologies were extensions and improvements of previous ones. For example, COM was extended from OLE and COM+ was extended from COM. Obviously, this was to maintain the backward compatibility. Though these extensions could solve the problems at hand, they ultimately led to more complexities. Microsoft’s new .NET technology is a welcome deviation from this path. It has been thought out and designed from scratch. It does not mean that .NET is not backward compatible. We can import the existing components to work in .NET. We can also create components in .NET that can be used by the existing clients. .NET is a new framework for programming Windows. It provides an application execution environment that manages memory, addresses versioning issues and improves the reliability, scalability, and security of your application.&lt;br /&gt;&lt;br /&gt;Microsoft has upgraded VB and languages like C++, COBOL, etc. to target the .NET environment. In addition to these languages, it has provided a fresh .NET compliant language—C#. It is natural to think that migration from Microsoft’s popular Visual Basic language to VB.NET or transition from VC++ to VC++.NET would be smooth. But one quick look at C# would convince you that in many cases coding in C# is more clean, pleasant and efficient.&lt;br /&gt;&lt;br /&gt;There are two main components of .NET framework—.NET Framework Base Class Library (FCL) and Common Language Runtime (CLR). Let us understand each of them.&lt;br /&gt;&lt;br /&gt;The base class library is an extensive common class library that can be used by any .NET compliant language. These classes encapsulate a high degree of functionality that programmers can use in their programs. The library includes classes for creating and displaying windows forms, web forms, serialization, accessing network and internet, manipulating XML documents, accessing databases, etc.&lt;br /&gt;&lt;br /&gt;Common Language Runtime is the heart of .NET framework. It actually manages the code during execution. The code that runs under CLR is called ‘managed code’. The code that is executed under .NET runtime gets benefits like cross-language inheritance, cross-language exception handling, enhanced security, versioning and deployment support, a simplified model for component interaction, and debugging and profiling services.&lt;br /&gt;&lt;br /&gt;Following figure illustrates the components of .NET framework. &lt;!--&lt;p class="mybody" align="center"&gt;&lt;img border="0" src="cart01.jpg" width="373" height="195" /&gt;&lt;/p&gt; --&gt; &lt;p class="mybody" align="center"&gt;&lt;img src="file:///D:/Documents%20and%20Settings/shesu04/Desktop/temp/cart01.jpg" width="373" border="0" height="195" /&gt;&lt;/p&gt; &lt;p class="mybody"&gt;The applications created in .NET compliant languages use the classes provided by base class library. These applications run under .NET runtime that manages the lifetime of objects created by applications, throws exceptions, etc.&lt;br /&gt;Let us now take a look at other important features of .NET.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Common Type System&lt;/b&gt;: Language interoperability under .NET is possible only when all the languages share a common data type system. For this, common type system (CTS) is introduced. CTS ensures that an &lt;b&gt; int&lt;/b&gt; in C# is same as an &lt;b&gt; int&lt;/b&gt; in VC++. Under CTS, all the classes are derived from the &lt;b&gt; System.Object&lt;/b&gt; class and all the primitive data types are mapped to the structures defined in base class library. CTS also specifies the visibility level (from where the type should be accessible) of data types.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Intermediate Language&lt;/b&gt;: A .NET programming language does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). IL is a CPU-independent language. The IL code is sent to the CLR that converts the code to machine language using the Just In Time compiler, which is then run on the host machine. Important aspect of IL language is that it provides the hardware abstraction layer. We can view the IL code of our application using the ILDASM tool shipped with Visual Studio.NET.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JIT Compilation&lt;/b&gt;: JIT (Just In Time) compiler is a crucial component of .NET framework. The JIT compiler converts IL code into machine code, which is then executed. The JIT compiler does not compile entire code at once because it could hamper the performance of the program. It compiles the code at runtime, at the time it is called. The code that is compiled gets stored until the execution comes to an end. This avoids recompilation of code. The reason why conversion from IL code to machine code takes place at runtime is that, the JIT first gets information of the processor type and convert the IL code so that it would run on that type of processor.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Assemblies&lt;/b&gt;: An assembly is a unit containing IL code of a program. It is similar to a DLL file, but difference is that unlike DLL, an assembly is self-describing. Assemblies contain assembly metadata (or manifest) that gives details of the assembly, type metadata describing the types, methods, etc. defined in the assembly and resources.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Garbage Collection&lt;/b&gt;: Garbage Collection is a program that is invoked by the CLR to free the memory that is not being used by the application. Because of this technique the programmers no more need to take care of memory leakages, dangling pointers and clean up of memory.&lt;br /&gt;I hope that what we saw above would give you a glimpse of .NET framework. Let us now create a simple program in C# that uses the .NET framework. It is assumed that you have installed Visual Studio.NET on a machine running under Windows NT/2000/XP.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size:100%;"&gt;The First C# Program&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;The steps to create the program are given below.&lt;/p&gt; &lt;ul&gt;&lt;li&gt;     &lt;p class="mybody" style="line-height: 150%;"&gt;Start Microsoft Visual Studio.NET from ‘Start | Program | Microsoft Visual Studio.NET’ menu option.   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p class="mybody" style="line-height: 150%;"&gt;Create a new C# project by selecting ‘File | New | Project’ menu option. A ‘New Project’ dialog would appear. From the ‘New Project’ dialog box select project type as ‘Visual C# Projects’. &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p class="mybody" style="line-height: 150%;"&gt;Select ‘Console Application’ from the list of Templates.   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p class="mybody" style="line-height: 150%;"&gt;Select a location where this project should get saved. Give name to the project as     &lt;b&gt;Simple&lt;/b&gt;. Click the OK button.   &lt;/p&gt;&lt;/li&gt;&lt;li&gt;     &lt;p class="mybody" style="line-height: 150%;"&gt;A ‘Class1.cs’ file (cs stands for CSharp) would get created with the skeleton code given below. &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="myprog"&gt;using System ;&lt;br /&gt;namespace Simple&lt;br /&gt;{&lt;/p&gt; &lt;p class="myprog1in"&gt;class Class1&lt;br /&gt; {&lt;/p&gt; &lt;p class="myprog2in"&gt;static void Main ( string[ ] args )&lt;br /&gt;  {&lt;/p&gt; &lt;p class="myprog2in"&gt;}&lt;/p&gt; &lt;p class="myprog1in"&gt;}&lt;/p&gt; &lt;p class="myprog"&gt;}&lt;/p&gt; &lt;p class="mybody"&gt;Now, add the following statement that would display the string “Hello world” on screen.&lt;/p&gt; &lt;p class="myprog"&gt;Console.WriteLine ( “Hello C#” ) ;&lt;/p&gt; Compile and execute the program by pressing Ctrl + F5. The program execution starts from the Main( ) function. Since C# is a pure object-oriented language it does not allow us to create global variables and functions. Instead, all variables and functions including Main( ) should be defined inside a class.&lt;br /&gt;&lt;br /&gt;To send output to the screen we have used the WriteLine( ) function. We can display any data type through this function. Since WriteLine( ) belongs to the Console class we have to use the form Console.WriteLine( ) to call it.&lt;br /&gt;&lt;br /&gt;To be able to use the Console class in any program we need to import it from a namespace, which has been done in our program through the statement using System. Like the Console class our class is also enclosed in the Simple namespace.&lt;br /&gt;&lt;br /&gt;Those who have not done C++ programming may find the terms class and namespace confusing. We would discuss them in detail in the forthcoming articles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3141210599755322353-1803864058838529806?l=msdotnettutorial.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://msdotnettutorial.blogspot.com/feeds/1803864058838529806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3141210599755322353&amp;postID=1803864058838529806' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1803864058838529806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3141210599755322353/posts/default/1803864058838529806'/><link rel='alternate' type='text/html' href='http://msdotnettutorial.blogspot.com/2008/08/net-framework.html' title='The .NET Framework'/><author><name>sandy</name><uri>http://www.blogger.com/profile/02503582209971047801</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
