Developer's Closet A place where I can put my PHP, SQL, Perl, JavaScript, and VBScript code.

6Mar/130
Format XML in Visual Studio

I often end up with badly formatted XML files that display as one long line in Visual Studio.

To format XML to a look more friendly, click Ctrl + K, then  Ctrl + D.

This will properly format the XML. No search/replace of newline characters is necessary anymore!

 

6Nov/120
MVC Web Application Error: ‘LocalSqlServer’ was not found

I created a new MVC Web Application and added a new Windows Azure Cloud Service project to the solution. The project was able to build successfully, and the Cloud project tested successfully, but when I tested the web app, I received the following error: Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty. Here is the entire message:

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.

Source Error:

Line 248:		<membership>
Line 249:			<providers>
Line 250: <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> Line 251:				<add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 252:			</providers>

Source File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config Line: 250

I've dealt with missing connection strings before, but this was different, I had no database or other connections to worry about. I removed the offending providers from the machine.config file, but I received the same error. The web.config was no help - it was too basic to have caused this error. Luckily, after about an hour, I stumbled across a great article that fixed the problem. Here is the fix, add this to your web.config under appSettings:

<add key="enableSimpleMembership" value="false"/> 

It seems this WebMatrix Simple Membership is enabled by default. I then found an article from Microsoft that describes this further. I'll look into this later, but what a relief to have that problem solved.

1Nov/120
Build a Web Setup Project using devenv to Create an MSI
I was disappointed when I learned that you still could not build a Web Setup Project vdproj file using MSBuild. However, you can still use devenv.exe on the commandline to build a project and create an MSI file (try devenv /? for more details). Remember to pass the solution file to devenv first, followed by the vdproj file:
@Echo Off
cd "c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
REM Build web setup MSI to Debug
devenv "C:\Dev\MvcWebApplication1\MvcWebApplication1.sln" /build Debug /project "C:\Dev\MvcWebApplication1\MvcWebSetup1\MvcWebSetup1.vdproj" > "C:\Dev\MvcWebApplication1\MvcWebSetup1\MvcWebSetup1.vdproj.log"
REM Move the deployment files 
echo F | xcopy /F /Y /R "C:\Dev\MvcWebApplication1\MvcWebSetup1\Debug\TestMvcWebSetup.msi" "\\releases\Dev\TestMvcWebSetup.msi\TestMvcWebSetup.msi"
I found a great article on adding a Web Setup Project to a solution here: http://dataerror.blogspot.in/2010/06/creating-web-setup-project-for-aspnet.html
8May/120
Backspace, Enter, and Arrow Keys Stop Working in Visual Studio 2010

This irritating problem plagued me for a while in Visual Studio 2010. When this happened, my enter, backspace, and arrow keys worked in one of the properties windows instead of the text box. To fix this, click ALT + ENTER. Focus will then shift back into the text screen and the problem goes away. Hope this helps.