June 2005 - Posts

Using Non-Default Database to Store ASP.NET 2.0 Application Settings

In beta1 of ASP.NET 2.0 there were two providers available to access application management data database. MS Access provider was default one. Access mdb file was created on demand and stored in Data application folder. In beta2 things were changed. Now we have only one AspNetSqlProvider. Personally I love single radio button configuration touch in ASP.NET website configuration tool :-) :
   
Still, default application configuration database behaves pretty much the same way. SQLEXPRESS database file is created by demand in App_Data folder. It is not best solution for all deployment scenarios.
I have been asked couple of times lately how to setup ASP.NET 2.0 application to store settings in non-default database. Let's say we want to use centralized MS-SQL server instead of CQLEXPRESS files in App_Data directory for each application. With beta2 we can easily achieve this. Management database connection string is defined by "LocalSqlServer" entry in connectionStrings section of config file. We can add following section to Web.config to access database of our choice:

<connectionStrings>
   <
remove name="LocalSqlServer"/>
   <
add name="LocalSqlServer" 
             connectionString="Data Source=SqlServerName;Initial Catalog=aspnetdb;Integrated Security=True" 
             providerName="System.Data.SqlClient"/>
</
connectionStrings>

Note: You can use aspnet_regsql GUI driven utility to setup new or configure existing configuration database. This simple utility installed with .NET 2.0 SDK and can be accessed from Visual Studio 2005 Command Prompt.

ASP.NET 2.0 Deployment Without Source Code

I was asked couple of times recently about deployment of ASP.NET 2.0 application without source code.
New compilation model of ASP.NET allow immediate application update, including changes in codebehind files (ASP like “JUST SAVE” behavior). You are no longer required to compile Web Application before accessing it. It is very convenient behavior for development and even testing environment, but what about production? We, usually, do not want to upload source code to production server to be JIT compiled. It is not so good for intellectual property protection and allows dangerous accidentally code altering.


In VS2005 we have a lot of options to deploy Web Site:

  1. xcopy deployment
  2. Copy Web Site Wizard - provide nice GUI for copying/synchronization of files to/from destination server
  3. Web Setup Project
  4. Publish Web Site Wizard
  5. aspnet_compiler SDK utility

You can not use first two options to copy application without sources because normally compiled assembly stored in ASP.NET Temporary directory and not under application root. Only last two options will allow you to deploy precompiled Web without source code.

Notes:
Web Setup Project
• In beta2 this option was moved from Website to Build menu.
• It is not present in Web Express edition.
• Uncheck “Allow this precompiled site to be updateable“ option to remove markup from aspx files
aspnet_compiler
• You can only compile Web Site or compile and deploy it in single step
• Can not deploy to remote computer. You will have to deploy locally and copy output to remote server.

CTP Madness and compatibility

If you are playing around with new stuff and going to loose your mind trying to find compatible builds of Yukon, Avalon, Team System etc. Here you can find a cure. I advise you to visit it, even before you starting to download. Brad Adams, Jason Sutherland thank you guys.

Visual Studio 2005 Team System Suite June CTP

Visual Studio 2005 Team System Suite June CTP along with Team Foundation Server and VS Professional  is available now for MSDN Subscribers. Couple of important points about this build:

  1. It supports double server installation mode only
  2. It doesn't support Go-Live License
  3. It has improved documentation, a lot of bugs are fixed
  4. It suppose to be less stable than beta2

Read more from Rob Caron's post.

Team System SCC Provider for VB6, VC6 and Everett

Microsoft announced at TechEd that they will write a SCC provider to allow VB6, VC6 an Visual Studio 2003 (Everett) access Hatteras (Team Foundation Version Control). I think it is a great thing for organizations that can not move all their development platforms overnight to VS2005. You will be surprised to find out how many ongoing VB6 projects I know.

Way to go! And don't disappoint me on this, I am waiting for it.

 

Microsoft Web Services Benchmarks for.NET 2.0

Microsoft has released a new version of the Web Service and XML benchmark tests originally developed by Sun. The new version implemented using .NET 2.0 Beta 2 and show a nice improvement in performance both of Web Service Requests processing and XML manipulation.

Unable to Update Default User Database from ASP.NET 2.0 site, published to IIS

In VS2005 beta2/MS-SQL EXPRESS if you are publishing your site to IIS virtual directory, attempt to access default user database (App_Data\aspnetdb.mdf) will fail. You will likely receive error message similar to this:

Failed to update database "D:\WebSites\ASPNET20CC\App_Data\ASPNETDB.MDF" because the database is read-only.

To reproduce the problem:
  1. Create simple web site with LoginControl and CreateUserWizard
  2. Publish site to IIS
  3. Browse login page from IIS virtual directory instead of Casiny
  4. Try to create new user or login with existing one
To fix the problem:
  1. Detach aspnetdb database from SQLEXPRESS using sseutil.exe utility.
  2. Remove *.mdf and *.ldf files from App_Data application directory
  3. Grant Read/Write access on App_Data to working process identity (ASPNET for IIS5.X or NETWORK SERVICE for IIS6)
  4. Copy *.mdf, *.ldf files back into App_Data folder
  5. Run application, refresh if any connection related error received

This bug is announced and fixed in later build of SSE. You can see full description here.

C# 1.0 Conformance in VS2005

Just found out new feature of Visual Studio 2005 (thanks to tip of Juval Lowy at TechEd lecture): you can ask compiler to check and compile code for 1.0 version of C#. You will receive errors for using new (C# 2.0) features.

To use it just go to the Project Properties>Build>Advanced and select ISO-1 in Language Versio combo. Notice that compiled assembly references will be resolve to version 2.0.

In conjunction with MSBuild Toolkit it gave nice solution for legacy applications support.

Free Microsoft E-Learning Courses

Microsoft just announced 17 Visual Studio 2005 and Sql Server 2005 courses free for public access. Enjoy!

Writing a blog ...

Sometimes it's exactly this filing... :)
Hopefully only sometimes

Visual Studio 2005 Launch Date

Finally!
Lunch date for SQL Server™ 2005, Visual Studio® 2005 and BizTalk® Server 2006 is announced. All these products will be formally launched during the week of Nov. 7. Read press release.

MSBuild Toolkit for Visual Studio 2005 RC Announced

If you are looking for possibility to use Class Designer, Code Snippets, Refactoring and other cool features of VS2005 and still be able to compile your application for .NET 1.1 platform, MSBuild Toolkit is a great news for you. It is major upgrade of Compatibility Toolkit, released last year. Thanks Robert McLaws.

ASP.NET 2.0 Beta2 Compilation Model

Apparently compilation model of ASP.NET 2.0 was changed in beta2. If you take a look now at “...\Temporary ASP.NET files\Application Name\x\y\”, you can find out that first hit on any page in application trigger compilation of 3 assemblies:

  1. App_global.asax.<xyz>.dll - if Global asax exists in application
  2. App_Code_<xyz>.dll - if App_Code folder exists and contains al teast one source file
  3. App_Web_<xyz>.dll - wich contains all webforms' classes
If you add new page to existing application, first hit on it will create additional App_Web_<hlm>.dll.
App_Web_... assemblies reference global ones.

This model is different from widely discribed assembly-per-page model. IMHO it is simpler. Keap in mind possible implication of this model (type reference, reflection GetType implications etc.)