sharing about .NET and technology RSS 2.0
 Wednesday, January 10, 2007

Virtual PC 2007 RC1 has been released, and can be downloaded on the Microsoft Connect site, if you participated in the beta tests. The main new features are:

  • Support for Windows Vista™ as a host operating system
  • Support for Windows Vista™  as a guest operating system
  • Support for 64-bit host operating systems
  • Support for hardware-assisted virtualization
  • Built-in support for network installations

More details about the release notes can also be downloaded on the Microsoft Connect site.

Wednesday, January 10, 2007 12:04:03 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -
 | 
 Saturday, December 30, 2006

The Validation Application Block (VAB) of the upcoming Enterprise Library v3, uses attributes to describe validations. This gives us for example the opportunity to generate ASP.NET validators based on the attributes decorated on the properties.

Take for example the NotNullValidator of VAB, this can be translated to a RequiredFieldValidator, whereas the RegexValidator can be translated to RegularExpressionValidator. You can go further with the NotNullValidator and mark required fields with a different backcolor and adding an asterix (*) to the end of the control.

I am big fan of the DetailsView control, you can simply bind a DataSource control to it, and it will automatically provide you with a caption to each control and two-way binding. Below you find an example how you can extend the BoundField control, that investigates the NotNullValidator attribute of VAB. Note that I am currently extending it for the other set of validators and in a more OO way. More info will follow later.

BoundFieldEx.cs - Copy Code
public class BoundFieldEx : System.Web.UI.WebControls.BoundField { public override void InitializeCell( DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex) { base.InitializeCell(cell, cellType, rowState, rowIndex); if ((((rowState & DataControlRowState.Edit) != DataControlRowState.Normal) && !this.ReadOnly) || ((rowState & DataControlRowState.Insert) != DataControlRowState.Normal)) { TextBox textBox = null; if (cell != null && cell.Controls.Count > 0) textBox = cell.Controls[0] as TextBox; if (textBox != null) { Type dataItemType = null; if (DataBinder.GetDataItem(base.Control) != null) dataItemType = DataBinder.GetDataItem(base.Control).GetType(); if (dataItemType != null) { ValidatorAttribute attribute = IsRequired(dataItemType, base.DataField); if (attribute != null) { string textBoxID = this.DataField; textBox.ID = textBoxID; RequiredFieldValidator validator = new RequiredFieldValidator(); validator.ControlToValidate = textBoxID; validator.ID = string.Concat("RequiredValidatorOf", textBoxID); validator.Display = ValidatorDisplay.Dynamic; validator.ErrorMessage = attribute.MessageTemplate; cell.Controls.Add(validator); } } } } } private ValidatorAttribute IsRequired(Type dataType, string property) { PropertyInfo propertyInfo = dataType.GetProperty(property); if (propertyInfo != null) { foreach (Attribute attribute in propertyInfo.GetCustomAttributes(true)) { if (attribute is NotNullValidatorAttribute) return attribute as ValidatorAttribute; } } return null; } }

Now you create a custom business object, called Customer, and bind it to the DetailsView through an ObjectDataSource.

Customer.cs - Copy Code
public class Customer { private string _firstName; private string _lastName; [NotNullValidator(MessageTemplate="Firstname cannot be empty")] public string FirstName { get { return _firstName; } set { _firstName = value; } } [NotNullValidator(MessageTemplate="Lastname cannot be empty")] public string LastName { get { return _lastName; } set { _lastName = value; } } public Customer Fill() { Customer customer = new Customer(); customer.FirstName = "Christoph"; customer.LastName = "De Baene"; return customer; } }

Inside your aspx page you have something like

Customer.aspx - Copy Code
<asp:ObjectDataSource id="customerDataSource" TypeName="IStaySharp.Business.Customer, IStaySharp.Business" DataObjectTypeName="IStaySharp.Business.Customer, IStaySharp.Business" SelectMethod="Fill" runat="server"> </asp:ObjectDataSource> <asp:ValidationSummary runat="server"/> <asp:DetailsView DataSourceID="customerDataSource" DefaultMode="Edit" AutoGenerateRows="false" runat="server"> <Fields> <rfx:BoundField HeaderText="Firstname" DataField="FirstName"/> <rfx:BoundField HeaderText="Lastname" DataField="LastName"/> </Fields> </asp:DetailsView>

Here is the result if you leave the properties empty:

Saturday, December 30, 2006 12:31:05 AM (Romance Standard Time, UTC+01:00)  #    Comments [10] -

 Sunday, December 24, 2006

That's what I call a christmas present. A CTP for Enterprise Library v3.0 has been released on CodePlex. More info can be found in this post.

Sunday, December 24, 2006 1:16:47 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Monday, December 11, 2006
Version 0.23 of SyntaxColor4Writer is compiled against the new build release of Windows Live Writer 1.0.1 (Build 6) and Actipro Code Highlighter v4.0.0041.
Monday, December 11, 2006 12:55:38 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Tuesday, November 28, 2006

Tom Hollander revealed some features/scenarios about the upcoming Validation Application Block that will be included in Enterprise Library v3. There are already some validation libraries available, for example

The fact that you can define rules through configuration is really cool. I can't wait for the CTP!

Tuesday, November 28, 2006 1:18:44 AM (Romance Standard Time, UTC+01:00)  #    Comments [1] -

 Monday, November 27, 2006

VISUG has a brand new website. All the necessary features are already available and more functionality is coming soon. The two last VISUG events for year 2006 are announced. One of the events is a panel discussion about exception handling and logging, and it will take place at Real Software (my home). The other event is a geek dinner where we can discuss about... you know what I mean ;).

Topic: Discussion on Enterprise Exception Handling and Logging

Description: This is a session where you (yes, you!) can discuss exception handling and logging in enterprise applications. Bring your tips and tricks, problems and exception handling frustrations with you, and we'll all learn about best practices together!
No slides or preparation required! Don't want to discuss? No problem, you're not required to say anything, but we hope you will. To help with a smooth discussion, it will be lead by a panel of 3 to 4 people. If you're interested to sit on this panel, you're invited (First-come, First-served basis).

When:
Monday 11 December, 18:30 - 20:30

Where:
Real Software (Prins Boudewijnlaan, 2550 Kontich, Route)

Register: VISUG website

See you on both events!

Monday, November 27, 2006 11:37:58 PM (Romance Standard Time, UTC+01:00)  #    Comments [1] -

 Wednesday, November 22, 2006

This macro enables you to nest project items inside Visual Studio .NET. Until now, there is no easy way to nest project items through the Visual Studio IDE, you can only do it by manipulating the project (.csproj or .vbproj) file and adding the DependentUpon element.

Inside the IStaySharp.vsmacros file there is a macro called 'Create Dependency' which allows you to nest two selected items. I have even created a video (672,18 KB) to illustrate how to configure and use the macro.

Wednesday, November 22, 2006 12:23:49 AM (Romance Standard Time, UTC+01:00)  #    Comments [29] -

 Sunday, November 19, 2006

I must have missed that one, but some weeks ago, version 3.0 of Windows Desktop Search for Windows XP/2003 has been released. If you need to search in netwerk files you can download Windows Desktop Search: Add-in for UNC/FAT. If you want to recognize more filetypes, check out the IFilters page on Channel9.

Sunday, November 19, 2006 1:41:50 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Wednesday, November 15, 2006

PowerShell 1.0 has been released for Windows XP SP2 and Windows Server 2003. The bits can be downloaded here. If you already have installed a previous release of PowerShell, you need to uninstall by selecting 'Show Updates' in the 'Change or Remove Programs'.

Wednesday, November 15, 2006 12:39:07 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Tuesday, November 14, 2006

One of the oldest and most basic programs is certainly the command prompt (cmd.exe). One thing is certain, you still can't do without the command prompt, and certainly being a developer.  I came across a nice tool, called Console, which enhances the command prompt. I have been using it for a couple of months now, and I really like it.

One of the things you should really customize is your PROMPT. More information about changing the PROMPT can be found here. Having, for example, your current directory path on a separate line is really useful. You can customize it through the environment variable called PROMPT, like Scott is doing, but I prefer passing it as a parameter to the cmd.exe. This way I can easily copy the application and no reboot is required. This can be done by the /k argument of the cmd.exe.

Here is a snippet of my XML configuration file for Console.

console.xml - Copy Code
<tab title="Console"> <console shell="cmd /k PROMPT $p$_$+$g" init_dir=""/> <cursor style="11" r="255" g="255" b="255"/> <background type="2" r="0" g="0" b="0"> <image file="" relative="0" extend="0" position="0"> <tint opacity="190" r="0" g="0" b="0"/> </image> </background> </tab> <tab title="cmd"> <console shell="cmd.exe /k PROMPT $p$_$+$g" init_dir=""/> <cursor style="11" r="255" g="255" b="255"/> <background type="0" r="0" g="0" b="0"> <image file="" relative="0" extend="0" position="0"> <tint opacity="0" r="0" g="0" b="0"/> </image> </background> </tab> <tab title="VS.NET 2005"> <console shell="cmd /k PROMPT $p$_$+$g &amp;&amp; C:\PROGRA~1\MID05A~1\VC\vcvarsall.bat" init_dir=""/> <cursor style="0" r="255" g="255" b="255"/> <background type="2" r="0" g="0" b="0"> <image file="" relative="0" extend="0" position="0"> <tint opacity="188" r="0" g="0" b="0"/> </image> </background> </tab> <tab title="PowerShell"> <console shell="C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" init_dir=""/> <cursor style="0" r="255" g="255" b="255"/> <background type="2" r="0" g="0" b="0"> <image file="" relative="0" extend="0" position="0"> <tint opacity="189" r="0" g="0" b="0"/> </image> </background> </tab>
This is the result in Console

Tuesday, November 14, 2006 10:57:18 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Wednesday, November 01, 2006

I am currently building software factories and I needed a way to have a list of running Visual Studio instances and the corresponding EnvDTE._DTE object to manipulate the solution. Windows internally keeps a list of COM objects that are currently running, called the Running Object Table (ROT). VS .NET 2005 for example, register itself in the ROT as "!VisualStudio.DTE.8.0:pid" where 'pid' is the process id of the corresponding VS 2005 instance.

In .NET 1.1 you would use the the following UCOMIRunningObjectTable, UCOMIBindCtx for enumerating the ROT. In .NET 2.0 these interfaces are obsolete and are replaced by IRunningObjectTable and BIND_OPTS respectively. Note that the same code can be used for getting other instances like MS Word, IE, etc.

DTEHelper.cs - Copy Code
using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using EnvDTE; public static class DTEHelper { const uint S_OK = 0; [DllImport("ole32.dll")] public static extern uint GetRunningObjectTable(uint reserved, out IRunningObjectTable ROT); [DllImport("ole32.dll")] public static extern uint CreateBindCtx(uint reserved, out IBindCtx ctx); static IDictionary<string, object> GetRunningObjectTable() { IDictionary<string, object> rotTable = new Dictionary<string, object>(); IRunningObjectTable runningObjectTable; IEnumMoniker monikerEnumerator; IMoniker[] monikers = new IMoniker[1]; GetRunningObjectTable(0, out runningObjectTable); runningObjectTable.EnumRunning(out monikerEnumerator); monikerEnumerator.Reset(); IntPtr numberFetched = IntPtr.Zero; while (monikerEnumerator.Next(1, monikers, numberFetched) == 0) { IBindCtx ctx; CreateBindCtx(0, out ctx); string runningObjectName; monikers[0].GetDisplayName(ctx, null, out runningObjectName); Marshal.ReleaseComObject(ctx); object runningObjectValue; runningObjectTable.GetObject(monikers[0], out runningObjectValue); if (!rotTable.ContainsKey(runningObjectName)) rotTable.Add(runningObjectName, runningObjectValue); } return rotTable; } public static IDictionary<string, _DTE> GetRunningVSIDETable() { IDictionary<string, object> runningObjects = GetRunningObjectTable(); IDictionary<string, _DTE> runningDTEObjects = new Dictionary<string, _DTE>(); foreach (string objectName in runningObjects.Keys) { if (!objectName.StartsWith("!VisualStudio.DTE")) continue; _DTE ide = runningObjects[objectName] as _DTE; if (ide == null) continue; runningDTEObjects.Add(objectName, ide); } return runningDTEObjects; } }
Wednesday, November 01, 2006 4:40:07 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

The Microsoft Patterns & Practicess Team recently released a new version of the Web Client Software Factory that can be found on CodePlex. One of the things I noticed directly, is that they implemented a web version of the Composite UI based on the ObjectBuilder.

The goals of Web Client Software Factory are:

  • CAB for Web
    • Hiding complexity
    • Separation of infrastructure & biz logic
    • Biz logic reuse amongst different UI Technologies
    • Promoting consistent development practices
  • Navigation
  • UI Richness
  • UI Layout management
  • State management
  • Best use of technology available (Ajax, WinForms controls, ...)
  • Security
  • SaaS implications on application design

More information about the vision & scope can be found here.

Wednesday, November 01, 2006 2:37:11 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Thursday, October 26, 2006

On IStaySharp.NET I created an article that shows you, how you can load a DSL file. This is necessary if you need to access your model from GAT, a Visual Studio AddIn, custom library, etc. The last couple of weeks I am digging into DSL and GAT for creating a set of software factories at Real Software that will be used as a baseline for building applications.

Learning two (DSL & GAT) simultaneously and combining them was not so trivial and there is some learning curve. For GAT there are some interesting resources:

The MSDN forums is a good resource when you have some issues and/or questions. DSL has also a specific forum. The capabilities of DSL are really impressive. Now you have finally the tools to write for example your own dataset designer with code generation!!!

Thursday, October 26, 2006 1:07:20 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Monday, October 23, 2006

Version 0.22 of SyntaxColor4Writer is compiled against the new build release of Windows Live Writer 1.0 (Build 145). The issues around spell checking and FireFox will be fixed in the next release.

Monday, October 23, 2006 8:31:23 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Wednesday, October 18, 2006

Last week I bought an external harddisk, Vantec Nexstar 3 (NST-360SU-BK), that can be connected through USB 2.0 and eSata. eSata is simply a new standard for connecting external SATA drives at full speed! I use the external harddisk to share data between my laptop (through USB 2.0) and my desktop PC (through eSata). I use extensively Virtual PC for development, and it's a good thing when developing on my desktop PC I can use the full speed of my HD. 

Wednesday, October 18, 2006 10:46:39 PM (Romance Standard Time, UTC+01:00)  #    Comments [1] -

 Thursday, October 12, 2006

Microsoft released the beta program for Virtual PC 2007. The new features are

  • Hardware-assisted virtualization
  • Support for Windows Vista as a guest and host operating system
  • Support for 64-bit host operating system

You can participate on the beta program through the Microsoft Connect web site.

Thursday, October 12, 2006 12:40:33 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

 Friday, October 06, 2006

I've upgraded SyntaxColor4Writer with the new version of CodeHighlighter 4.0. It uses a new parsing model and it supports some additional language definitions, namely:

  • Assembly
  • Lua
  • MSIL
  • Pascal

For example:

HasChanges method of a DataSet in MSIL - Copy Code
1 .method public hidebysig instance bool HasChanges() cil managed 2 { 3 .maxstack 2 4 L_0000: ldarg.0 5 L_0001: ldc.i4.s 28 6 L_0003: call instance bool System.Data.DataSet::HasChanges(System.Data.DataRowState) 7 L_0008: ret 8 }

Any suggestions and/or feedback about SyntaxColor4Writer is welcome!

Friday, October 06, 2006 1:07:46 AM (Romance Standard Time, UTC+01:00)  #    Comments [5] -

 Thursday, October 05, 2006

A new version of CruiseControl.NET has been released. The release notes of version 1.1 can be found here. This is the defacto standard tool if you want to continuous integration together with unit testing, code metrics, code analysis, etc.

Thursday, October 05, 2006 12:48:25 PM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

Recently I switched from RSSBandit to GreatNews as RSS reader (noticed by a post from Bert Jansen).

The speed for aggregating feeds using GreatNews is really fast! I think it was better called SpeedNews ;). Besides that, it has a nice user-interface and all config & feed data is kept in the installation folder. This means that no installation (MSI) is required, and that it can easily be deployed to other computers.

Thursday, October 05, 2006 2:31:16 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -
 | 
 Friday, September 29, 2006

Today I published a new version of SyntaxColor4Writer on IStaySharp.NET. It's compiled against the new beta version of Windows Live Writer with the following added features:

  • 'Copy Code' link (copies everything to the clipboard)
  • Caption text
  • Customize backcolor, including line numbering
  • Spaces in tabs
  • Font size

     

    Below you find some examples:

    1 <system.web> 2 <compilation defaultLanguage="VB" debug="true"/> 3 <customErrors mode="ReadOnly"/> 4 </system.web>

    C# code of the Main method class.

    Program.cs - Copy Code
    1 /// <summary> 2 /// The main entry point for the application. 3 /// </summary> 4 [STAThread] 5 static void Main() 6 { 7 Application.EnableVisualStyles(); 8 Application.SetCompatibleTextRenderingDefault(false); 9 Application.Run(new TestForm()); 10 }

  • Friday, September 29, 2006 1:12:38 AM (Romance Standard Time, UTC+01:00)  #    Comments [0] -

    Navigation
    Archive
    <January 2007>
    SunMonTueWedThuFriSat
    31123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910
    About the author/Disclaimer

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008
    Christoph De Baene
    Sign In
    Statistics