Friday, December 22, 2006

Touchy connection strings

My ASP.NET 2.0 / SQL Server 2005 application was working perfectly in my development environment but I experienced the following error message when testing deployment in a Windows 2003 virtual machine:

"A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)".

My connection string was:

Server=localhost;Database=myDB;Integrated Security=SSPI;

Simply changing it to the following solved the issue:

Data Source=.;Initial Catalog=myDB;Integrated Security=True;

Considering both shared memory and TCP/IP where enabled in both environments, I can neither explain why the issue occurred or why the change above solved it. If someone can, please leave a comment.

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.

Tuesday, December 19, 2006

New incompatibility between ASP.NET Ajax 1.0 RC and Google AdSense

Run the following ASP.NET page in IE7 and you will get a Javascript error:

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server" >
<Scripts>
<asp:ScriptReference Name="PreviewScript.js" Assembly="Microsoft.Web.Preview" />
</Scripts>
</asp:ScriptManager>
<div>
<script type="text/javascript"><!--
google_ad_client = "pub-6623312146541354";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text";
google_ad_channel = "";
google_color_border = "000000";
google_color_bg = "F0F0F0";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</form>
</body>
</html>

ASP.NET Ajax page method on login page requires setting location in web.config

I have spent quite a while on this one, so I deliver my findings here hoping that it will help.

If you have an ASP.NET web site with forms authentication and your login page has an ASP.NET Ajax extensions page method, this method will not work unless you set:

<location path="login.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>


Otherwise, the call to ~/login.aspx/yourScriptMethod fails because it is not authenticated.

Thursday, December 14, 2006

“debugger”, the magic JavaScript statement

This post is dedicated to all the Javascript programmers who still use alerts to debug their code.

Not sure about you, but I have always struggled to set and enable Visual Studio breakpoints to debug my Javascript code until I have found about a magic statement named debugger.

To use it:
  1. Make sure “Disable Script Debugging” is unchecked in Internet Explorer, Tools (menu) -> Internet Options… (submenu) -> Advanced (tab) -> Browsing (node).
  2. Put the debugger; statement anywhere in your code where you want the breakpoint.
  3. Execute your web application and when the browser script engine interprets the statement, it launches the debugger and breaks on the statement line.