Archives

Archives / 2009 / November
  • Visual Studio Error: The project file ' ' has been renamed or is no longer in the solution.

    I received the vague error message “The project file ' ' has been renamed or is no longer in the solution” while building a Visual Studio solution.  I was unable to build any projects in the solution.  Rebuild and Clean were not working and were responding with the same message.

    image

    ---------------------------
    Microsoft Visual Studio
    ---------------------------
    The project file ' ' has been renamed or is no longer in the solution.
    ---------------------------
    OK  
    ---------------------------

    After a bunch of searching around and hair pulling, I was able to narrow it down by removing all projects from my solution and slowly adding them back in one at a time and rebuilding between each one.  Eventually I tracked it down to the web application project I had in my solution, specifically the Silverlight Applications tab in the Project Properties.

    image

    What had happened was I removed a Silverlight project from my solution that was no longer needed but the Web Application project still had a reference to it.  Not sure why the name of the project got removed but it certainly made it difficult to understand the error message.

    By removing these two project references from the Silverlight Applications tab, the error message went away and I was able to build the solution.

    I hope this helps someone else out there.



  • How to show white space in Visual Studio

    In Microsoft Word I usually have the paragraph symbol turned on to Show Hidden Formatting Symbols (white space) so that I can clearly see spaces, tabs, and other white space characters. 

    image

    image

    Up until recently I had no idea that Visual Studio had the same option to display white space.  Jeff Atwood’s recent blog post Whitespace: The Silent Killer had a screen shot on some code showing white space characters, so I hunted around in the Visual Studio toolbars for a little bit and found the option under the Edit menu.

    Edit > Advanced > View White Space

    image 

    image

    You can also use Ctrl+R, Ctrl+W to toggle it on and off.

     



  • ISO 3166-1 Country Data SQL Script

    I am creating a standard sign up form with one of the fields being a country drop down. So I created my Country database table and then needed to fill it with information. I found the ISO list of countries here, but then the issue was how to get that list into my Country database table. Luckily someone has already done that for me: http://vidmar.net/weblog/archive/2008/05/23/database-of-country-names-numeric-alpha-2-and-alpha-3-iso-codes.aspx

    But I also like to be able to check a script like that into source control to be able to track changes to it. So I updated the insert script to be a rerunnable insert/update script.  The script will check if a country id exists and if it does not exist, then it will insert the country otherwise it will just do an update. The insert sql script from http://vidmar.net/weblog/archive/2008/05/23/database-of-country-names-numeric-alpha-2-and-alpha-3-iso-codes.aspx really got me most of the way there so I need to give a lot of credit to him.

    The link below will get you my updated version of the country data update sql script. I also updated it to 2010 from the ISO 3166 code lists plus any changes that they have posted so it is up to date as of May 15, 2010. I will try (but no promises) to keep it updated on a regular basis. Feel free to contact me if you want to try and keep it updated for me and I will post it here.

    Click here for the country data update sql script (up-to-date as of May 15, 2010).

    You can use this sql to create the Country table:

    CREATE TABLE [dbo].[Country]
        (
            CountryId int NOT NULL,
            Iso2 char(2) NOT NULL,
            Iso3 char(3) NOT NULL,
            Name nvarchar(64) NOT NULL,
            DateCreated datetimeoffset(7) NOT NULL CONSTRAINT [df__Country__DateCreated] DEFAULT (sysdatetimeoffset()),
            DateModified datetimeoffset(7) NOT NULL  CONSTRAINT [df__Country__DateModified] DEFAULT (sysdatetimeoffset())
        ) 

    ALTER TABLE dbo.Country ADD CONSTRAINT
        pk__Country__CountryId PRIMARY KEY CLUSTERED
        (
            CountryId ASC
        ) WITH FILLFACTOR = 100 ON [PRIMARY]



  • Generating a random strong password

    You can use the ASP.NET Membership provider to generate a new random strong password.

    In the past I have usually either rolled my own authentication system or integrated an asp.net authentication system into an existing application and therefore I did not use the ASP.NET Membership system.  In the current application I am writing, I had a need to generate a random strong password for the customer. 

    The ASP.NET Membership system already has a static method built-in for this.  You can use the GeneratePassword static method from the Membership class to create a new password:

    String strongPassword = System.Web.Security.Membership.GeneratePassword(8, 1);

    From the MSDN documentation, the two parameters are:

    • length – Int32
      • The number of characters in the generated password. The length must be between 1 and 128 characters.
    • numberOfNonAlphanumericCharacters – Int32
      • The minimum number of punctuation characters in the generated password.

    Also from the documentation: the generated password will contain alphanumeric characters and the following punctuation marks: !@#$%^&*()_-+=[{]};:<>|./?.

    But also not included in the documentation is that the returned password will not be a “dangerous string”; in other words it won’t look like a block of script. 

    The Membership.GeneratePassword checks the newly generated password string using an internal method called CrossSiteScriptingValidation.IsDangerousString() and will not return a password that does not pass this test.  It will just loop and continue to generate a new one until it is not considered a dangerous string.  Pretty cool stuff!



  • Canon Scanner – Unable to open TWAIN source

    I have a Canon CanoScan 4400F Scanner and the other day I was unable to get it to work.  I use the Canon software CanoScan Toolbox to operate the scanner and when trying to scan I was getting the following error message:

    image

    ---------------------------
    CanoScan Toolbox
    ---------------------------
    Unable to open TWAIN source
    Please check connection
    Then re-start Toolbox
    ---------------------------
    OK  
    ---------------------------

    Searching the Internet for this problem turned up several people having the same problem and several solutions which looked like they may or may not work.  One of the recommended solutions was to make sure a certain folder path is in your PATH environment variable.  As it turned out this was the problem, so here is how to add that path back into your environment variables.

    First, determine the correct path to add into the PATH environment variable.  Look in C:\Windows\twain_32 and there should one other folder in there.  In my case it was  named CNQ4803.

    image

    This is the path that is needed to be added into the PATH environment variable.

    C:\Windows\twain_32\CNQ4803

     

    Now, follow these instructions to get to the dialog to modify the PATH environment variable.

    Control Panel > System > and then choose Advanced System Settings in the left hand column.

    image

    This will bring up the System Properties dialog (it should already be on the Advanced tab).

    image

    At the bottom of this dialog is an Environment Variables button.  Clicking this button will bring up the Environment Variables dialog.

    image

    In the bottom panel, scroll until you find the variable named Path.  Select this one and then hit the Edit… button to bring up the Edit System Variable dialog.

    image

    In the Variable value text box, scroll all the way to the right and then add in the path C:\Windows\twain_32\CNQ4803 that was determined earlier.  Make sure to separate this value with a preceding semi-colon.  And also be careful not to make any other changes to this value.

    Now OK your way out of all of the dialogs and CanoScan Toolbox will now work as expected.