use the following query to selct number of rows in multiple tables
select table_name, num_rows from user_tables where lower(table_name) in ('Table1',
'Table2',
'Table3')
Monday, December 21, 2009
Oracle: Stored procedure for Analyzing Tables
1. Create the following procedure by changing the 'User Name'
CREATE OR REPLACE PROCEDURE analyze_tables IS
BEGIN
FOR syn_cur IN (SELECT table_name
FROM user_tables)
LOOP
DBMS_STATS.GATHER_TABLE_STATS(ownname => 'User Name',
tabname => syn_cur.TABLE_NAME,
estimate_percent => NULL,
cascade => TRUE);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
null;
END analyze_tables;
2. Run the procedure as below
begin
-- Call the procedure
analyze_tables;
end;
That is it.
CREATE OR REPLACE PROCEDURE analyze_tables IS
BEGIN
FOR syn_cur IN (SELECT table_name
FROM user_tables)
LOOP
DBMS_STATS.GATHER_TABLE_STATS(ownname => 'User Name',
tabname => syn_cur.TABLE_NAME,
estimate_percent => NULL,
cascade => TRUE);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
null;
END analyze_tables;
2. Run the procedure as below
begin
-- Call the procedure
analyze_tables;
end;
That is it.
Labels:
Oracle
Wednesday, December 16, 2009
Resolving Can't Login To Sqlexpress Using Sa Account
When installing Visual Studio 2005 or Visual Studio 2008, the installer will automatically install for us one instance of SQL Server 2005 Express. But we can't actually connect the database without extra tools and we can't login except using Integrated Security. In this article I will explain how to download extra tools and how to login using sa account (not Windows Authentication Mode).
1. First download Management Studio Express for SQL Server Express 2005, http://www.microsoft.com/downloads/details...;displaylang=en this tool will enable you to connect with SQLExpress instance that is installed via Visual Studio. Install this tool and you can connect to database [MyComputerName]\SQLEXPRESS but for first you will need to use Windows Authentication mode. This way you can connect to the instance.
2. After success connecting the database, Open Security tree, Logins tree and you can see sa account. Double click 'sa' account and from General page, change the Password and Confirm Password to new password that you want. Then change to Status page, on Login section select Enabled. Then click OK.
3. Now right click the [MyComputerName]/SQLExpress and select Properties then open the Security page, on Server Authentication section select SQL Server and Windows Authentication Mode.
4. Open Services diaog box, (on Control Panel open Administrative Tools, then Services). Select the SQL Server (SQLEXPRESS) service, restart this service.
5. Now you can connect to SQLEXPRESS instance using Management Studio via sa account and new password you set.
The issues raise because by default Microsoft has (once again) made the free SQLEXPRESS by default instance only with Windows Authentication Mode (which means that it will accept connection only from integrated security, like from local computer or computer that has login for it). And by that reason, SQLEXPRESS is limited to developer, thus some developer does not know that this default behaviour can actually reconfigure. After configuration you may see that SQLEXPRESS can now act like a decent database, and even more if you read my other article here you can even configure the instance name SQLEXPRESS to whatever you like!
LINK:
Resolving Can't Login To Sqlexpress Using Sa Account
1. First download Management Studio Express for SQL Server Express 2005, http://www.microsoft.com/downloads/details...;displaylang=en this tool will enable you to connect with SQLExpress instance that is installed via Visual Studio. Install this tool and you can connect to database [MyComputerName]\SQLEXPRESS but for first you will need to use Windows Authentication mode. This way you can connect to the instance.
2. After success connecting the database, Open Security tree, Logins tree and you can see sa account. Double click 'sa' account and from General page, change the Password and Confirm Password to new password that you want. Then change to Status page, on Login section select Enabled. Then click OK.
3. Now right click the [MyComputerName]/SQLExpress and select Properties then open the Security page, on Server Authentication section select SQL Server and Windows Authentication Mode.
4. Open Services diaog box, (on Control Panel open Administrative Tools, then Services). Select the SQL Server (SQLEXPRESS) service, restart this service.
5. Now you can connect to SQLEXPRESS instance using Management Studio via sa account and new password you set.
The issues raise because by default Microsoft has (once again) made the free SQLEXPRESS by default instance only with Windows Authentication Mode (which means that it will accept connection only from integrated security, like from local computer or computer that has login for it). And by that reason, SQLEXPRESS is limited to developer, thus some developer does not know that this default behaviour can actually reconfigure. After configuration you may see that SQLEXPRESS can now act like a decent database, and even more if you read my other article here you can even configure the instance name SQLEXPRESS to whatever you like!
LINK:
Resolving Can't Login To Sqlexpress Using Sa Account
Labels:
Sql Server 2005
Tuesday, December 8, 2009
Install WSS on Vista or Windows 7
I was in an impression of WSS can not be installed on Vista / Windows 7. But I was wrong.
Found some cool links to achieve this
Installing Windows SharePoint Services on Windows 7 (or Vista)
Installing WSS 3.0 SP2 / MOSS SP2 on Windows 7 RC
Running SharePoint on Windows 7
Install MOSS 2007 & WSS 3.0 on Windows Server 2008 R2 – you will need SP2 slipstream
WSS 3 on Windows 7
Running SharePoint on Windows 7
How to install Windows SharePoint Services 3.0 SP1 on Vista x64/x86
Found some cool links to achieve this
Installing Windows SharePoint Services on Windows 7 (or Vista)
Installing WSS 3.0 SP2 / MOSS SP2 on Windows 7 RC
Running SharePoint on Windows 7
Install MOSS 2007 & WSS 3.0 on Windows Server 2008 R2 – you will need SP2 slipstream
WSS 3 on Windows 7
Running SharePoint on Windows 7
How to install Windows SharePoint Services 3.0 SP1 on Vista x64/x86
Labels:
WSS 3.0 And Sharepoint 2007
Tuesday, April 7, 2009
How to Remotely Restart a Windows Machine Through Command Line
The DOS command line built into every windows machine can be used to perform a lot of useful tasks. One very helpful task is shutting down your computer. By working your way through a few simple steps, you will find that you are able to easily shut down or restart your computer.
Steps
- Make sure you have an administrative rights on the remote machine and you can PING it.
- On your workstation - Click on Start > Run, Type shutdown -i
- select options to shutdown or restart
- Alternatively - Go to command prompt (start > run > cmd) on your workstation... and Type shutdown -r -m \\xxx.xxx.xxx.xxxReplace xxx.xxx.xxx.xxx with the IP address or computer name of the remote machine. -r option is for restart, don't use -r if want to just shut down the system.
Tips
- Type shutdown -? for more options and control over shutdown command..
Warnings
- Works only for windows servers and workstations.
- Shutdown is not an inherent command in Windows Server. You need to install the Windows Server Admin Pack to get this functionality. Out of the box, this will not work.
Labels:
Command line
Monday, February 16, 2009
What is New In Visual Studio 2008 And .Net Framework 3.5 - Part 4
Following are the some of articles describes the updates on VS2008
New for Visual Studio 2008 SP1 and FxCop 1.36 – Multi-targeting rule
http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx
Visual Studio 2008 - New Features
http://www.codeproject.com/KB/dotnet/Visual_Studio_2008.aspx
http://msdn.microsoft.com/en-us/library/bb386063.aspx
New for Visual Studio 2008 SP1 and FxCop 1.36 – Multi-targeting rule
http://davesbox.com/archive/2008/08/25/new-for-visual-studio-2008-sp1-and-fxcop-1-36-multi-targeting-rule.aspx
Visual Studio 2008 - New Features
http://www.codeproject.com/KB/dotnet/Visual_Studio_2008.aspx
http://msdn.microsoft.com/en-us/library/bb386063.aspx
Labels:
Visual Studio 2008
What is New In Visual Studio 2008 And .Net Framework 3.5 - Part 3
New in Visual Studio 2008 Original Release Version
Integrated Development Environment (IDE)
Settings Migration
If you have Visual Studio 2005 and Visual Studio 2008 installed on the same computer, then when you first start Visual Studio 2008, you can migrate most of your settings from Visual Studio 2005. Third-party code snippets and add-ins cannot be automatically migrated and must be manually installed again for use in Visual Studio 2008. If you do not have Visual Studio 2005 and Visual Studio 2008 installed on the same computer, you can still manually migrate your Visual Studio 2005 settings for use in Visual Studio 2008.
Community Components
When you author community components by using Visual Studio 2008, you can specify whether you intend the component to be installed for use with Visual Studio 2005 and Visual Studio 2008 or just with Visual Studio 2008 by using a new value for the ContentVersion element. If you install a community component designed in Visual Studio 2005, the component will automatically be installed for use with both Visual Studio 2005 and Visual Studio 2008.
The Community menu has been removed for Visual Studio 2008. The commands formerly known as Ask a Question and Check Question Status have been combined into a new command named MSDN Forums, which is on the Help menu. The Send Feedback command is now the Report a Bug command, also on the Help menu. All other commands that were on the Community menu were removed from Visual Studio 2008.
Window Management and General User Elements
Several user interface (UI) elements have been updated. These include the following:
* IDE Navigator: An improved interface makes switching between items easier.
* Tool window docking targets have been improved to make tool windows easier to dock.
* Common dialog boxes: Visual Studio 2008 uses Windows standard dialog boxes instead of custom dialog boxes. This makes the navigation experience more consistent with that of Windows.
* You can now specify a custom font for IDE elements not identified individually in the Show settings for list in the Fonts and Colors, Environment, Options Dialog Box by using the new option Environment Font.
Class Designer Support for Visual C++ Code
In earlier versions of Visual Studio, the Class Designer supported only the managed languages (Visual C# and Visual Basic). In Visual Studio 2008, Class Designer adds limited support for native C++ code that can be used only for visualization and documentation. For more information about Visual C++ support in Class Designer, see Working with Visual C++ Code in Class Designer.
Projects and Solutions
Web Application Projects
The new Web application project model provides the same Web project semantics as the Visual Studio .NET 2003 Web project model. This includes a structure based on project files and a build model based on compiling all the code for a project into a single assembly. In addition, the new project type supports many of the new features of Visual Studio 2005 (such as class diagrams, test development, and generics) and of ASP.NET version 2.0 (such as master pages, data controls, membership and logon, role management, Web parts, personalization, site navigation, and themes).
The Web application project model in Visual Studio 2005 removes two elements that are required for Web projects in Visual Studio .NET 2003:
* Using FrontPage Server Extensions. These are no longer required, but they are supported if your site already uses them.
* Using a local copy of Internet Information Services (IIS). The new project model supports both IIS and the built-in ASP.NET Development Server.
Use Web application projects when you have to do one of the following:
* Migrate large applications from Visual Studio .NET 2003 to Visual Studio 2005.
* Control the names of output assemblies.
* Use stand-alone classes to reference page and user-control classes.
* Build a Web application that includes multiple Web projects.
* Add pre-build and post-build steps during compilation.
AJAX Development
You can now create Web applications that feature next-generation user interfaces and reusable client components that use the new features of Visual Studio 2005. You can develop Web pages by using a server-based approach, a client-based approach, or a combination of both, according to your requirements. The AJAX server-based and client-based programming models are supported by the following:
* Server controls that support server-based AJAX development. This includes the ScriptManager, UpdatePanel, UpdateProgress, and Timer controls. These controls enable you to create rich client behavior, such as partial-page rendering and displaying update progress during asynchronous postbacks, with little or no client script.
* The Microsoft AJAX Library, which supports client-based, object-oriented development that is browser independent. In addition to supporting the new AJAX-enabled server controls, the client library enables you to develop custom client components that extend DOM elements or that represent a DOM element.
* Server classes that enable you to develop server controls that map to custom client components whose events and properties are set declaratively. Server types that support this functionality include controls that derive from the ExtenderControl or ScriptControl base classes, or that implement the IExtenderControl or IScriptControl interfaces.
* Support for script globalization and localization. Globalization enables you to display dates and numbers based on a culture value (locale). Localization enables you to specify localized content (text, images, and so on) for client components for UI elements or exception messages.
* Access to Web services and to ASP.NET authentication, roles management, and profile application services.
Visual Studio 2008 enables you to easily enable asynchronous partial-page updates in a page, which avoids the overhead of full-page postbacks. You can just put existing controls and markup inside UpdatePanel controls. Postbacks from inside an UpdatePanel control become asynchronous postbacks and refresh only the part of the page inside the panel, which creates a more fluid user experience. You can display the progress of the partial-page update by using UpdateProgress controls.
Project Designer
Project Designer Support for Windows Presentation Foundation (WPF) Applications
Windows Presentation Foundation (WPF) applications have been added to Visual Studio 2008. There are four WPF project types:
* WPF Application (.xaml, .exe)
* WPF Browser Application (.exe, .xbap)
* WPF Custom Control Library (.dll)
* WPF User Control Library (.dll)
When a WPF project is loaded in the IDE, the user interface of the Project Designer pages lets you specify properties specific to WPF applications.
Project Designer Support for Web Application Projects
Web Application projects were added to Visual Studio in Visual Studio 2005 Service Pack 1 and are also included in Visual Studio 2008. The new Web Application project model provides the same Web Application project semantics as the Visual Studio .NET 2003 Web project model, except updated with features of Visual Studio 2005 and ASP.NET version 2.0. The Visual Studio Project Designer supports Web application projects, with the following limitations:
* On the Settings page, Web application projects can only be application-scoped. For more information, see Settings Page, Project Designer.
* On the Signing page, the manifest signing option is disabled because Web application projects do not use ClickOnce deployment. For more information, see Signing Page, Project Designer.
Project Designer Multitargeting Support
Multitargeting lets you target code to a specific .NET Framework version:
* .NET Framework 2.0, which was included with Visual Studio 2005.
* .NET Framework 3.0, which is included with Windows Vista.
* .NET Framework 3.5, which is included with Visual Studio 2008.
To support multitargeting, the Advanced Compiler Settings (Visual Basic) and Advanced Build Settings (C#) dialog boxes have a new Target framework drop-down list that lets you specify these operating systems. For more information, see Advanced Compiler Settings Dialog Box (Visual Basic) and Advanced Build Settings Dialog Box (C#).
Deployment
ClickOnce Deployment
ClickOnce deployment has been enhanced with the following new features:
* ClickOnce supports the deployment of WPF Web Browser Applications. WPF Web Browser Applications are hosted in a Web browser and therefore require special deployment and security settings. When you build and deploy these applications, Visual Studio will provide appropriate user interface and default values.
* ClickOnce gives ISVs the option to re-sign the application manifest with their customer's company name, application name, and deployment/support URL. When end users install the application, the ISV's original company branding still appears on the "Do you want to trust this application?" dialog box.
* You can build and deploy Visual Studio Tools for Office applications by using the Project Designer's Publish page or the Publish Wizard.
* ClickOnce supports manifest generation under User Account Control (UAC) on Windows Vista.
* ClickOnce supports the deployment of Office add-ins and documentation when you use Visual Studio Tools For Office. For more information, see the Visual Studio Tools for Office Developer Center Web site.
* ClickOnce has better support for third-party browsers. Earlier versions supported installation in third-party browsers by using plug-ins, which sometimes caused problems. In this version, a user can install a ClickOnce file directly by using the Run command.
* You can associate file name extensions with a ClickOnce application, so that the application can be started directly from the associated file type. For more information, see How to: Create File Associations For a ClickOnce Application.
* ClickOnce has better support for changing the deployment location of an application and handling certificate expiration. For more information about the ClickOnce security model, see ClickOnce Deployment and Authenticode.
* For security, ClickOnce applications are always installed and run on a per-user basis. An application that requests Administrator privileges from Windows Vista UAC fails gracefully during installation.
Windows Installer Deployment
Windows Installer deployment has been updated for Windows Vista and the latest .NET Framework versions:
* Windows Installer has been updated so that installation on Windows Vista is smooth, even when it is running under UAC.
* The .NET Framework Launch Condition supports targeting applications for the new .NET Framework 3.0 and 3.5 versions.
Editing
New Design View and CSS Design Tools
Visual Studio 2008 now has a rich CSS editing experience with several new tools to make working with cascading style sheets (CSS) easier than ever. Much of the work designing the layout and styling content can be done in Design view using the CSS Properties grid, the Apply Styles and Manage Styles panes, and the Direct Style Application tool. You can also change positioning, padding, and margins in Design view using WYSIWYG visual layout tools.
IntelliSense for Jscript and ASP.NET AJAX
IntelliSense has been significantly improved and now supports JScript authoring and ASP.NET AJAX scripting. Client script that is included in a Web page by using "" tags now has the benefit of IntelliSense, as do .js script files.
Additionally, IntelliSense displays XML code comments. XML code comments are used to describe the summary, parameter, and return details of the client script. ASP.NET AJAX also uses XML code comments to provide IntelliSense of ASP.NET AJAX types and members. IntelliSense is also supported for external script file references that use XML code comments.
Object Browser and Find Symbol Support for Multi-targeting
You now can specify that the Object Browser display only information for a single version of the .NET Framework or the .NET Compact Framework. In addition, Find Symbol, Find and Replace Window searches can be restricted to a single version of the .NET Framework or the .NET Compact Framework.
WPF Designer
The Windows Presentation Foundation (WPF) Designer lets you create WPF applications and custom controls in the IDE. The WPF Designer combines real-time editing of XAML with an enhanced graphical design-time experience. The following features are new for the WPF Designer:
* SplitView lets you adjust objects in the graphical designer and immediately view the changes to the underlying XAML code. Likewise, changes to the XAML code are immediately reflected in the graphical designer.
* The Document Outline window lets you view and move through your XAML with full selection synchronization between the designer, the document outline, the XAML editor, and the Properties window.
* IntelliSense in the XAML editor enables rapid code entry. IntelliSense now supports types that you have defined.
* Grid lines can be added to grids in the designer to enable easy grid-based control placement.
* Snap lines let you easily align controls and text.
* The designer now supports the loading of types you have defined. These include custom controls and user controls.
* You can cancel loading of large XAML files.
* Design-time extensibility supports design mode and property editors.
Data
* The Object Relational Designer (O/R Designer) assists developers in creating and editing the LINQ to SQL objects that map between an application and a database. The O/R Designer creates the DataContext, entity classes, and DataContext methods that are used by LINQ to SQL to communicate with the remote database and handle data that is used in your application. For more information, see O/R Designer Overview.
* N-Tier support for typed datasets provides enhancements to the Dataset Designer that assist in separating TableAdapter code and typed dataset code into discrete projects. For more information, see N-Tier Data Application Overview.
* Hierarchical update capabilities have been incorporated into the Dataset Designer to enable saving data in multiple related tables. A new TableAdapterManager object providing generated code that includes the save logic necessary for maintaining referential integrity has been added to typed datasets. Instead of calling the Update method for each TableAdapter, call the TableAdapterManager.UpdateAll method. For more information, see Hierarchical Update.
* Local database caching incorporates a SQL Server Compact 3.5 database and Microsoft Synchronization Services for ADO.NET into an application and prepares the application to periodically synchronize the data with a remote database on a server. Local database caching enables applications to reduce the number of round trips between the application and a database server. This can increase performance when you are working with data that changes infrequently or when applications are not always able to connect to the remote database. For more information, see Occasionally Connected Applications Overview.
* Microsoft SQL Server Compact 3.5 is a compact database that can be deployed on desktop computers, smart devices, and Tablet PCs. SQL Server Compact 3.5 is a local database that is easily incorporated into applications and is easily deployed. For more information, see Using SQL Server Compact 3.5 (Visual Studio).
Language-Integrated Query (LINQ)
Language-Integrated Query (LINQ) is a new set of features in Visual Studio 2008 that extend powerful query capabilities into the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and transforming data, and can be extended to support potentially any kind of data source. Visual Studio 2008 includes LINQ provider assemblies that enable language-integrated querying of .NET Framework collections (LINQ to Objects), SQL Databases (LINQ to SQL), ADO.NET Datasets (LINQ to ADO.NET), and XML documents (LINQ to XML).
The standard query operators are the methods that comprise the query capabilities in the LINQ pattern.
Enumerable
Queryable
Client Application Services
Client application services are new in the .NET Framework 3.5 and enable Windows-based applications (including Windows Forms and Windows Presentation Foundation applications) to easily access the ASP.NET login, roles, and profile services. These services let you authenticate users and retrieve user roles and application settings from a shared server.
You can enable client application services by specifying and configuring client service providers in the Visual Studio Project Designer or in your application configuration file. These providers plug into the Web extensibility model and let you access the Web services through existing .NET Framework login, roles, and settings APIs. Client application services also support occasional connectivity by storing and retrieving user information from a local data cache when the application is offline.
Reporting
Visual Studio 2008 provides several new reporting features and improvements.
New Report Projects
Visual Studio 2008 includes two new project templates for creating reporting applications. You will find the Reports Application template available on the New Project dialog box and the ASP.NET Reports Web Site template available on the New Web Site dialog box. When you create a new Reports Application project, Visual Studio provides a report (.rdlc) and a form (.vb/.cs) with a ReportViewer control bound to the report. For an ASP.NET Reports Web Site project, Visual Studio will create a Web site that contains a report (.rdlc), default ASP.NET page (.aspx) with a ReportViewer control bound to the report, and Web configuration file (.config).
When you create a report project, a new Report Wizard is started. You can then use the wizard to build the report, or alternatively, close the wizard and build the report manually.
Report Wizard
Visual Studio 2008 introduces a Report Wizard, which guides you through the steps to create a basic report. You will select a report data source, define a data set, select a report type (tabular or matrix), and apply a style to the report. After you complete the wizard, you can enhance the report by using Report Designer.
The Report Wizard is started automatically when you create a new Reports Application project or ASP.NET Reports Web Site.
Expression Editor Enhancement
The Expression Editor now provides sample expressions that you can use in report expressions. You can copy the sample expressions to your report to use as is or modify to suit your needs.
ReportViewer Printing
The RSClientPrint control is now available when the ASP.NET ReportViewer control is configured for local processing. This enables you to print reports that have been processed by the control and are independent of a report server.
PDF Compression
The ReportViewer controls will now compress reports that are rendered or exported to the PDF format when they are configured for local processing.
MSBuild
Target a Specific .NET Framework
MSBuild now lets you build projects for specific versions of the .NET Framework. Several new API functions support this new functionality. For more information, see Building for Specific .NET Frameworks.
Multiple Processor Capabilities
MSBuild now recognizes when a system is using multiple processors, either multicore processors or multiple separate processors. MSBuild uses all the available processors to reduce the overall build time for projects. For more information, see Using Multiple Processors to Build Projects.
Enhanced Logging
Build event logging has been upgraded to handle multi-processor builds. MSBuild now supports the distributed logging model in addition to the central logging model, and introduces a new technology known as "forwarding loggers." For more information, see Logging in MSBuild.
Item Definitions
The new ItemDefinitionGroup project file element lets you define a set of Item Definitions, which are global default metadata values that are applied to all items in the project. For more information, see Item Definitions.
Assembly Location and Name Changes
The file names and locations of the MSBuild assemblies have been updated for Visual Studio 2008. The following assemblies now have "v3.5" appended to their file names:
* Microsoft.Build.Conversion.v3.5.dll
* Microsoft.Build.Utilities.v3.5.dll
* Microsoft.Build.Tasks.v3.5.dll
In addition, the following build assemblies are now located in \Program Files\Reference Assemblies\Microsoft\Framework\v3.5\:
* Microsoft.Build.Conversion.v3.5.dll
* Microsoft.Build.Engine.dll
* Microsoft.Build.Framework.dll
* Microsoft.Build.Utilities.v3.5.dll
The Microsoft.Build.Tasks.v3.5.dll file is located in \Windows\Microsoft.NET\Framework\v3.5\.
Integrated Development Environment (IDE)
Settings Migration
If you have Visual Studio 2005 and Visual Studio 2008 installed on the same computer, then when you first start Visual Studio 2008, you can migrate most of your settings from Visual Studio 2005. Third-party code snippets and add-ins cannot be automatically migrated and must be manually installed again for use in Visual Studio 2008. If you do not have Visual Studio 2005 and Visual Studio 2008 installed on the same computer, you can still manually migrate your Visual Studio 2005 settings for use in Visual Studio 2008.
Community Components
When you author community components by using Visual Studio 2008, you can specify whether you intend the component to be installed for use with Visual Studio 2005 and Visual Studio 2008 or just with Visual Studio 2008 by using a new value for the ContentVersion element. If you install a community component designed in Visual Studio 2005, the component will automatically be installed for use with both Visual Studio 2005 and Visual Studio 2008.
The Community menu has been removed for Visual Studio 2008. The commands formerly known as Ask a Question and Check Question Status have been combined into a new command named MSDN Forums, which is on the Help menu. The Send Feedback command is now the Report a Bug command, also on the Help menu. All other commands that were on the Community menu were removed from Visual Studio 2008.
Window Management and General User Elements
Several user interface (UI) elements have been updated. These include the following:
* IDE Navigator: An improved interface makes switching between items easier.
* Tool window docking targets have been improved to make tool windows easier to dock.
* Common dialog boxes: Visual Studio 2008 uses Windows standard dialog boxes instead of custom dialog boxes. This makes the navigation experience more consistent with that of Windows.
* You can now specify a custom font for IDE elements not identified individually in the Show settings for list in the Fonts and Colors, Environment, Options Dialog Box by using the new option Environment Font.
Class Designer Support for Visual C++ Code
In earlier versions of Visual Studio, the Class Designer supported only the managed languages (Visual C# and Visual Basic). In Visual Studio 2008, Class Designer adds limited support for native C++ code that can be used only for visualization and documentation. For more information about Visual C++ support in Class Designer, see Working with Visual C++ Code in Class Designer.
Projects and Solutions
Web Application Projects
The new Web application project model provides the same Web project semantics as the Visual Studio .NET 2003 Web project model. This includes a structure based on project files and a build model based on compiling all the code for a project into a single assembly. In addition, the new project type supports many of the new features of Visual Studio 2005 (such as class diagrams, test development, and generics) and of ASP.NET version 2.0 (such as master pages, data controls, membership and logon, role management, Web parts, personalization, site navigation, and themes).
The Web application project model in Visual Studio 2005 removes two elements that are required for Web projects in Visual Studio .NET 2003:
* Using FrontPage Server Extensions. These are no longer required, but they are supported if your site already uses them.
* Using a local copy of Internet Information Services (IIS). The new project model supports both IIS and the built-in ASP.NET Development Server.
Use Web application projects when you have to do one of the following:
* Migrate large applications from Visual Studio .NET 2003 to Visual Studio 2005.
* Control the names of output assemblies.
* Use stand-alone classes to reference page and user-control classes.
* Build a Web application that includes multiple Web projects.
* Add pre-build and post-build steps during compilation.
AJAX Development
You can now create Web applications that feature next-generation user interfaces and reusable client components that use the new features of Visual Studio 2005. You can develop Web pages by using a server-based approach, a client-based approach, or a combination of both, according to your requirements. The AJAX server-based and client-based programming models are supported by the following:
* Server controls that support server-based AJAX development. This includes the ScriptManager, UpdatePanel, UpdateProgress, and Timer controls. These controls enable you to create rich client behavior, such as partial-page rendering and displaying update progress during asynchronous postbacks, with little or no client script.
* The Microsoft AJAX Library, which supports client-based, object-oriented development that is browser independent. In addition to supporting the new AJAX-enabled server controls, the client library enables you to develop custom client components that extend DOM elements or that represent a DOM element.
* Server classes that enable you to develop server controls that map to custom client components whose events and properties are set declaratively. Server types that support this functionality include controls that derive from the ExtenderControl or ScriptControl base classes, or that implement the IExtenderControl or IScriptControl interfaces.
* Support for script globalization and localization. Globalization enables you to display dates and numbers based on a culture value (locale). Localization enables you to specify localized content (text, images, and so on) for client components for UI elements or exception messages.
* Access to Web services and to ASP.NET authentication, roles management, and profile application services.
Visual Studio 2008 enables you to easily enable asynchronous partial-page updates in a page, which avoids the overhead of full-page postbacks. You can just put existing controls and markup inside UpdatePanel controls. Postbacks from inside an UpdatePanel control become asynchronous postbacks and refresh only the part of the page inside the panel, which creates a more fluid user experience. You can display the progress of the partial-page update by using UpdateProgress controls.
Project Designer
Project Designer Support for Windows Presentation Foundation (WPF) Applications
Windows Presentation Foundation (WPF) applications have been added to Visual Studio 2008. There are four WPF project types:
* WPF Application (.xaml, .exe)
* WPF Browser Application (.exe, .xbap)
* WPF Custom Control Library (.dll)
* WPF User Control Library (.dll)
When a WPF project is loaded in the IDE, the user interface of the Project Designer pages lets you specify properties specific to WPF applications.
Project Designer Support for Web Application Projects
Web Application projects were added to Visual Studio in Visual Studio 2005 Service Pack 1 and are also included in Visual Studio 2008. The new Web Application project model provides the same Web Application project semantics as the Visual Studio .NET 2003 Web project model, except updated with features of Visual Studio 2005 and ASP.NET version 2.0. The Visual Studio Project Designer supports Web application projects, with the following limitations:
* On the Settings page, Web application projects can only be application-scoped. For more information, see Settings Page, Project Designer.
* On the Signing page, the manifest signing option is disabled because Web application projects do not use ClickOnce deployment. For more information, see Signing Page, Project Designer.
Project Designer Multitargeting Support
Multitargeting lets you target code to a specific .NET Framework version:
* .NET Framework 2.0, which was included with Visual Studio 2005.
* .NET Framework 3.0, which is included with Windows Vista.
* .NET Framework 3.5, which is included with Visual Studio 2008.
To support multitargeting, the Advanced Compiler Settings (Visual Basic) and Advanced Build Settings (C#) dialog boxes have a new Target framework drop-down list that lets you specify these operating systems. For more information, see Advanced Compiler Settings Dialog Box (Visual Basic) and Advanced Build Settings Dialog Box (C#).
Deployment
ClickOnce Deployment
ClickOnce deployment has been enhanced with the following new features:
* ClickOnce supports the deployment of WPF Web Browser Applications. WPF Web Browser Applications are hosted in a Web browser and therefore require special deployment and security settings. When you build and deploy these applications, Visual Studio will provide appropriate user interface and default values.
* ClickOnce gives ISVs the option to re-sign the application manifest with their customer's company name, application name, and deployment/support URL. When end users install the application, the ISV's original company branding still appears on the "Do you want to trust this application?" dialog box.
* You can build and deploy Visual Studio Tools for Office applications by using the Project Designer's Publish page or the Publish Wizard.
* ClickOnce supports manifest generation under User Account Control (UAC) on Windows Vista.
* ClickOnce supports the deployment of Office add-ins and documentation when you use Visual Studio Tools For Office. For more information, see the Visual Studio Tools for Office Developer Center Web site.
* ClickOnce has better support for third-party browsers. Earlier versions supported installation in third-party browsers by using plug-ins, which sometimes caused problems. In this version, a user can install a ClickOnce file directly by using the Run command.
* You can associate file name extensions with a ClickOnce application, so that the application can be started directly from the associated file type. For more information, see How to: Create File Associations For a ClickOnce Application.
* ClickOnce has better support for changing the deployment location of an application and handling certificate expiration. For more information about the ClickOnce security model, see ClickOnce Deployment and Authenticode.
* For security, ClickOnce applications are always installed and run on a per-user basis. An application that requests Administrator privileges from Windows Vista UAC fails gracefully during installation.
Windows Installer Deployment
Windows Installer deployment has been updated for Windows Vista and the latest .NET Framework versions:
* Windows Installer has been updated so that installation on Windows Vista is smooth, even when it is running under UAC.
* The .NET Framework Launch Condition supports targeting applications for the new .NET Framework 3.0 and 3.5 versions.
Editing
New Design View and CSS Design Tools
Visual Studio 2008 now has a rich CSS editing experience with several new tools to make working with cascading style sheets (CSS) easier than ever. Much of the work designing the layout and styling content can be done in Design view using the CSS Properties grid, the Apply Styles and Manage Styles panes, and the Direct Style Application tool. You can also change positioning, padding, and margins in Design view using WYSIWYG visual layout tools.
IntelliSense for Jscript and ASP.NET AJAX
IntelliSense has been significantly improved and now supports JScript authoring and ASP.NET AJAX scripting. Client script that is included in a Web page by using "" tags now has the benefit of IntelliSense, as do .js script files.
Additionally, IntelliSense displays XML code comments. XML code comments are used to describe the summary, parameter, and return details of the client script. ASP.NET AJAX also uses XML code comments to provide IntelliSense of ASP.NET AJAX types and members. IntelliSense is also supported for external script file references that use XML code comments.
Object Browser and Find Symbol Support for Multi-targeting
You now can specify that the Object Browser display only information for a single version of the .NET Framework or the .NET Compact Framework. In addition, Find Symbol, Find and Replace Window searches can be restricted to a single version of the .NET Framework or the .NET Compact Framework.
WPF Designer
The Windows Presentation Foundation (WPF) Designer lets you create WPF applications and custom controls in the IDE. The WPF Designer combines real-time editing of XAML with an enhanced graphical design-time experience. The following features are new for the WPF Designer:
* SplitView lets you adjust objects in the graphical designer and immediately view the changes to the underlying XAML code. Likewise, changes to the XAML code are immediately reflected in the graphical designer.
* The Document Outline window lets you view and move through your XAML with full selection synchronization between the designer, the document outline, the XAML editor, and the Properties window.
* IntelliSense in the XAML editor enables rapid code entry. IntelliSense now supports types that you have defined.
* Grid lines can be added to grids in the designer to enable easy grid-based control placement.
* Snap lines let you easily align controls and text.
* The designer now supports the loading of types you have defined. These include custom controls and user controls.
* You can cancel loading of large XAML files.
* Design-time extensibility supports design mode and property editors.
Data
* The Object Relational Designer (O/R Designer) assists developers in creating and editing the LINQ to SQL objects that map between an application and a database. The O/R Designer creates the DataContext, entity classes, and DataContext methods that are used by LINQ to SQL to communicate with the remote database and handle data that is used in your application. For more information, see O/R Designer Overview.
* N-Tier support for typed datasets provides enhancements to the Dataset Designer that assist in separating TableAdapter code and typed dataset code into discrete projects. For more information, see N-Tier Data Application Overview.
* Hierarchical update capabilities have been incorporated into the Dataset Designer to enable saving data in multiple related tables. A new TableAdapterManager object providing generated code that includes the save logic necessary for maintaining referential integrity has been added to typed datasets. Instead of calling the Update method for each TableAdapter, call the TableAdapterManager.UpdateAll method. For more information, see Hierarchical Update.
* Local database caching incorporates a SQL Server Compact 3.5 database and Microsoft Synchronization Services for ADO.NET into an application and prepares the application to periodically synchronize the data with a remote database on a server. Local database caching enables applications to reduce the number of round trips between the application and a database server. This can increase performance when you are working with data that changes infrequently or when applications are not always able to connect to the remote database. For more information, see Occasionally Connected Applications Overview.
* Microsoft SQL Server Compact 3.5 is a compact database that can be deployed on desktop computers, smart devices, and Tablet PCs. SQL Server Compact 3.5 is a local database that is easily incorporated into applications and is easily deployed. For more information, see Using SQL Server Compact 3.5 (Visual Studio).
Language-Integrated Query (LINQ)
Language-Integrated Query (LINQ) is a new set of features in Visual Studio 2008 that extend powerful query capabilities into the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and transforming data, and can be extended to support potentially any kind of data source. Visual Studio 2008 includes LINQ provider assemblies that enable language-integrated querying of .NET Framework collections (LINQ to Objects), SQL Databases (LINQ to SQL), ADO.NET Datasets (LINQ to ADO.NET), and XML documents (LINQ to XML).
The standard query operators are the methods that comprise the query capabilities in the LINQ pattern.
Enumerable
Queryable
Client Application Services
Client application services are new in the .NET Framework 3.5 and enable Windows-based applications (including Windows Forms and Windows Presentation Foundation applications) to easily access the ASP.NET login, roles, and profile services. These services let you authenticate users and retrieve user roles and application settings from a shared server.
You can enable client application services by specifying and configuring client service providers in the Visual Studio Project Designer or in your application configuration file. These providers plug into the Web extensibility model and let you access the Web services through existing .NET Framework login, roles, and settings APIs. Client application services also support occasional connectivity by storing and retrieving user information from a local data cache when the application is offline.
Reporting
Visual Studio 2008 provides several new reporting features and improvements.
New Report Projects
Visual Studio 2008 includes two new project templates for creating reporting applications. You will find the Reports Application template available on the New Project dialog box and the ASP.NET Reports Web Site template available on the New Web Site dialog box. When you create a new Reports Application project, Visual Studio provides a report (.rdlc) and a form (.vb/.cs) with a ReportViewer control bound to the report. For an ASP.NET Reports Web Site project, Visual Studio will create a Web site that contains a report (.rdlc), default ASP.NET page (.aspx) with a ReportViewer control bound to the report, and Web configuration file (.config).
When you create a report project, a new Report Wizard is started. You can then use the wizard to build the report, or alternatively, close the wizard and build the report manually.
Report Wizard
Visual Studio 2008 introduces a Report Wizard, which guides you through the steps to create a basic report. You will select a report data source, define a data set, select a report type (tabular or matrix), and apply a style to the report. After you complete the wizard, you can enhance the report by using Report Designer.
The Report Wizard is started automatically when you create a new Reports Application project or ASP.NET Reports Web Site.
Expression Editor Enhancement
The Expression Editor now provides sample expressions that you can use in report expressions. You can copy the sample expressions to your report to use as is or modify to suit your needs.
ReportViewer Printing
The RSClientPrint control is now available when the ASP.NET ReportViewer control is configured for local processing. This enables you to print reports that have been processed by the control and are independent of a report server.
PDF Compression
The ReportViewer controls will now compress reports that are rendered or exported to the PDF format when they are configured for local processing.
MSBuild
Target a Specific .NET Framework
MSBuild now lets you build projects for specific versions of the .NET Framework. Several new API functions support this new functionality. For more information, see Building for Specific .NET Frameworks.
Multiple Processor Capabilities
MSBuild now recognizes when a system is using multiple processors, either multicore processors or multiple separate processors. MSBuild uses all the available processors to reduce the overall build time for projects. For more information, see Using Multiple Processors to Build Projects.
Enhanced Logging
Build event logging has been upgraded to handle multi-processor builds. MSBuild now supports the distributed logging model in addition to the central logging model, and introduces a new technology known as "forwarding loggers." For more information, see Logging in MSBuild.
Item Definitions
The new ItemDefinitionGroup project file element lets you define a set of Item Definitions, which are global default metadata values that are applied to all items in the project. For more information, see Item Definitions.
Assembly Location and Name Changes
The file names and locations of the MSBuild assemblies have been updated for Visual Studio 2008. The following assemblies now have "v3.5" appended to their file names:
* Microsoft.Build.Conversion.v3.5.dll
* Microsoft.Build.Utilities.v3.5.dll
* Microsoft.Build.Tasks.v3.5.dll
In addition, the following build assemblies are now located in \Program Files\Reference Assemblies\Microsoft\Framework\v3.5\:
* Microsoft.Build.Conversion.v3.5.dll
* Microsoft.Build.Engine.dll
* Microsoft.Build.Framework.dll
* Microsoft.Build.Utilities.v3.5.dll
The Microsoft.Build.Tasks.v3.5.dll file is located in \Windows\Microsoft.NET\Framework\v3.5\.
Labels:
Visual Studio 2008
What is New In Visual Studio 2008 And .Net Framework 3.5 - Part 2
New in Visual Studio 2008 Service Pack 1 (SP1)
Smart Device Projects
Occasionally Connected Applications
Visual Studio provides tools to create occasionally connected smart device applications by using SQL Server Compact and Microsoft Synchronization Services for ADO.NET (Devices) version 1.0.
Power Packs Controls and Components
The Microsoft Visual Basic Power Packs 3.0 controls and components that were previously available for download are now included in Visual Studio 2008 SP1. Power Packs can be used in both Visual Basic and Visual C# Windows Forms Application projects.
Included in the Power Packs are a new DataRepeater control, and also updated versions of the previously released Line and Shape controls, the PrintForm component, and the Printer Compatibility Library.
DataRepeater Control
The new DataRepeater control lets you use standard Windows Forms controls to display rows of data in a scrollable container. This control provides more flexibility than standard grid controls.
Line and Shape Controls
The Line and Shape controls are a set of three graphical controls that let you draw lines, ovals, and rectangles on forms and containers at design time. These controls make it easier to enhance the look of your user interface. Line and Shape controls encapsulate many of the graphics methods that are contained in the System.Drawing namespace so that you can draw lines and shapes in a single step without having to create graphics objects, pens, and brushes. You can create complex graphics effects such as gradient fills by just setting some properties. These controls also provide events such as click and double-click to enable you to respond to and interact with end users.
PrintForm Component
The PrintForm component is designed so that you can easily print a Windows Form as you could in Visual Basic 6.0. By using the PrintForm component, you can once again lay out a Windows Form exactly how you want it and enable users to print the form as a quick report.
Printer Compatibility Library
The Printer Compatibility Library enables projects that use the Visual Basic 6.0 Printer object and Printers collection to be upgraded without requiring you to rewrite the printing logic. Just add a reference to the library, declare a Printer, and make some minor syntax changes, and the project will be able to print by using the Printers collection and Printer object as it did in Visual Basic 6.0. This version incorporates a new Write method into the Printer object. The new method lets you print text without using a forced carriage return, like the semicolon syntax used by the Print method in Visual Basic 6.0.
Distributing Power Packs
Also included is a bootstrapping package that lets you easily redistribute the Visual Basic Power Packs with an application. This lets you include the Power Packs in a ClickOnce Project or Setup Project by just clicking a check box.
.NET Framework Client Profile Support
Visual Studio 2008 SP1 supports the new .NET Framework Client Profile, a subset of the .NET Framework redistributable library that is optimized for client scenarios. These are some of the benefits of the Client Profile:
* A bootstrapper, which is just 200K, enables a fast response to the setup URL of an application.
* An integrated custom UI lets you package your application together with the Client Profile for a seamless installation experience.
* A small file size of 26.5MB helps to make installation fast.
ClickOnce Deployment
ClickOnce deployment includes the following features:
* Support for publishing unsigned manifests. For more information, see "Generating an Unsigned Manifest" in How to: Sign Application and Deployment Manifests.
* Enhancements to the Publish Options dialog box. These enhancements include support for configuring the following options:
o File Associations.
o Error URL, which specifies a Web site that is displayed in dialog boxes that are encountered during ClickOnce installations.
o Suite name, which specifies the name of the folder on the Start menu in which the application will be installed.
o Exclude Deployment Provider URL, which specifies whether to exclude the deployment provider URL from the deployment manifest.
Smart Device Projects
Occasionally Connected Applications
Visual Studio provides tools to create occasionally connected smart device applications by using SQL Server Compact and Microsoft Synchronization Services for ADO.NET (Devices) version 1.0.
Power Packs Controls and Components
The Microsoft Visual Basic Power Packs 3.0 controls and components that were previously available for download are now included in Visual Studio 2008 SP1. Power Packs can be used in both Visual Basic and Visual C# Windows Forms Application projects.
Included in the Power Packs are a new DataRepeater control, and also updated versions of the previously released Line and Shape controls, the PrintForm component, and the Printer Compatibility Library.
DataRepeater Control
The new DataRepeater control lets you use standard Windows Forms controls to display rows of data in a scrollable container. This control provides more flexibility than standard grid controls.
Line and Shape Controls
The Line and Shape controls are a set of three graphical controls that let you draw lines, ovals, and rectangles on forms and containers at design time. These controls make it easier to enhance the look of your user interface. Line and Shape controls encapsulate many of the graphics methods that are contained in the System.Drawing namespace so that you can draw lines and shapes in a single step without having to create graphics objects, pens, and brushes. You can create complex graphics effects such as gradient fills by just setting some properties. These controls also provide events such as click and double-click to enable you to respond to and interact with end users.
PrintForm Component
The PrintForm component is designed so that you can easily print a Windows Form as you could in Visual Basic 6.0. By using the PrintForm component, you can once again lay out a Windows Form exactly how you want it and enable users to print the form as a quick report.
Printer Compatibility Library
The Printer Compatibility Library enables projects that use the Visual Basic 6.0 Printer object and Printers collection to be upgraded without requiring you to rewrite the printing logic. Just add a reference to the library, declare a Printer, and make some minor syntax changes, and the project will be able to print by using the Printers collection and Printer object as it did in Visual Basic 6.0. This version incorporates a new Write method into the Printer object. The new method lets you print text without using a forced carriage return, like the semicolon syntax used by the Print method in Visual Basic 6.0.
Distributing Power Packs
Also included is a bootstrapping package that lets you easily redistribute the Visual Basic Power Packs with an application. This lets you include the Power Packs in a ClickOnce Project or Setup Project by just clicking a check box.
.NET Framework Client Profile Support
Visual Studio 2008 SP1 supports the new .NET Framework Client Profile, a subset of the .NET Framework redistributable library that is optimized for client scenarios. These are some of the benefits of the Client Profile:
* A bootstrapper, which is just 200K, enables a fast response to the setup URL of an application.
* An integrated custom UI lets you package your application together with the Client Profile for a seamless installation experience.
* A small file size of 26.5MB helps to make installation fast.
ClickOnce Deployment
ClickOnce deployment includes the following features:
* Support for publishing unsigned manifests. For more information, see "Generating an Unsigned Manifest" in How to: Sign Application and Deployment Manifests.
* Enhancements to the Publish Options dialog box. These enhancements include support for configuring the following options:
o File Associations.
o Error URL, which specifies a Web site that is displayed in dialog boxes that are encountered during ClickOnce installations.
o Suite name, which specifies the name of the folder on the Start menu in which the application will be installed.
o Exclude Deployment Provider URL, which specifies whether to exclude the deployment provider URL from the deployment manifest.
Labels:
Visual Studio 2008
What is New In Visual Studio 2008 And .Net Framework 3.5 - Part 1
New in Visual Studio 2008 SP1
* Smart Device Projects
o Occasionally Connected Applications
* Power Packs Controls and Components
* DataRepeater Control
* Line and Shape Controls
* PrintForm Component
* Printer Compatibility Library
* Distributing Power Packs
* .NET Framework Client Profile Support
New in Visual Studio 2008 Original Release Version
* Integrated Development Environment (IDE)
o Settings Migration
o Community Components
o Community and Help Menus
o Window Management
o Class Designer
* Projects and Solutions
o Web Application Projects
o AJAX Development
o Project Designer
o Deployment
* Editing
o New Design View and CSS Design Tools
o IntelliSense for Jscript and ASP.NET AJAX
o Object Browser and Find Symbol Support for Multi-targeting
o WPF Designer
* Data
* Language-Integrated Query (LINQ)
* Client Application Services
* Reporting
o New Report Projects
o Report Wizard
o Expression Editor Enhancement
o ReportViewer Printing
o PDF Compression
* MSBuild
o Target a Specific .NET Framework
o Multiple Processor Capabilities
o Enhanced Logging
o Item Definitions
o Assembly Location and Name Changes
* Smart Device Projects
o Occasionally Connected Applications
* Power Packs Controls and Components
* DataRepeater Control
* Line and Shape Controls
* PrintForm Component
* Printer Compatibility Library
* Distributing Power Packs
* .NET Framework Client Profile Support
New in Visual Studio 2008 Original Release Version
* Integrated Development Environment (IDE)
o Settings Migration
o Community Components
o Community and Help Menus
o Window Management
o Class Designer
* Projects and Solutions
o Web Application Projects
o AJAX Development
o Project Designer
o Deployment
* Editing
o New Design View and CSS Design Tools
o IntelliSense for Jscript and ASP.NET AJAX
o Object Browser and Find Symbol Support for Multi-targeting
o WPF Designer
* Data
* Language-Integrated Query (LINQ)
* Client Application Services
* Reporting
o New Report Projects
o Report Wizard
o Expression Editor Enhancement
o ReportViewer Printing
o PDF Compression
* MSBuild
o Target a Specific .NET Framework
o Multiple Processor Capabilities
o Enhanced Logging
o Item Definitions
o Assembly Location and Name Changes
Labels:
Visual Studio 2008
Friday, January 9, 2009
Update for .NET 3.5 SP1 Released
First you can search for KB959209 in the Microsoft knowledge base for details on this update. Here is the URL for the article: http://support.microsoft.com/kb/959209.
This update addresses following issues that may affect an ASP.NET developer that has .NET 3.5 SP1 installed:
- Dynamic Data used with Entity Framework generates an error when navigating one to one relationships
- BrowserCaps generates an error if Front Page Server extensions are installed.
- Using a derived UpdateProgress control may encounter an exception.
- An exception is thrown if the website is using WPF to generate images and the site is hosted under IIS.
This update addresses following issues that may affect an ASP.NET developer that has .NET 3.5 SP1 installed:
- Dynamic Data used with Entity Framework generates an error when navigating one to one relationships
- BrowserCaps generates an error if Front Page Server extensions are installed.
- Using a derived UpdateProgress control may encounter an exception.
- An exception is thrown if the website is using WPF to generate images and the site is hosted under IIS.
Labels:
.Net 3.5 SP1,
Asp.net
Thursday, January 1, 2009
Globally trap unhandeld exceptions using VB.Net and Winforms
Don't worry if your windows application don't have any exception block. Using Application.vb or Application.ThreadException we can trap unhandeled exceptions in our application. There are two ways we can accomplish this Job.
1. Using Application.vb file : If your application does not starts with Main function, then we can use Application.Vb file and catch the unhandeled exceptions.
2. Write code in Sub Main : If you have Sub Main() function in the application. we can not create Application.Vb file. That time kindly follow the following steps to catch the unhandled exception.
Following are the steps those will help us to trap exceptions.
i) Create the handeler in the Sub main Method
Public Sub Main()
'To Call any Unhandled Exception thrown by Current Application Thread
AddHandler Application.ThreadException, AddressOf Application_ThreadException
'Write other code here
End Sub
Once we create declare the above handler, any handeled exception generated in the current thread will call the "Application_ThreadException" function.
ii). Create the Application_ThreadException function and catch the exception.
'Application_ThreadException will be called if Unhandled Exception thrown by Current Application Thread
Private Sub Application_ThreadException(ByVal sender As Object, ByVal e As Threading.ThreadExceptionEventArgs)
If (e.Exception.GetType().Name.ToUpper = "OUTOFMEMORYEXCEPTION") Then
GC.Collect()
End If
' Supress Certain types of errors only , else dispaly the error message
If (e.Exception.GetType().Name.ToUpper <> "OUTOFMEMORYEXCEPTION" _
And e.Exception.GetType().Name.ToUpper <> "OBJECTDISPOSEDEXCEPTION") Then
Dim result As DialogResult = DialogResult.Cancel
Try
result = ShowThreadExceptionDialog(e.Exception)
Catch
Try
MessageBox.Show("Fatal Error", _
"Fatal Error", _
MessageBoxButtons.AbortRetryIgnore, _
MessageBoxIcon.Stop)
Finally
Application.Exit()
End Try
End Try
If (result = DialogResult.Abort) Then
Application.Exit()
End If
End If
End Sub
Private Function ShowThreadExceptionDialog(ByVal e As Exception) As DialogResult
Dim stack As New StackTrace(e, True)
Dim result = stack.ToString()
Dim errorMsg As String = " Unhandled Exception :" & e.Message & vbCrLf & vbCrLf
errorMsg &= vbCrLf & vbCrLf & "Stack Trace:" & _
vbCrLf & result
Return MessageBox.Show(errorMsg, _
Application.ProductName, _
MessageBoxButtons.AbortRetryIgnore, _
MessageBoxIcon.Stop)
End Function
Happy Coding..
1. Using Application.vb file : If your application does not starts with Main function, then we can use Application.Vb file and catch the unhandeled exceptions.
2. Write code in Sub Main : If you have Sub Main() function in the application. we can not create Application.Vb file. That time kindly follow the following steps to catch the unhandled exception.
Following are the steps those will help us to trap exceptions.
i) Create the handeler in the Sub main Method
Public Sub Main()
'To Call any Unhandled Exception thrown by Current Application Thread
AddHandler Application.ThreadException, AddressOf Application_ThreadException
'Write other code here
End Sub
Once we create declare the above handler, any handeled exception generated in the current thread will call the "Application_ThreadException" function.
ii). Create the Application_ThreadException function and catch the exception.
'Application_ThreadException will be called if Unhandled Exception thrown by Current Application Thread
Private Sub Application_ThreadException(ByVal sender As Object, ByVal e As Threading.ThreadExceptionEventArgs)
If (e.Exception.GetType().Name.ToUpper = "OUTOFMEMORYEXCEPTION") Then
GC.Collect()
End If
' Supress Certain types of errors only , else dispaly the error message
If (e.Exception.GetType().Name.ToUpper <> "OUTOFMEMORYEXCEPTION" _
And e.Exception.GetType().Name.ToUpper <> "OBJECTDISPOSEDEXCEPTION") Then
Dim result As DialogResult = DialogResult.Cancel
Try
result = ShowThreadExceptionDialog(e.Exception)
Catch
Try
MessageBox.Show("Fatal Error", _
"Fatal Error", _
MessageBoxButtons.AbortRetryIgnore, _
MessageBoxIcon.Stop)
Finally
Application.Exit()
End Try
End Try
If (result = DialogResult.Abort) Then
Application.Exit()
End If
End If
End Sub
Private Function ShowThreadExceptionDialog(ByVal e As Exception) As DialogResult
Dim stack As New StackTrace(e, True)
Dim result = stack.ToString()
Dim errorMsg As String = " Unhandled Exception :" & e.Message & vbCrLf & vbCrLf
errorMsg &= vbCrLf & vbCrLf & "Stack Trace:" & _
vbCrLf & result
Return MessageBox.Show(errorMsg, _
Application.ProductName, _
MessageBoxButtons.AbortRetryIgnore, _
MessageBoxIcon.Stop)
End Function
Happy Coding..
Subscribe to:
Posts (Atom)