User Profile

First Name
Last Name

Linq2SQL Debug Visualizer

Tuesday, 15 December 2009

I know I'm just about the last cab off the rank on this one but I think the Linq2SQL debug visualizer is pretty nifty.

 It lets you view the SQL generated by a Linq query while you are debugging in VS2008 - sweet.

 If that doesn't float your boat you can always use the DataContext.GetCommand() or DataContext.Log() and Log() usage

Fluent NHibernate is pretty kickass

Monday, 23 November 2009

This FluentNHibernate stuff is pretty good gear.

One thing to remember is to always specify an Id throught the Id method.

eg

 Id(x => x.MyIdPropertyName);

Otherwise you stand to get an error a little like this:

The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.

Chapter 8 - Application Domains and Services

Friday, 10 July 2009

It's not sexy, it's not exciting. It's AppDomains and Services.

 I use Thread.Current.SetPrincipalPolicy() in every test suite in one project. Interesting to come across the same method attached to AppDomain.

I do like the concept - start an assembly with limited privileges to avoid kicking off a badass mutant ninja experience thanks to a nasty third party assembly vomiting all over your application's sofa. Mixed metaphor's we love 'em.

Certification here I come

Friday, 1 May 2009

I have wanted to do Microsoft Certifications for a few years but always found myself too busy with one project or another. Now, with Skills-Tracker out the door and the next project a Jindalee away I have the time. And thanks to a new MCPD course that I'm going to be presenting I also have the motivation.

Sure Silverlight is the future, but right now?

Tuesday, 24 February 2009

Sure Silverlight is the future, but right now I'm heavily into WinForms and old school ASP.NET. With a tight deadline and a toilet roll of requirements, it's only barely manageable thanks to the uber cool DevExpress control set. 

Although it's sometimes tricky to get on top of the features they provide, and not knowing WinForms inside and out I don't quite know when I really need to hit the DevExpress controls and when to use a standard WinForms component. Generally, I use the DevExpress controls for everything because they've subclassed almost all the standard controls and applied skinning capabilities to them. So I figure I'm not losing out and I'll get a bonus here and there.

Just lately I've run into a limitation trying to get the system to indicate if the data is valid or not.

DevExpress has a DxValidationProvider but it's a little limited so I'm using the WinForms ErrorProvider instead.

What I like about it is that it is a control extender, so when you add it to a form or user control, all the data-bound controls gain a few extra properties that are related to validation - snazzy. I like extenders. In the ASP.NET world they are a godsend for being able to emit reasonable HTML.

In this particular case I can specify whether the 'validation failed' exclamation icon appears on the right or left hand side of the input box - sweet.


And because I'm binding to CSLA.NET business objects their validation rules are automagically compared to the data being entered by the user whenever a property changes. Specifying the rules in the business object means no UI validation coding from me - I like it!

protected override void AddBusinessRules()
{
  AddCommonRules();

  //Hiding - Add less common rules (eg for interdependent propeties)

}

private void AddCommonRules()
{
  ValidationRules.AddRule(Csla.Validation.CommonRules.StringMaxLength,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FirstName", 15));
  ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired,
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Surname", 150));
}

DevExpress say that their next release will see the DxValidationProvider get some icon alignment goodness - we'll see.

Silverlight - is it the future of .NET UI development

Wednesday, 18 February 2009

I did a presentation on Silverlight at the HDNUG meeting last night. The question we debated towards the end of the meeting was - is Silverlight the future for .NET UI development. Most people said no - one or two said yes. I said 'yes'.

But what was I thinking! The only way that Silverlight will become the .NET UI development tool of choice is if Microsoft builds a cross-platform standalone Silverlight host so we can use it instead of the web browser. This is what Adobe has done with AIR. It provides an environment for Flash/Flex applications. It provides an abstraction of the underlying operating system so that a Flash/Flex application can run just as easily on a Windows system as a Mac. If that's not available to Silverlight applications then there's a big opportunity missed. That narrows the scope for .NET development to browser-hosted ASP.NET or Silverlight apps versus WinForms or WPF. And the decision is all too easy for most people judging by our discussion last night.

Noone had any qualms about saying that Silverlight would take over the mantle from Ajax for ASP.NET in the online space. In a desktop world though, there was not much of a vibe for Silverlight.

That's not too surprising. For Silverlight to take over from WinForms it would need to beat out both WinForms and WPF. Silverlight's proponents aren't going to have a hard job convincing .NET developers to avoid GoogleGears, AIR, JavaFX and the like. As a rule .NET developers like working with the toolset they know and understand. And AJAX has bruised so many people that if Silverlight gets tooled up it will be flooded with refugees from .NET development projects using any of the Ajax toolkits. It's not that they don't work, it's just that it's difficult to get sophisticated Ajax UI's that are consistently responsive and let the processors do something other than service the browser at 99%.

But, if your application only has to run on a Windows desktop then in the future WPF is going to be the simple choice. Simple as in, just my app and the OS, no need for a browser to get in the way and cause me pain.

So, is Microsoft going to deliver a Silverlight host outside of a browser plug-in? I'm not full of beans on this one. Would it be fantastic to be able to develop an application that you could deploy over the intarweb and have it run on the users device inside or outside of the browser? Yes. Maybe somone else will do the job (hello Prism).

Currently, Silverlight runs in a browser - lots of browsers in fact. That's a bit of a pain in terms of resources and screen real estate (chrome) and certainly reduces the quality of the user experience. Lets take one examnple - the browser Back button. If your application is hosted in a browser there's almost a guarantee that the user will click the Back button at some point and expect to be able to just click the Forward button and return to where they were. But supporting those two simple actions can be incredibly difficult. Issues like this make the browser hosted approach too much for many projects.

So, for most applications it makes more sense to run in a stand alone environment => goodbye Silverlight, hello WinForms/WPF, goodbye cross-platform support. That provides a nice tie-in to Windows while we all wait for GoogleGears, AIR, etc to play out their strategies.


Visual Studio 2005 Add Data Source Wizard - Illegal characters in path

Monday, 9 February 2009

Oooh I'd love someone to tell me what's going wrong here with the Data Source Wizard in Visual Studio 2005

I'm trying to add a Data Source using the Add Data Source Wizard and the dialog just crashes while populating the list box...

The error message is:

---------------------------
Wizard Form
---------------------------
An unexpected error has occurred.

Error Message: Illegal characters in path.
---------------------------
OK  
---------------------------
 

It looks kinda like this:

Google searching hints at 'Visual Studio 2008 Orcas release' installed alongside VS2005 being a problem... Funny cos that was the label on my VS2008 splash screen for a while but now it's changed to just Visual Studio 2008.

 

And it seems to be just one project in my solution. Other projects can have Data Sources added just fine...

And now, all is well, with a restart and this update applied - "Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86"

Of course it's not a big deal to add a data source by copying an existing .datasource file or creating a new one in \Properties\DataSources\ and inserting a corresponding entry into the relevant .csproj project file.

Here's the structure of a .datasource file:

<?xml version="1.0" encoding="utf-8"?>
<!--
    This file is automatically generated by Visual Studio .Net. It is
    used to store generic object data source configuration information. 
    Renaming the file extension or editing the content of this file may  
    cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="MyClass" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
   <TypeInfo>MyReferencedLibrary.And.NamespacePath.GoesHere.MyClass, MyReferencedLibrary.And.NamespacePath.GoesHere, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

And here's how the line looks in the MyReferencedLibrary.And.NamespacePath.GoesHere.csproj file:

<None Include="Properties\DataSources\MyReferencedLibrary.And.NamespacePath.GoesHere.MyClass.datasource" />

This should appear in the <ItemGroup> element containing the list of projet file items eg classes, resources, properties.


.Net project location is not trusted

Saturday, 7 February 2009

Go figure, this is still a gotcha!

I remember being caught out with an annoying dialog a year or two ago, when I opened a Visual Studio solution that I had downloaded in a zip file. The dialog box message was '.NET project location is not trusted'.

The solution isn't provided on MSDN. They go into detail about security policies and the like. Fortunately the answer is simple, modify the properties of the zip file. Right click on the zipped file in in Explorer and click the Unblock button.

Then unzip the files. Open in Visual Studio. Dialog box no more.

Thanks to: Stephen Cawood, James Kovac and Chris Craft

S#arp Architecture

Friday, 18 July 2008

hehe - one to follow up - I like it.

SharpArchitecture

Performance Testing ASP.NET applications

Wednesday, 25 June 2008

Some ASP.NET performance testing links emphasising WCAT: 

 

ASP.NET Debugger Timeout In Windows Vista

Monday, 23 June 2008

Another hat tip to someone who did the hard yards before me and provided a solution... 

My reasoning for duplicating this info is that it'll help others to Google it.

There's really not much to add to this Vault of Thoughts - .NET Blog piece.

I was experiencing the same problem, while debugging with Visual Studio 2005 on Vista I'd noticed that sometimes I lost the debugger session. It would just stop. It seemed to occur after I held up execution for a while but it didn't seem to be the same amount of time every time...

Turns out that IIS 7 in Vista has a simple health monitoring check that ensures the worker process is responding to requests by sending a periodic PING request.

ASP.NET Debugger Timeout In Windows Vista 

 This is configured by setting:

  1. Ping Enabled = true
  2. Ping Maximum Response Time = timeout value in seconds
  3. Ping Period = interval between ping requests in seconds
And the fix: Either set Ping Enabled = false or increase Ping Maximum Response Time to a convenient value to avoid the debugger stopping inconveniently.



.NET Date Format String Links

Thursday, 12 June 2008

Automatically labelling builds with CruiseControl.NET

Monday, 19 May 2008

If you use your continuous integration server's build number and/or your source control system's revision number in your assembly's version number it's not easy to generate the right assembly version info with automated builds.

With CruiseControl.NET you can use the labeller block to specify how your build label is generated.

I'm just using the default method which increments the existing build label by one on each successful build.

I'm also determining the current revision number in my source control system of choice Subversion and assigning that to a property called svn.revision.

The really useful part comes with NAnt's <asminfo> task:

            <asminfo output="VersionInfo.Designer.cs" language="CSharp">
                <imports>
                    <import namespace="System" />
                    <import namespace="System.Reflection" />
                </imports>
                <attributes>
                    <attribute type="AssemblyVersionAttribute" value="${CCNetLabel}.${svn.revision}" />
                </attributes>
            </asminfo>

 This task generates a file called VersionInfo.Designer.cs and drops it into the CruiseControl.NET WorkingDirectory.

You will need to reference this file from your assembly's project. Then the version of the assembly will be set for you when the project is built by the next task in the build process.

How do I do that? Well, if you take a look at any .csproj file you will see the file paths are generally relative to the project file. Think the best option is to add a file to the solution as a solution item called VersionInfo.Designer.cs. Then set it's content to something like this:

using System;
using System.Reflection;

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.832
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: AssemblyVersionAttribute("1.0.0.0")]

Version info for any assemblies created by development team members will be distinct from the assemblies generated by the build server because the last three characters will always be '0.0' rather than say '121.3880'.

On the build server this file will be overwritten by the generated file and the assembly version set.


How To: Determine the version of Visual Studio installed

Tuesday, 13 May 2008

Do I have Visual Studio 2005 Service Pack 1? Or even the Vista Compatibility Update?

Take a look at Visual Studio Help:
  • Help > About Microsoft Visual Studio

Service Pack 1 gives Version 8.0.50727.762. The version before SP1 will be 8.0.50727.42

With the Vista Compatibility Update the version will be Version 8.0.50727.867 (vsvista.050727-8600)

How To: Specify a char from ASCII code

Saturday, 3 May 2008

Do you want C#:

char char1 = 'Z'; // Character literal
char char2 = '\x0058'; // Hexadecimal
char char3 = (char)88; // Cast from integral type
char char4 = '\u0058'; // Unicode

 Or VisualBasic.NET:

Dim associatedChar As Char ' Returns "A".
associatedChar = Chr(65) ' Returns "a".
associatedChar = Chr(97) ' Returns ">".
associatedChar = Chr(62) ' Returns "%".
associatedChar = Chr(37) 

From  Yahoo! Answers

1 2