Thursday, 28 August 2008

LINQ-To-SQL auto-generate failure. "The custom tool 'MSLinqToSQLGenerator' failed. Unspecified error." Visual Studio 2008 SP1 bug. SourceSafe may delete your designer.cs file!

If you have a partial class associated with a LINQ DataContext DBML's designer.cs file, then after Visual Studio 2008 SP1 is applied, the designer file may not be created properly IF you have a using statement declared outside of the namespace.

The simple solution is to move the using statements inside the namespace construct.

A bug has been posted to Microsoft.  I'm just glad it's a simple solution.

thanks, k

Wednesday, 27 August 2008

Unable to dismiss ModalPopupExtender dialog with CancelControlId or behaviour's hide method

This is because the TargetControlId must not be the panel.  I found that if I created a HiddenField control, just inside the popup panel, this makes the Cancel and OK buttons work as expected.

Thursday, 21 August 2008

Community Server 2.1 SP3 with IIS 7 : "Request is not available in this context"

Unfortunately, CS 2.1 will not work out-of-the-box with IIS 7.0.  There is a small problem where the Job initialisation routine attempts to get the Application's Path  on application start-up from the current request - i.e. the request that started the application.  This will no longer work because the request has been decoupled from application start-up.

This is a simple change though... just change the ApplicationPath property getter inside Globals.cs to

static public string ApplicationPath {

            get {
                string applicationPath = "/";
                if(HttpContext.Current != null)
                    applicationPath = HttpRuntime.AppDomainAppVirtualPath;

                // Are we in an application?
                //
                if (applicationPath == "/") {
                    return string.Empty;
                } else {
                    return applicationPath;
                }
            }

        }

 

The change is simple to get the Application Path from the Http Runtime, rather than the request object. i.e. using AppDomainAppVirtualPath

Just re-compile in release mode and you're away.  Also, ensure the SP level of your CS source code is the same as the binary in your app.

Here are the version numbers and release dates for CS 2.1

  • CS 2.1 Build 2.1.60809.935 August 9, 2006             RTM
  • CS 2.1 Service Pack 1 Build 2.1.61025.2 October 30, 2006
  • CS 2.1 Service Pack 2 Build 2.1.61129.2 December 5, 2006
  • CS 2.1 Service Pack 3 Build 2.1.20416.3 April 16, 2007

thanks

k

Wednesday, 6 August 2008

Backing Up Visual SourceSafe with a batch script, WinZip and FTP

Obviously source code is the most important thing to any software project and I wanted to make sure that we had automated process in-place which would ensure we had an archive of weekly, off-site backups of our work. 

So I assembled a batch script like this:

@For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @(
    Set Month=%%B
    Set Day=%%A
    Set Year=%%C
)
@set filename=VSS%Year%%Month%%Day%bak.zip
echo Creating %filename%...
"C:\Program Files\WinZip\wzzip.exe" -p -r "C:\VSS_BACKUP_ZIPS\%filename%" "c:\VSS_BACKUP\*.*"
echo Done

REM --- CREATED ZIP ---

set FTPADDRESS=127.0.0.1
set SITEBACKUPFILE=%filename%

REM set /p FTPUSERNAME=Enter FTP User Name:
REM set /p FTPPASSWORD=Enter FTP Password:

set FTPUSERNAME=myusername
set FTPPASSWORD=mypassword

CLS
> script.ftp USER
>>script.ftp ECHO %FTPUSERNAME%
>>script.ftp ECHO %FTPPASSWORD%
>>script.ftp ECHO binary
>>script.ftp ECHO prompt n
:: Use put instead of get to upload the file
>>script.ftp ECHO CD VSSBackups
>>script.ftp ECHO put %SITEBACKUPFILE%
>>script.ftp ECHO bye
FTP -v -s:script.ftp %FTPADDRESS%
TYPE NUL >script.ftp
DEL script.ftp

This script depends on the following:

  • Visual SourceSafe is configured to maintain a Shadow directory, which contains all the latest files.
  • WinZip and the WinZip Command Line Add-on (although I'm sure this can easily be replaced by something free)
  • Microsoft's FTP.exe program in Windows\System32.

It does the following:-

  1. It parses out the various components of the current date into variables: month, day and year. 
  2. Creates the zip of the VSS shadow folder, with a filename containing today's date in the format 'yyyyMMdd'
  3. Generates a temporary FTP command file called 'script.ftp'.  This commands the FTP program to upload the zip file.
  4. Invokes FTP.exe to process the command file, thus uploads the zip off-site.

 

Once I'd tested it, I used the Windows Task Scheduler to invoke it every Sunday night at 1am.

Now we have peace of mind.

thanks

Kris