Month: August, 2006

Adding a column with DataType VarBinaryMax using SMO

24 August, 2006 (00:48) | .net | 1 comment

I have discovered that the following code does not behave as expected…
Table someTable = database.Tables["some_table"];
Column someColumn = new Column (someTable, "some_column", DataType.VarBinaryMax);
someTable.Columns.Add(someColumn);
someTable.Alter();

This code will actually add a column of type varbinary(1) to the database. The following works…
Column someColumn = new Column (someTable, "some_column", DataType.VarBinary(-1));
Oh well.


InternalsVisibleTo Attribute Compiler Error CS1726

1 August, 2006 (13:00) | .net | No comments

I’ve decided to use the InternalsVisibleTo assembly attribute to give access to some internal classes to a unit testing project.I added the attribute to my project, and I got this CS1726 compiler error. I duly googled for a solution, and discovered that (unsurprisingly) many people came across this error after strong naming their assembly.

The thing was that none of my assemblies were strong named. It turns out that the problem was due to the presence of the following attributes in my AssemblyInfo.cs file:

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

I commented them out and hey-presto, everything worked as expected. I think the presence if these attributes is a hang-over from VS2003. They don’t seem to be generated by default in VS2005 Assembly Info files.