Latest Replies
Saturday
Jun212008

Visual Studio 2005 could freeze on ASPX files

If VS 2005 stops responding when opening ASPX (or other web related files), do not blame any add-in, try to uninstall/repair everything (including Layered Service Provider stack) or search for VS hotfixes/KB articles. Wasting hours on all that could be of little help.

Just make sure first, that your W3 publication service has not hung up.

This, increased friction and the need to do "Install VS2005 SP1" routine, is the primary reason why I feel I little bit uneasy when there is need to switch back to 2005 for some projects.

Thursday
Jun192008

Memo to self: strip X-Unsent

One more thought about X-Unsent header that could be used to enable simple integration between Smart Client and Outlook Express (which happens to be the default handler for *.eml files on any bare Windows system or even system with Microsoft Outlook).

It seems that X-Unsent is stripped down by the OE on transmission. However, if it is present, then some some spam fighters may consider that this is the trace of spamming attempt that has not been covered up properly. Since it is so easy to check for this rule (as opposed, for example, to running OCR on the attached image), they could do that.

Thursday
Jun192008

I love using Microsoft Project in software development projects

I love Microsoft Project. It is the best tool for managing projects of medium complexity (whether it is construction of 15 floor building, delivering small factory or software project). Ability to automate and extend is great, too (things like templates or custom cost calculation are not present within the product itself but are essential for the efficient work). You just have to follow two rules:

  • Theoretical (PMBoK is just the basics) and practical knowledge of the Project Management is required
  • *Never *let MSP automatically level the resource usage.

And I "love" Microsoft Project Server + Microsoft Web Access. It is a messy process to get the whole thing working even on the fresh server machine (not even talking about the horrible integration with Microsoft SharePoint).

Successfully setting up the whole Microsoft Project Server thing does not guarantee that you will be able to do that again.
Thursday
Jun192008

Information integration - simplest approach for templated emails

Let's talk the code:

var client = new SmtpClient();

var folder = new RandomTempFolder();
client.DeliveryMethod = 
  SmtpDeliveryMethod.SpecifiedPickupDirectory;

client.PickupDirectoryLocation = folder.FullName;

var message = new MailMessage("to@no.net",
  "from@no.net", "Subject","Hi and bye");

// need this to open email in Edit mode in OE
message.Headers.Add("X-Unsent", "1");

client.Send(message);

var files = folder.GetFiles();

Process.Start(files[0].FullName);

Launched Template in Outlook Express

Basically, some desktop SmartClient component generates the template file for the user and then the associated email client is used to open it and send.

Default email client scenarios:

  • Windows: Outlook - does not handle by default, Outlook Express is called instead
  • Windows: The Bat! - message is opened for viewing, hit Shift-F6 and Enter to send

Advantages of the approach are:

  • Reduced complexity: little coding.
  • Free bonus: emails are saved in the outbox, they could be queued for sending or processed by rules
  • Reduced complexity: there is no need to implement email editor, inbox and send routines.
  • Reduced complexity: there is no need for the to manage SMTP settings in the Desktop application (enter, validate, persist, secure etc)
  • .eml format is portable and recognized by numerous email clients

Notes/caveats:

  • Do not forget to add the code to clean-up code your temp folders once in a while
  • It is possible to avoid using this RandomTempFolder thing, but it will require hacking deep into the System.Net.Mail namespace.
  • Although normally email agents understand .eml files, Microsoft Outlook does not do that. Outlook Express is associated with the extension instead.
  • Outlook Express uses X-Unsent flag to indicate incomplete emails and open them in compose mode (thus allowing to send). Yet, it does not always honor this header.
  • Microsoft Outlook can work only with the files like .msg and .oft. These are OLE Compound Files. We were not able to find any efficient .NET approach to generate these (it is assumed that Outlook automation has been out ruled)
Wednesday
Jun182008

Online Analytical Processing with .NET and DevExpress PivotGrid

Now and then I hit situation where some kind of Online Analytical Processing (OLAP) is needed.

In short OLAP is just a way to provide convenient slicing and dicing of some data. You can call it fluent reporting, where the the data-source for the report is fact table and report itself is some kind of aggregation.

There are two simple implementation scenarios of OLAP .NET world that I have encountered so far. In both cases facts table could be simply represented as enumeration of strongly-typed objects (residing DB, memory, flat file etc). And the aggregation is performed via

  • Linq queries against facts data that generate some output. Sorting, grouping, filtering, projecting – all this is done in the code. This output is in fact the aggregation/projection/report (whatever you call it).
  • Pivot Grid controls that are fed with the facts table and are used to let end-users define filtering, sorting etc rules via the UI. The process is less flexible than in the previous scenario, but it does not require any development skills.

I've assembled quick-n-dirty tool for the second type of approach. You can download it here and use to slice-n-dice your raw data (see below for the details).

Simple OLAP tool

To start playing:

  • Download OLAP analysis tool sample and unzip
  • Run, hit “Open” and load “SampleOrderFacts.xml” that comes with the tool.

To create “Total Sales per Product Category” report:

  • Drag-n-drop “CategoryName” to “Drop Row”
  • Drag-n-drop “Total” to “Drop Data”

First report

To create “Employee Sales per Product Category” report:

  • Drag-n-drop “CategoryName” to “Drop Column”
  • Drag-n-drop “EmployeeName” to “Drop Row”
  • Drag-n-drop “Total” to “Drop Data”

Employee sales per product category

To add “Include only orders that ship to USA”:

  • Hit “Prefilter”
  • Hit “+”, then compose “ShipCountry Equals 'USA'”

Edit filter

To load your own facts table:

  • Check out the Sample project.
  • Use XmlSerializer to save array of your facts into file
  • Copy assembly with fact object into the working directory of OLAP tool and reference the type in the OLAP.exe.config
  • Run, hit “Open” and load your file with serialized facts.
  • Have fun
Saturday
Jun072008

How to run free NCover on a 64 bit machine

There is a great code coverage tool called NCover that collects information about the code statements visited during the test execution. It has turned commercial but last free versions 1.5.8 are still available for download (BTW, you can use this service to skip the registration phase).

Additionally there is a great utility NCoverExplorer that excels at parsing and visualizing these code coverage reports. It also provides means to generate HTML reports and integrate them with CC.NET. It went commercial, too, but the last free version is still great.

NCoverExplorer with some LandorSystems code NCoverExplorer report

The only real benefit of the commercial (enterprise!) version for me was the ability to run NCover on 64 bit machine. Otherwise you would get the dreaded:

Profiled process terminated. Profiler connection not established.

Well, it turns out that you do not need to spend money on that. Here are the steps that worked for Windows Server 2008 64 bit (wasted 40mins on that):

  • Find corflags.exe from .NET 2.0 SDK or Microsoft SDK (on my machine it was in E:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin).
  • Execute it against NCover and your unit test runner (nunit-console.exe in my case) executables with /32BIT+ flag. I.e.:
    СorFlags.exe NCover.exe /32BIT+
    CorFlags.exe nunit-console.exe /32BIT+

This will actually force NCover and NUnit to run under WOW64 (x86 emulator that allows 32-bit Windows applications to run on 64-bit Windows).

Additionally, if you have the latest NUnit, you do not even have to modify its executable, just use nunit-console-x86.exe (this one has been compiled to run under 32 bits). Kudos to Cygon for brining this up!

PS: BTW, using Windows Server 2008 64 bit as the primary development environment turns out to be really enjoyable experience.

Saturday
Jun072008

FxCop rules that Microsoft has turned on internally

FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements.

FxCop 1.36 beta

It is really easy to integrate FxCop checks into your continuous integration project. FxCop has command-line processor, also MSBuild Contrib (set of extra tasks for MSBuild), NAnt Contrib (is it still alive?) and CC.NET dashboard provide support for it out-of-the-box.

Here's the sample for FxCop + MSBuild.Contrib

<Target Name="Report">
  <MakeDir Directories="$(ArtifactDirectory)" />
  <FxCop ToolPath="Resource/Tool/FxCop" 
    ProjectFile="MyProject.fxcop" 
    AnalysisReportFileName="$(ArtifactDirectory)/MyProject.fxcop-result.xml" />    
</Target>

However не все йогурты одинаково полезны not all FxCop rules are equally useful. And after enabling full FxCop scan you might find yourself overwhelmed with all these "Correct the spelling" (FxCop has its own dictionary...) or "Do not nest type...". Do not worry, even Microsoft does not use all the rules. Here's the list of FxCop rules that are used internally within the Developer Department.

Basically they have 2 sets of rules - Public Rule Set and Non-Public Rule Set. First one includes the second one.

Additionally you can write custom rules for the tool, but there is no FxCop Contrib project yet.