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. 
- Object Orientation
- Internet Explorer 8 Beta 1
- ASP.NET
- Silverlight 2 Beta 1
- Visual Studio 2008
- Misc
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.
Download: ComponentDropper v0.9 (35.04 KB)
There is also a demo (1.11 Mb) that illustrates the use of Component Dropper. Note that the demo uses an older version of Component Dropper, namely version 0.5, and it's not an VS add-in anymore.
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. Any suggestions or remarks are welcome!
PowerCommands is a set of useful extensions for the Visual Studio 2008 adding functionality to various area of the IDE. The features I found very useful are: - Copy/Paste References
- Edit Project File
- Remove and Sort Usings
PowerCommands can be downloaded here and below you find the complete list of features: - Collapse Projects
This command collapses a hierarchy in the solution explorer starting from the root selected node. It can be executed from three different places: solution, solution folders and project nodes respectively. - Copy Class
This command copies a selected class entire content to the clipboard. It can be executed from a single project item or a project item with dependent sub items. - Paste Class
This command pastes a class entire content from the clipboard. It can be executed from a project or folder node. - Copy References
This command copies a reference or set of references to the clipboard. It can be executed from the references node, a single reference node or set of reference nodes. - Paste References
This command pastes a reference or set of references from the clipboard. It can be executed from different places depending on the type of project. For CSharp projects it can be executed from the references node. For Visual Basic and Website projects it can be executed from the project node. - Copy As Project Reference
This command copies a project as a project reference to the clipboard. It can be executed from a project node. - Edit Project File
This command opens the MSBuild project file for a selected project inside Visual Studio. It can be executed from a project node. - Open Containing Folder
This command opens a Windows Explorer window pointing to the physical path of a selected item. It can be executed from a project item node - Open Command Prompt
This command opens a Visual Studio command prompt pointing to the physical path of a selected item. It can be executed from four different places: solution, project, folder and project item nodes respectively. - Unload Projects
This command unloads all projects in a solution. It can be executed from the solution node. - Reload Projects
This command reloads all unloaded projects in a solution. It can be executed from the solution node. - Remove and Sort Usings
This command removes and sort using statements for all classes given a project. It can be executed from a solution node or a single project node. Note: The Remove and Sort Usings feature is only available for C# projects since the C# editor implements this feature as a command in the C# editor (which this command calls for each .cs file in the project). The Visual Basic IDE implements this functionality for Imports in an interactive way: Project properties, go to the References tab, then click the Unused References... button, then select which references you want removed via a listbox. - Extract Constant
This command creates a constant definition statement for a selected text. It can be executed from the code window over a selected text. - Clear Recent File List
This command clears the Visual Studio recent file list. - Clear Recent Project List
This command clears the Visual Studio recent project list. - Transform Templates
This command executes the associated custom tool with text templates items. It can be executed from a DSL project node or a folder node. - Close All
This command closes all documents. It can be executed from a document tab.
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\90\SDK\Assemblies. - 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: Copy Codeusing System.Data.SqlClient;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
public class Sample
{
public void Create(string connectionstring)
{
SqlConnection connection = new SqlConnection(connectionstring);
Server server = new Server(new ServerConnection(connection));
Database database = server.Databases["MyDatabase"];
// Create table, called Customer
Table table = new Table(database, "Customer");
// Add 'ID' column which is the primary key
Column idColumn = new Column(table, "ID");
idColumn.DataType = DataType.Int;
idColumn.Identity = true;
idColumn.IdentitySeed = 1;
idColumn.IdentityIncrement = 1;
// Create a primary key index
Index index = new Index(table, string.Format("PK_{0}", table.Name));
index.IndexKeyType = IndexKeyType.DriPrimaryKey;
index.IndexedColumns.Add(new IndexedColumn(index, "ID"));
table.Indexes.Add(index);
// Add 'Name' column
Column nameColumn = new Column(table, "Name");
nameColumn.DataType = DataType.VarChar(50);
// Add colums to table
table.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 - Copy Codestring connectionstring = @"data source=SQLiteDatabase.DB";
MyMeta.dbRoot myMeta = new MyMeta.dbRoot();
myMeta.Connect(MyMeta.dbDriver.SQLite, connectionstring);
IDatabase db = myMeta.DefaultDatabase;
foreach (MyMeta.ITable table in db.Tables)
{
Console.WriteLine("{0} ({1})", table.Name, table.Columns.Count);
Console.WriteLine("\tCOLUMNS");
foreach (MyMeta.IColumn column in table.Columns)
{
Console.WriteLine("\t\t{0} ({1}), Nullable:{2}",
column.Name, column.DataTypeName, column.IsNullable);
}
Console.WriteLine("\tINDEXES");
foreach (MyMeta.IIndex index in table.Indexes)
{
Console.WriteLine("\t\t{0}, Unique:{1}", index.Name, index.Unique);
}
}
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:
Languages.xml - Copy Code<Languages>
...
<Language From="SQL" To="C#">
<Type From="bigint" To="long" />
<Type From="binary" To="object" />
<Type From="bit" To="bool" />
<Type From="char" To="string" />
<Type From="datetime" To="DateTime" />
<Type From="decimal" To="decimal" />
<Type From="float" To="double" />
<Type From="image" To="byte[]" />
<Type From="int" To="int" />
<Type From="money" To="decimal" />
<Type From="nchar" To="string" />
<Type From="ntext" To="string" />
<Type From="numeric" To="decimal" />
<Type From="nvarchar" To="string" />
<Type From="real" To="float" />
<Type From="smalldatetime" To="DateTime" />
<Type From="smallint" To="short" />
<Type From="smallmoney" To="decimal" />
<Type From="text" To="string" />
<Type From="timestamp" To="byte[]" />
<Type From="tinyint" To="byte" />
<Type From="uniqueidentifier" To="Guid" />
<Type From="varbinary" To="byte[]" />
<Type From="varchar" To="string" />
<Type From="xml" To="string" />
<Type From="sql_variant" To="object" />
</Language>
...
<Language From="SQLITE" To="C# (SQLite v3.x)">
<Type From="CHAR" To="string" />
<Type From="DATETIME" To="DateTime" />
<Type From="DATE" To="DateTime" />
<Type From="TIMESTAMP" To="DateTime" />
<Type From="TIME" To="TimeSpan" />
<Type From="DECIMAL" To="decimal" />
<Type From="VARCHAR" To="string" />
<Type From="NVARCHAR" To="string" />
<Type From="TEXT" To="string" />
<Type From="INTEGER" To="long" />
<Type From="INT" To="long" />
<Type From="FLOAT" To="float" />
<Type From="BOOLEAN" To="bool" />
<Type From="CLOB" To="string" />
<Type From="BLOB" To="byte[]" />
<Type From="NUMERIC" To="decimal" />
<Type From="VARYINGCHARACTER" To="string" />
<Type From="NATIONALVARYINGCHARACTER" To="string" />
</Language>
...
</Languages>
|
DbTargets.xml - Copy Code<DbTargets>
...
<DbTarget From="SQL" To="SqlClient">
<Type From="bigint" To="SqlDbType.BigInt" />
<Type From="binary" To="SqlDbType.Binary" />
<Type From="bit" To="SqlDbType.Bit" />
<Type From="char" To="SqlDbType.Char" />
<Type From="datetime" To="SqlDbType.DateTime" />
<Type From="decimal" To="SqlDbType.Decimal" />
<Type From="float" To="SqlDbType.Float" />
<Type From="image" To="SqlDbType.Image" />
<Type From="int" To="SqlDbType.Int" />
<Type From="money" To="SqlDbType.Money" />
<Type From="nchar" To="SqlDbType.NChar" />
<Type From="ntext" To="SqlDbType.NText" />
<Type From="numeric" To="SqlDbType.Decimal" />
<Type From="nvarchar" To="SqlDbType.NVarChar" />
<Type From="real" To="SqlDbType.Real" />
<Type From="smalldatetime" To="SqlDbType.SmallDateTime" />
<Type From="smallint" To="SqlDbType.SmallInt" />
<Type From="smallmoney" To="SqlDbType.SmallMoney" />
<Type From="text" To="SqlDbType.Text" />
<Type From="timestamp" To="SqlDbType.Timestamp" />
<Type From="tinyint" To="SqlDbType.TinyInt" />
<Type From="uniqueidentifier" To="SqlDbType.UniqueIdentifier" />
<Type From="varbinary" To="SqlDbType.VarBinary" />
<Type From="varchar" To="SqlDbType.VarChar" />
<Type From="xml" To="SqlDbType.Xml" />
<Type From="sql_variant" To="SqlDbType.Variant" />
</DbTarget>
...
<DbTarget From="SQLITE" To="SQLite.NET v3.x">
<Type From="CHAR" To="DbType.String" />
<Type From="DATETIME" To="DbType.DateTime" />
<Type From="DATE" To="DbType.DateTime" />
<Type From="TIMESTAMP" To="DbType.DateTime" />
<Type From="TIME" To="DbType.Time" />
<Type From="DECIMAL" To="DbType.Decimal" />
<Type From="VARCHAR" To="DbType.String" />
<Type From="NVARCHAR" To="DbType.String" />
<Type From="TEXT" To="DbType.String" />
<Type From="INTEGER" To="DbType.Int64" />
<Type From="INT" To="DbType.Int32" />
<Type From="FLOAT" To="DbType.Single" />
<Type From="BOOLEAN" To="DbType.Boolean" />
<Type From="CLOB" To="DbType.String" />
<Type From="BLOB" To="DbType.Binary" />
<Type From="NUMERIC" To="DbType.Decimal" />
<Type From="VARYINGCHARACTER" To="DbType.String" />
<Type From="NATIONALVARYINGCHARACTER" To="DbType.String" />
</DbTarget>
...
</DbTargets>
|
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.
MyMeta - Copy Codestring connectionstring = @"data source=SQLiteDatabase.DB";
MyMeta.dbRoot myMeta = new MyMeta.dbRoot();
myMeta.Connect(MyMeta.dbDriver.SQLite, connectionstring);
myMeta.LanguageMappingFileName = @"C:\Program Files\MyGenerations\Settings\Languages.xml";
myMeta.DbTargetMappingFileName = @"C:\Program Files\MyGenerations\Settings\DbTargets.xml";
myMeta.Language = "C# (SQLite v3.x)";
myMeta.DbTarget = "SQLite.NET v3.x";
IDatabase db = myMeta.DefaultDatabase;
foreach (MyMeta.ITable table in db.Tables)
{
Console.WriteLine("{0} ({1})", table.Name, table.Columns.Count);
Console.WriteLine("\tCOLUMNS");
foreach (MyMeta.IColumn column in table.Columns)
{
Console.WriteLine("\t\t{0} ({1}), DBTargetType:{2}, LanguageType:{3}",
column.Name, column.DataTypeName, column.DbTargetType, column.LanguageType);
}
}
The mapped types can be found in the properties DbTargetType and LanguageType on the IColumn interface.
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
I has been a while that I released a new version of ComponentDropper and I am going to release a new update very soon. I received positive feedback, and I am planning to add some new features and certainly to provide an installer for the add-in. Please leave a comment if you have any suggestions about ComponentDropper.
Yesterday I arrived in Barcelona for TechEd 2007. I followed already some interesting sessions about LINQ, it brings you closer how you can access data in a more intuitive and more object-oriented way (data = objects). I really like LINQ to SQL, one of the drawbacks, is that it can only be used against a SQL Server database. If you need to target another database and program against a conceptual model (not a 1-1 mapping with your datatable structure and objects) you can have a look at LINQ to Entities.
On my current project I had the need to iterate through the properties of an object with reflection and to check if one of the properties is a generic List type, e.g. IList<int>, IList<Customer>, etc. To check through reflection on a generic type, you need to use the GetGenericTypeDefinition method. Copy Codeforeach (PropertyInfo propertyInfo in entity.GetType().GetProperties())
{
if (propertyInfo.PropertyType.IsGenericType &&
typeof(List<>).IsAssignableFrom(propertyInfo.PropertyType.GetGenericTypeDefinition()))
{
IEnumerable enumerable = propertyInfo.GetValue(entity, null) as IEnumerable;
IEnumerator enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext())
{
// do something
}
}
}
Last week, I purchased a Linksys WRT54GL at RouterShop.nl. The service at Routershop.nl was really fast: at around 1:00pm I created the order and it was delivered the very next day! The big advantage of WRT54GL is that you can upgrade the firmware of the device. Some popular firmware's are DD-WRT, OpenWRT and Tomato. I am using Tomato, of which today a new version has been released, i.e. Tomato 1.09. Tomato has a very nice interface, many interesting features and great-looking graphs. Below you will find a nice graph concerning the bandwidth: Note that you need to install the Adobe SVG Viewer in order to view the graphs.
Last weekend I visited CeBIT 2007 in Hannover. We rented a house for the weekend in Steinhude which is not far from CeBIT and can easily be reached by car and train. If you are looking to stay overnight in Steinhude I would recommend this house, all comfort is available (TV, shower, kitchen, etc.). Like every year, there were lots of brands and new products to discover. One of the cool things at CeBIT, is that you can gather a lot of gadgets :). An eyecatcher was this modding project for the World Cyber Games 2007 which is a 200 hours project! And I found that server rack of IBM also impressive. One of the things that really touched me - a trip down memory lane -, was a working Commodore 64 of the good old days. There was a room that showed some computer history. If I remember correctly, I have had the following computers with which I grew up, and I have to admit, it was mainly for playing games  And when I came of age, I switched to the traditional personal computer. But I must say that there is really nothing compared to those old skool arcade games, such as
CSLA.NET framework from Lhotka contains a lot of mechanisms for adding validations and business rules. Through CSLA.NET you can easily provide your own custom rules. Enterprise Library v3.0 now also contains a validation application block (VAB) that can be used through attributes and even from a configuration file. The two validation mechanisms of validation are complementary. This can be done by adding a custom rule that uses the ValidationFactory of the VAB. This means we have something like: Copy Codepublic class VABRules
{
public class VABRuleArgs : RuleArgs
{
private string _ruleset;
public string Ruleset
{
get { return _ruleset; }
}
public VABRuleArgs(string propertyName) : this(propertyName, null)
{
}
public VABRuleArgs(string propertyName, string ruleset) : base(propertyName)
{
_ruleset = ruleset;
}
}
public static bool VABValid<T>(object target, RuleArgs e)
{
Validator<T> validator = ValidationFactory.CreateValidator<T>(((VABRuleArgs)e).Ruleset);
if (validator == null)
return true;
ValidationResults results = validator.Validate(target);
if (results == null)
return true;
foreach (ValidationResult result in results)
{
if (result.Key == e.PropertyName)
{
e.Description
|