When you debug ASP.NET applications in IIS using Debug -> Attach To Process… and you keep the w3wp.exe process hanged on a code line for too long, it is automatically recycled and you lose your debugging session. To avoid that, go to the IIS Management Console, edit the application pool properties and set Ping Enabled = false.
Monday, July 28, 2008
Friday, July 04, 2008
ASP.NET projects deployed with Web Deployment Project 2005 do not load localized resources
Scott Guthrie explains how to use VS 2005 Web Deployment Project in his blog. But if you use global resources to localize your ASP.NET application and sign and version your web deployment assembly, these localized resources will not load. If you look at the fusion log, you will find an entry like follows:
Calling assembly : Memba.WebSite.XP, Version=1.1.0.0, Culture=neutral, PublicKeyToken=a4ae091aa8097a5a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\VelodocXP\web.config.
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Memba.WebSite.XP.resources, Version=0.0.0.0, Culture=fr, PublicKeyToken=a4ae091aa8097a5a
LOG: The same bind was seen before, and was failed with hr = 0x80131040.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80131040).
The problem comes from the fact that aspnet_merge.exe versions your satellite resource assemblies as "0.0.0.0" whatever the version number you set for your web deployment strong named assembly.
I have not found any way to version satellite assemblies according to the main assembly, but the following workaround works:
- Create an AssemblyInfo.cs class file in your App_Code directory;
- Include the typical information including versioning information;
- Add [assembly: System.Resources.SatelliteContractVersion ("0.0.0.0")]
Monday, April 21, 2008
Error 1316 when installing Office 2007 PIA’s
If you build a setup for an Office 2007 VSTO add-in following the steps described in Deploying Visual Studio 2005 Tools for Office Second Edition Solutions Using Windows Installer, your setup may report that the installation of the Office 2007 PIA's have failed. Looking at the log or installing o2007PIA.msi separately, you will get "Error 1316. Setup cannot read from file <tempdir>\PIARedist.msi. Check your connection to the network, or CD-ROM drive. For other potential solutions to this problem, see SETUP.CHM".
This occurs on fresh installs of Office 2007 with Microsoft Business Contact Manager and more generally, it seems to occur on any computer which has the Office 2007 PIA's installed using another installer than o2007pia.msi, which is the one Microsoft recommends using.
There seems to be a workaround which is to rename o2007pia.msi into PIARedist.msi both in the file system where bootstrapper packages are stored and in the product.xml file as shown below:
<PackageFiles>
<PackageFile Name="PIARedist.msi"/>
<PackageFile Name="ComponentCheck.exe"/>
</PackageFiles>
...
<Command PackageFile="PIARedist.msi"
Arguments=""
EstimatedInstalledBytes="30000000"
EstimatedInstallSeconds="60">
You will need to rebuild your setup project.
Please let me know if this workaround does not work for you.
Monday, March 31, 2008
Validating email notification HTML for Outlook 2007
Velodoc issues numerous email notifications. The presentation uses the latest CSS tags and sophisticated layered HTML. Everything worked fine in Outlook 2003 which uses Internet Explorer as the HTML rendering engine. Outlook 2007 and its Word 2007 rendering engine broke many little things.
Although it is definitely a step back in terms of HTML rendering capability for emails, everything is explained in Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007. The article comes with a very handy tool to validate HTML and CSS in your development environment.
I have not been able to install the tool for Visual Studio 2005 SP1 on Windows Vista Ultimate x64 because I could not instantly find the registry keys described in the setup instructions, but it works perfectly with Dreamweaver 8 provided you replace "Dreamweaver MX 2004" by "Dreamweaver 8" in the default installation path.
FileNotFoundException in Visual Studio Setup Project
The Velodoc XP setup project would consistently fail on a specific Windows Server 2003 server of ours but not on other computers of our network. The complete issue is described at http://www.codeplex.com/VelodocXP/WorkItem/View.aspx?WorkItemId=1005. The error message was:
Exception occurred while initializing the installation: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\WINDOWS\system32\and' or one of its dependencies. The system cannot find the file specified.
Obviously, there is no such "C:\WINDOWS\system32\and" file in our application or on the system. MSI logs and fusion logs would not give any more information.
We have been puzzled by this issue for quite some time. We have finally removed features from our setup one by one until we have been able to identify that a specific custom action was at the source of the problem.
In the literature and samples that you will find regarding developing Visual Studio setup projects, custom action data is passed in the form /NAME = VALUE which works fine unless value contains a space.
The reference documentation at http://msdn2.microsoft.com/en-us/library/2w2fhwzz.aspx states that in setup custom actions, data should be passed as:
/NAME = VALUE if not a directory and value has no space
/NAME = "VALUE" if spaces are expected in a value which is not a directory
/NAME = "VALUE\" if the expected value is a directory
I wish we had not simply read how-to articles and sample code, but also the reference documentation.
Monday, March 17, 2008
Installing Visual Studio Extensions for WCF after an upgrade to .NET 3.0 Service Pack 1
Yesterday, I got stuck installing Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP after my computer had been upgraded to .NET Framework 3.0 Service Pack 1. The installation fails with a warning that a prerequisite, i.e. Microsoft .NET framework 3.0, is missing.
A quick search on the Internet gave me the following trick which works:
- Add the following key and value to the registry aimed at luring the installer:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{15095BF3-A3D7-4DDF-B193-3A496881E003}]
"DisplayName"="Microsoft .NET Framework 3.0" - Install vsextwfx.msi.
- Remove the key above.
Source: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2550726&SiteID=1.
Thanks Erich.
Wednesday, January 31, 2007
Functional and load testing of ASP.NET Ajax applications – part I
Introduction
Velodoc is developed in ASP.NET C# 2.0 with Visual Studio .NET 2005.
VSTS comes with unit testing, web testing and load testing, considering load testing is actually an execution environment for unit tests and web tests.
Unfortunately Visual Studio web tests work at the protocol level, recording HTTP traffic in order to replay it. The same applies to Redgate’s ANTSLoad and many other load testing tools. Velodoc is an Ajax application and this does not work.
We have started our search for a solution from the following lists of testing tools:
- http://www.aptest.com/webresources.html
- http://www.softwareqatest.com/qatweb1.html
- http://www.testdriven.com/modules/mylinks/viewcat.php?cid=21&orderby=titleA&PHPSESSID=9f0501e81e532817372ad86a3dec5395
Obviously there are tools like Mercury Winrunner/Loadrunner and the IBM Rational equivalents which certainly cope but they are too expensive.
Our requirements are the following:
- Test ASP.NET applications
- Works on Windows XP with IE
- Compatible with NetAdvantage controls, iFrames, file uploads and Ajax
- Scripts IE including IE dialogs to drive functional UI tests
- Several instances can be executed concurrently to create load/stress tests
- Uses a familiar technology (low learning curve)
- Open source is a plus and a requirement if the supplier has not been around for a long time.
There are three types of solutions which cope more or less with these requirements:
- Macro recorders/players
- Test environments
- Web application scripting frameworks
Macro recorders/players and test environments
Searching on Tucows, Download.com and other shareware web sites reveals loads of macro recorders. Most of them hook the message pump and replay the windows messages. Obviously, the result is not good. We have tried a dozen of them but only iOpus iMacros 5.2 could do a decent job at automating a file upload from https://www.velodoc.net/. The code is reproduced below:
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=https://www.velodoc.net
SIZE X=876 Y=627
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID: SenderTextBox CONTENT=test1@acme.com
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID: RecipientTextBox CONTENT=test2@acme.com
TAG POS=1 TYPE=TEXTAREA FORM=NAME:aspnetForm ATTR=ID: MessageTextBox CONTENT= Test<SP>with<SP>iMacro
FRAME F=1
WINCLICK X=100 Y=429 CONTENT=
WINCLICK X=100 Y=429 CONTENT=C:\test.bin
FRAME F=0
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:aspnetForm ATTR=ID: SendTermsCheckBox&&VALUE:on CONTENT=YES
WINCLICK X=490 Y=513 CONTENT=
I see at least three drawbacks to using iOpus iMacros as a functional test tool:
- The lack of assertions and reporting capabilities makes it insufficient for functional testing;
- The lack of infrastructure makes it insufficient for load testing;
- The proprietary language reduces the possibilities despite the fact that it can call external scripts or be called via a COM component.
I have also tried several test environments mentioned in the above lists. Generally, recording the file upload test on https://www.velodoc.net/ has always proved difficult but I cannot tell whether it was feasible or not for some of them. I have limited myself to 2 hours per evaluation and the inherent complexity and learning curve was not worth digging passed first impression.
Web application scripting frameworks
I have looked at two open-source frameworks, which both script IE to execute functional tests on the web application:
Both frameworks are very easy to start with due to a familiar language and an intuitive API. Additionally both frameworks provide the necessary assertions to report on the success or failure of a test fixture.
Scripting a file upload on the Velodoc home page with IEUnit entails the following JavaScript code:
_.openWindow(https://www.velodoc.net);
_.setField("SenderTextBox", test1@acme.com);
_.setField("RecipientTextBox", test2@acme.com);
_.setTextArea("MessageTextBox", "Test with IEUnit");
var fname = "C:\\test.bin";
var cmdShell = new ActiveXObject("WScript.Shell");
cmdShell.Run("C:\\EnterFileName.sbk " + fname, 0, false);
_.setFrame(0);
_.clickObjById("FileInput");
_.setFrame(-1);
_.setCheckBox("SendTermsCheckBox",true);
_.clickObjById("SendWebImageButton");
Where EnterFileName.sbk contains:
var fpath = " " + WScript.Arguments(1);
var popupWin = _.waitForWindow("Choose file", 30000);
_.setFrame(0);
_.findWindow(popupWin, "Edit").sendText(fpath);
_.findWinButton(popupWin, "&Open").click();
Scripting a file upload on the Velodoc home page with WatiN entails the following C# code:
using (IE ie = new IE(https://www.velodoc.net/))
{
ie.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
ie.TextField(Find.ById("SenderTextBox")).TypeText("test1@acme.com");
ie.TextField(Find.ById("RecipientTextBox")).TypeText("test2@acme.com");
ie.TextField(Find.ById("MessageTextBox")).TypeText("Test with WatiN");
Frame f = ie.Frame(Find.ById("FileUploadFrame"));
FileUpload fUp = f.FileUpload(Find.ById("FileInput"));
fUp.Set("C:\\test.bin");
ie.CheckBox(Find.ById("SendTermsCheckBox")).Checked = true;
//ie.TextField(Find.ById("SenderTextBox")).FireEvent("onKeyUp");
ie.Button(Find.ById("SendWebImageButton")).ClickNoWait();
SimpleTimer t = new SimpleTimer(60 * 60);
Span s;
do
{
s = ie.Span(Find.ById("DownloadLinkLabel"));
if (!String.IsNullOrEmpty(s.Text))
goto EXIT;
System.Threading.Thread.Sleep(1000);
} while (!t.Elapsed);
throw new WatiN.Core.Exceptions.TimeoutException("...", 60 * 60));
EXIT:
Assert.AreEqual(true, s.Text.Contains(https://www.velodoc.net/));
}
Conclusion
The beauty of WatiN is that it builds on top of C# and .NET framework. Accordingly you get not only a rich language but also a rich environment. Test code built with WatiN can be executed within NUnit and Visual Studio unit testing projects which means that they can also be executed for load tests which I am going to try next although we know already that launching several instances of IE has its own limitation.
Tuesday, January 16, 2007
SGen XmlSerializers
My VS2005 C# web project was perfectly working in my development environment but I got the following error after deploying in a production environment:
Configuration Error
Parser Error Message: Cannot deserialize [C:\data.xml].
Using the fusion log viewer (FUSLOGVW.EXE) reveals a binding exception to Assembly.XmlSerializers.dll, where Assembly is the name of the assembly which contains the classes serialized in data.xml.
My ASP.NET application runs as a dedicated application pool under the credentials of a windows user which has very limited rights. The problem is related to the user rights which prevent the ASP.NET process from automatically generating XmlSerializers.
Visual Studio cannot generate XmlSerializers
On the build tab of your VS project properties, there is an option called “Generate Serialization Assemblies” which you can set to “On”.
If you look at MSBuild commands in the output window, doing so actually adds a command line which looks like the following:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\sgen.exe /assembly:"Assembly.dll" /proxytypes /reference:"reference1.dll" … /reference:"referenceN.dll" /compiler:/keycontainer:VS_KEY_5EFB7881D71082EDCF85DBBFCD748B9A /compiler:/delaysign-
Note the /proxytypes option which actually prevents SGen from generating your XmlSerializers as specified in the documentation for the XML Serializer Generator Tool (Sgen.exe).
Use SGen as a post-build event
As a consequence you need to add the SGen command as a custom post-build event on the Build Events tab of your VS project properties:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sgen.exe" /force /assembly:"$(TargetPath)" /compiler:/keycontainer:VS_KEY_5EFB7881D71082EDCF85DBBFCD748B9A /compiler:/delaysign-
Other interesting links
Thursday, December 21, 2006
Diagnosing "aspnet_merge.exe exited with code 1” error in Web Deployment Projects
For those that have problems with Error 24 "aspnet_merge.exe" exited with code 1.
The error is related to a duplicate class name in your web project, i.e. two files which have the same name, generally in different directories.
Those files could be hard to find and the following is a quick way to isolate the problem and find the duplicate names.
In Visual Studio 2005:
- Select Tools --> Options.
- Then in the Projects and Solutions branch, select Build and Run.
- You'll see a dropdown box for MSBuild Project Build Output Verbosity. Change this to Diagnostic, and OK.
- Show your build output by selecting the View --> Output option.
- Make sure that in the 'Show output from' box, you've selected "Build".
- Then just build your project, and wait for the inevitable fail. You will see where the duplicates are when it fails to build.
This tip has been posted by Simon Morgan on http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx.
Friday, October 13, 2006
SourceSafe 2005 issue fixed
I periodically run the following script to launch the Analyze tool on SourceSafe databases:
Dim shell
Set shell = CreateObject("WScript.Shell")
Dim sVssAnalyzeCmd
Dim sVssAnalyzeExe
sVssAnalyzeExe = chr(34) & "C:\Program Files\Microsoft Visual SourceSafe\analyze.exe" & chr(34) & " -F -V3 -D "
'----------> First Project
sVssAnalyzeCmd = sVssAnalyzeExe & chr(34) & "d:\vss2005\project1\data" & chr(34)
shell.Run sVssAnalyzeCmd, 7, true
One day, Analyze was reporting the following error:
The file 0\DATA\\ is not a valid SourceSafe physical database file. It must be renamed to a file with an extension or moved to another directory outside the database.
I found a curious fix on the web: to work around this problem, rename the physical file for the database root. Use all uppercase letters in the new name.
I renamed d:\vss2005\project1\data\a\aaaaaaaa into d:\vss2005\project1\data\a\AAAAAAAA and it worked.
I am glad to realize that a fix has recently been made available by Microsoft at:
http://support.microsoft.com/kb/923842/en-us