... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2004-10-29

NUnit Gotcha

If you neglect to make the constructor on a test fixture public, the NUnit test runner will complain that the fixture is invalid with the misleading reason 'the fixture contains no tests'.

2004-10-27

Internet Explorer DOM

Using IE 6, when you create an INPUT node, you must set the type property prior to adding the node as a child of another element.  If you try to add it afterwards, IE complains that the type property cannot be read.

2004-10-22

SQL Server

Here is an MS SQL statement that creates an SQL script containing INSERT statements for all of the data in all of the tables in the current schema:

select
    case when c.ordinal_position = 1
        then 'SELECT ''INSERT INTO "' + t.table_name + '" VALUES ('''
        else ''
        end,
    ' + coalesce('
        + case when patindex('%char%', c.data_type) <> 0
               or patindex('%text%', c.data_type) <> 0
               or patindex('%date%', c.data_type) <> 0
               or patindex('%time%', c.data_type) <> 0
            then ''''''''' + replace(' + c.column_name + ', '''''''', '''''''''''') + '''''''''
            else 'convert(varchar, ' + c.column_name + ')' end
        + ', ''NULL'')',
    case when c.ordinal_position <> all(select max(ordinal_position)
                                       from information_schema.columns
                                       where table_name = t.table_name )
        then ' + '','''
        else ' + '');'' FROM "' + t.table_name
            + case when t.table_name = all(select max(table_name)
                                           from information_schema.tables
                                           where table_type = 'BASE TABLE'
                                           and table_name <> 'dtproperties'
                                           )
                  then '";' else '" UNION' end
        end
from information_schema.tables as t
join information_schema.columns as c on (t.table_name = c.table_name)
where t.table_type = 'BASE TABLE'
and t.table_name <> 'dtproperties'
order by t.table_name, c.ordinal_position

It doesn't handle all the data types, but works well for small databases.  The statement could be adapted to other dialects of SQL.

2004-10-08

Simulators

In anticipation of demonstrating QJ to Schlumberger, I went looking for some open source E&P software, especially simulators, that I could try to hook into QJ.  I found Sim42, an open source chemical process simulator.  I also dragged SysQuake out of distant memory as a general purpose simulation package.

2004-10-07

Visual Studio

The way Visual Studio 2003 handles web projects still sucks.  As I noted before, there is a way to work around most of the problems discussed at:

ASP.NET Applications without Web Projects

In the end, however, these were the steps I followed to get things to work in my project:

  1. Create a deploy directory to hold your assembled web application.  Add this directory to your web server instead of the default build outputs directory.
  2. Create a post-build script to copy the build outputs to the deploy directory, as well as other critical files like the *.aspx, Global.asax, Web.config, etc.  Note that the DLLs for the application must be contained in a directory tree rooted in a directory called bin.  A sample post-build script might look like:
    del/s/q $(ProjectDir)deploy
    xcopy/y/f $(ProjectDir)Web.config $(ProjectDir)deploy
    xcopy/y/f $(ProjectDir)Global.asax $(ProjectDir)deploy
    xcopy/y/f $(ProjectDir)*.aspx $(ProjectDir)deploy
    xcopy/y/f $(TargetDir)*.dll $(ProjectDir)deploy\bin
  3. Make sure you have a Web.config file and that the attribute /configuration/compilation/@debug is true.
  4. Edit the project's configuration properties so that:
    1. Debugging\Enable ASP.NET Debugging is true
    2. Debugging\Debug Mode is URL
    3. Debugging\Start URL is the URL of your page

Also, as a one-time operation on any given Visual Studio installation, I followed the steps on the web site referenced above to get make all of the web items available on the "new item" palette.  Specifically, I added the following lines to the of the file VC#\CSharpProjectItems\LocalProjectItems\localprojectitems.vsdir in the VS installation directory:

..\CSharpAddWebFormWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2236|10|#2263|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4534|0|WebForm.aspx
..\CSharpAddWebServiceWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2243|20|#2266|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4521|0|Service.asmx
..\CSharpAddMobileWebFormWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2398|25|#2399|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4571|0|MobileWebForm.aspx
..\CSharpAddGlobalASAX.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2304|160|#2305|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4542|8192|Global.asax
..\CSharpAddMobileWebFormWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2398|25|#2399|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4571|0|MobileWebForm.aspx
..\CSharpAddMobileWebUserControl.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2400|56|#2401|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4572|0|MobileWebUserControl.ascx
..\CSharpAddWebConfig.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2312|170|#2313|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4545|8192|Web.config
..\CSharpAddWebDataForm.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2380|45|#2381|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4559|0|DataForm.aspx
..\CSharpAddWebFormWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2236|10|#2263|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4534|0|WebForm.aspx
..\CSharpAddWebServiceWiz.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2243|20|#2266|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4521|0|Service.asmx
..\CSharpAddWebUserControl.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2378|55|#2379|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4558|0|WebUserControl.ascx
..\StaticDisco.disco|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2393|155|#2394|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4525|0|Disco.disco

2004-10-01

xs3p

Stylus Studio uses a nice XML Schema documentation generator called xs3p.

Stylus Studio

Bugs?

 The expression context for the XPath query functionality does not define the default namespace.  Therefore, there is no way to search for elements in most documents, i.e. documents that have a non-empty default namespace.  How did they miss that one?

The query v.1 button keeps getting reselected when I type text into the query box even after I have explicitly chosen v.2.  I have to type first, then select v.2.

XPath2 querying is sketchy.  There is no mention of it in the documentation.  The expression "for $x in (1, 2, 3) return $x" generates a warning dialog box with no text in it.  "(1, 2, 3)" works.

Visual Studio

The way Visual Studio 2003 handles web projects sucks.  You must create a virtual directory on IIS that contains not only your binaries, but also your source.  Weird.  Also, VS2003 cannot handle filenames that start with a dot -- such as Subversion .SVN files.  I found an article that shows how to work with ASP.NET with a standard local project:

ASP.NET Applications without Web Projects

Blog Archive