In some cases it can be useful to quickly run your Microsoft unit tests on a machine where Visual Studio is not installed. For example on an end-user machine and/or during acceptance testing. Microsoft unit tests have a great integration with Visual Studio and Team Foundation Server, but unfortunately the unit tests cannot be run as a standalone application.
I saw there was an open-source adapter for NUnit, called Microsoft Team System NUnit Adapter from Exact Magic Software that can run Microsoft unit tests inside NAnt. For my unit tests I had some problems with the ExpectedException attribute. Then I noticed there is a project called Gallio and it worked like a charm and it can do a lot more! I noticed that today a new version has been released, namely Gallio v3.0.4.
Gallio is a extensible , open and neutral test automation platform. It provides tools and services needed to run and manipulate tests written using a wide range of other frameworks. Gallio can run tests from
Today I needed to install extra stuff on my VPC, but it turned out that there was not enough space. Donn Felker blogged a nice article how you can resize your VHD, I followed all the steps and It worked like a charm.
SQL Server 2008 is now available on MSDN and TechNet, see the announcement here. To have an overview of the new features, you can have a look here and you may download the SQL Server 2008 Books Online. Apparently has SQL Server 2008 powershell support!
The unity application block is a dependency injection container with support for constructor, property and method call injection. It simplifies the Inversion of Control (IoC) pattern and the Dependency Injection (DI) pattern. The Unity application block can be found on CodePlex.
The unity application block has two important methods for registering types and mappings into the container, namely RegisterType and RegisterInstance.
Method
Default Lifetime
Explanation
RegisterType
Transient Lifetime
Container will create a new instance on each call to Resolve
RegisterInstance
Container-controller lifetime
Instance has the lifetime of the container
Below you find an example where we map the ILogger interface to ConsoleLogger (implements ILogger).
If you now try to resolve MyClass you will get an exception, because it cannot resolve which type (ConsoleLogger or EventLogger) to use. Therefore you can use the Dependency attribute where you can denote a key. For example:
When trying to edit some code during debug, I received the following dialog of Visual Studio:
It appears that the edit and continue feature is not supported when the target is a 64-bit application. On this page you find a nice overview of the scenarios where the edit and continue features are not supported. To resolve the problem, you have to set the target to x86, which can be found in the project properties.
In my current sample project when the runtime tried to access the MyMeta library (see following post) I always get the following FatalExecutingEngineError exception:
It turns out that the problem is that the MyMeta library is compiled under a x86 platform whereas the application is running on a x64 platform. In the properties settings of your visual studio project you have to set the platform target to x86! It was set to 'Any CPU', but now everything works fine.
Component Dropper is a component that resides in the toolbox of VS.NET and enables you to choose a component (controls, datasets, providers, components, etc.) from the assemblies that are referenced in the current project.
In Visual Studio .NET you can auto populate the controls in the toolbox by setting the AutoToolboxPopulate property to true in menu Tools -> Options -> Windows Forms Designer.
Component Dropper is an alternative way for dropping a component on the designer surface. It gives you a dialog with all the components that reside in the assemblies that are referenced in the current project. This means that it is not limited to the assemblies that reside in the current solution. This way you can easily browse and search throughout the assemblies and controls, this is very handy if you have bunch of assemblies and controls. There is never a need to refresh the toolbox, because it dynamically searches throughout the references in the current project.
If after installation you don't see the component dropper appearing in the toolbox, you can simply drag-and-drop the IStaySharp.RazorToolbox.dll to the toolbox.
SMO (SQL Server Management Objects) is a .NET based object library for programming all aspects of managing Microsoft SQL Server. Replication Management Objects (RMO) is another library that encapsulates SQL Server replication management.
SMO assemblies are shipped with SQL Server 2005 and can be used to connect with SQL Server 7, 2000 or 2005. The assemblies are located in the following folder C:\Program Files\Microsoft SQL Server\90SDKAssemblies.
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.SmoEnum.dll
Microsoft.SqlServer.SqlEnum.dll
With SMO you can do all kind of management on a SQL Server, namely: tables, columns, indexes, stored procedures, service broker, backup and restore, managing users/roles and logins, scheduling, etc. Here you can find some specific tasks that can be done with SMO.
Below you find an example how you can create a table with SMO:
usingSystem.Data.SqlClient;usingMicrosoft.SqlServer.Management.Smo;usingMicrosoft.SqlServer.Management.Common;publicclassSample{publicvoidCreate(stringconnectionstring){SqlConnectionconnection=newSqlConnection(connectionstring);Serverserver=newServer(newServerConnection(connection));Databasedatabase=server.Databases["MyDatabase"];// Create table, called CustomerTabletable=newTable(database,"Customer");// Add 'ID' column which is the primary keyColumnidColumn=newColumn(table,"ID");idColumn.DataType=DataType.Int;idColumn.Identity=true;idColumn.IdentitySeed=1;idColumn.IdentityIncrement=1;// Create a primary key indexIndexindex=newIndex(table,string.Format("PK_{0}",table.Name));index.IndexKeyType=IndexKeyType.DriPrimaryKey;index.IndexedColumns.Add(newIndexedColumn(index,"ID"));table.Indexes.Add(index);// Add 'Name' columnColumnnameColumn=newColumn(table,"Name");nameColumn.DataType=DataType.VarChar(50);// Add colums to tabletable.Columns.Add(idColumn);table.Columns.Add(nameColumn);table.Create();}}
MyMeta is an open-source API that allows you to get meta-data from your database. MyMeta is part of MyGeneration, a free code generator hosted on Sourceforge. The MyMeta API can be downloaded separately here (filename is called mymeta_installer.exe).
MyMeta supports the following databases. Note that the API is extensible and that you can provide your own plug-ins
Advantage
Delimited Text
Firebird
IBM DB2
IBM iSeries (AS400)
Interbase
Microsoft Access
Microsoft SQL CE
Microsoft SQL Server
MySQL
MySQL2
Oracle
Pervasive
PostgreSQL
PostgreSQL 8+
SQLite
VistaDB
Xsd3b (xml,xsd,uml,er)
Below you find a code snippet that will iterate, for a SQLite database, all tables, columns and indexes.
MyMeta can map database types to specific ADO.NET data types and language types (C#, VB.NET, etc.). MyMeta has a set of XML files (included in the setup) that contains these mappings. Namely the Languages.xml and DbTargets.xml. Below you find a snippet of the two XML files:
The xml files can be loaded by setting the LanguageMappingFilename and DbTargetMappingFilename. Setting the right target can be done by the properties Language and DbTarget.
Jihaaa, Visual Studio 2008 has been released on MSDN. If you want to have a nice overview of the new features in VS2008, take a look at this post from ScottGu.
Take a look at the following downloads available for VS2008