Visual Studio 2010 and ALM

Today I was lucky enough to attend a Microsoft / Black Marble event at Edinburgh Waverly Gate on Visual Studio, Team Foundation Server (both 2010) and the general Microsoft ALM approach.

I have been using Visual Studio 2010 and Team Foundation Server 2010 since the Beta 1 days (for both!), so have a good knowledge of them both, but figured it was a good idea to go along and see what I was missing.

And it was worthwhile.

TFS and VS integrated beautifully. You really could not wish for a better combination.  TFS provides an amazingly extensible foundation for your company to base its source control on – but don’t be fooled – TFS is not just another Subversion. It offers the end to end ALM solution – full User Case, UML diagrams for planning, Work Item and resource tracking all built into a warehouse architecture expertly exposed through a combination of Reporting Server and Sharepoint (that hurts me to say … you know how much I dislike Sharepoint!).

One of the most manager friendly functions added in 2010 is the ability to link query data out from TFS to Office products – from Excel to Project, your line manager can now manage you in their comfort zone. Maybe it’s a good idea, maybe not. One thing that was mentioned today was that anything that stopped them constantly asking “how’s it going” was probably a good. Now that is something I can certainly agree with! Getting decent reliable information out to project stakeholders has always been a challenge.

The demonstration of the new Microsoft Test Manager was very impressive too – finally something to allow us to document test scripts (you know those things that you get testers to follow, right?) and have an easy to use framework the testers can use to step through them (and it captures bugs – complete with relevant tracing information!) is incredible. Oh and it all links back to TFS and your dev team. Imagine it, dev’s talking to testers. Whatever next? Removal of management? Maybe not – someone has to read the reports after all :)  What they DO have coming is automated testing – macro-esque based visual UI testing. Currently only available for Winforms app and ASP.NET websites, but reliably confirmed as hopefully getting Silverlight support for RTM. I’m waiting with baited breath – this could potentially save me a LOT of hassle.

Blend SketchFlow is pretty impressive for mock applications too … but I still don’t see it being able to unseat the larger one’s out there in this niche market, such as Axure.

The one thing that seems to missing in all of the ALM solutions I’ve used in my career so far is an effective Release management tool.

But more on that later :)

Silverlight, Cross Browser issues with GetElementById

I’ve recently spent some time tracing cross browser issues with Silverlight 3, and one in particular irked me a little.

With one project, I used the HtmlPage.Document.GetElementById managed code to get information (and ultimately set them) in HTML pages.

However, it seems this does not work properly with Chrome and Firefox. On the surface it all seems to work fine, however, settings values definitely was not working as it should.

So, the work around is a basic JavaScript function such as :

function getValue(elementName) {
var result = document.forms[“formhere”].elements[elementName];
if (result != null) {
return result.value;
}
return “”;
}

And then calling out to this using HtmlPage.Window.Invoke(“doSomething”);

This works :)  A bit messy, but at least it DOES work reliably, unlike the built in GetElementById. Here’s hoping it’s fixed in Silverlight 4.

Code Regions - Their use and misuse

Over the last few evenings I have been reviewing code done by a fellow developer, and have come to a conclusion.

The .NET code regions (aka Collapse Regions, Collapsible blocks and dear god knows what else in other languages) can really be misused.

Correct use of regions can group common sections of code – for example code that all interacts with the same property (you might have the property itself and also a number of private functions that work with or derive from the property), for improving readability (yes, we all know that we should not have units / classes that size but we all have right?) and generally for being neat (it is cool seeing it all shrink down isn't it?). BUT, likewise you can seriously go overboard.

This code in question has many levels of nest regions, and although it certainly does tidy the code up, it certainly does not help it’s maintainability.

I’m sure I’m not alone in the fact that I typically use a lot of keyboard shortcuts when I’m developing, but adding many many many regions, with many layers of nesting, this makes keyboard shortcuts for the region collapse / expand pretty useless. No matter what you do, you always seem to end up with too much or too little code on screen – either way, it makes development difficult.

Which brings onto a final point … if this is the case (i.e. the code is damn near impossible to understand at a glance due to the structuring in place), doesn’t this qualify as un-maintainable code?  Perhaps we should be setting up rules on TFS and the like to detect the layers of nested regions, and flag them for review when it sees someone going to excess?

Comments, as always, welcomed :)

Visual Studio 2010 Beta 2 and November Release of Azure Tools

I’ve just had a slight dance with the new release of the Azure Tools (that adds VS 2010 Beta 2 compatibility), and thought I would quickly note down the issues I hit – and of course the solutions!

First off, as you can expect, a few things have been renamed:

RoleManager is now RoleEnvironment
ILocalResource is now LocalResource

Don’t forget to release the release notes and recreate your local dev storage databases … but watch out – the command is incorrect – the docs are missing a colon! The command should be dsinit /sqlinstance:<instance>.

More Annoying Errors - MS Azure Related (again)

Argh – trying to debug an application locally with the Azure Dev Framework, and got this:

image

Yet another really helpful error message guys. Surely in dev stuff (and CTP’s) it’s worth actually giving lots of error data – at least we might understand it and be able to submit more detailed reports back :)

Quick and Simple list paging in WCF

I had to come up with a quick way to do paging of a List of objects today as we have been hitting the packet limit on WCF – we could have easily increased the limit, but in my opinion this just masks the error and doesn’t actually fix it.

Anyway, the quick solution that I implemented is roughly as follows:

Change the interface definition on the WCF to allow you to pass in a page number

In your Data Access Layer code, take the page number and do something like:

int skipCount = (pageNumber - 1) * pageSize;

foreach (Signup alpha in webDal.Signups.Skip(skipCount).Take(pageSize))
{
// Do something else where
}

As you can see – very simple, no fuss and uses Linq. And in theory it shouldn’t load SQL either thanks to the Skip function.

I believe the RIA Services toolkit is going to have paging in there, but I don’t want to switch everything over right now ;)

Silverlight 3 changes networking stack

One thing that might have managed to slip under people’s radar (and certainly did mine until this morning) is that Silverlight 3 changes the network stack options.

No longer are we tied to having the host browser carrying out the HTTP communication for us (and the subsequent issues with browsers such as Chrome and Firefox) – now Silverlight can natively handle the communications.

This also opens up the use of REST services.

Interesting development – I haven’t had a chance to test it yet, but I’m hoping that it does actually work, and fixes some of the compatibility issues that we have seen.

For more information, checkout http://blogs.msdn.com/silverlight_sdk/archive/2009/08/12/new-networking-stack-in-silverlight-3.aspx

Exceptions In Blend

I am sure that everyone reading this (who has used Microsoft Expression Blend at least) has encountered the following error message:

image

 

You probably groan too when you see it. Where do you start looking … is it XAML related, or is it code …

Well, the answer is actually fairly simple. Debug blend.

Load the project in both Visual Studio and Blend.

Compile it in Blend.

In Visual Studio – attach the debugger to the running process of Blend – click Debug, Attach to Process and select Blend.

Now open the rough control / page / whatever in Blend.

And witness the exception (complete with details!) in Visual Studio.

Happy debugging :)

Silverlight 3 and Binary Bindings

One of the tasks on my todo list has been to switch our Silverlight project at work from basicHttpBindings in WCF to the new Binary Binding – which should hopefully reduce network traffic, improve security etc etc.

I was kind of dreading this task, expecting it to be truly awkward, but in actual fact it was a piece of cake.

Two major steps:

1. Update the web.config file for the service, replacing the binding details with the new structure detailing the binary binding, and changing the endpoint. For example:

The original binding had:

<basicHttpBinding>
    <binding name="Application.Binding">
        <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
        </security>
    </binding>
</basicHttpBinding>

With the endpoint defined:

<endpoint address="" binding="basicHttpBinding" contract="Application.IApplication" bindingConfiguration="Application.Binding">
    <identity>
        <dns value="localhost"/>
    </identity>
</endpoint>

To switch this to binary binding, simply add:

<customBinding>
    <binding name="Application.BinaryBinding">
        <binaryMessageEncoding />
        <httpsTransport />
    </binding>
</customBinding>

And use this new binding as follows

<endpoint address="" binding="customBinding" contract="Application.IApplication" bindingConfiguration="Application.BinaryBinding">
</endpoint>

Note that both of these binding definitions are running on SSL; if you wanted to run the binary binding on http, simply drop the “s” from the line <httpsTransport />.

2. Refresh the service references in Visual Studio.

Thats it!

Visual Studio 2010, Silverlight 3 and a Cryptic Error

For the last few days I’ve been fighting a strange error while porting an application to Silverlight 3 …

Obviously, I had to use Visual Studio 2010 for the work – why not, I’m trying one beta technology, might as well make life interesting eh?
Actually, there are technical reasons why you would want to use VS 2010 for the SL3 development, but I’m not going to discuss them here at this point in time – they have been beaten to death elsewhere on the net.

Anyway, I hit this error message:

Error   3        The "ValidateXaml" task failed unexpectedly.

System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Development\{Project}\{Assembly}.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

File name: 'file:///C:\Development\{Project}\{Assembly}.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework.  This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous.  If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go2.microsoft.com/fwlink/?LinkId=131738 for more information.

Note that I have hidden the project name and assembly name, as it’s for something that I don’t want to expose yet!

The path is not a network path, its local, and it’s a trusted location. I have full admin rights on the machine, so I knew it wasn’t permissions related, but I checked that too just in case.

I was stumped.

Then something hit me this morning. I wonder if it’s a flag on the assemblies themselves. These particular assemblies are 3rd party libraries, and everything we had developed internally was working fine, so I went digging.

Turns out that they had the “block” flag set – this is set by Windows for files that are downloaded from the internet, and apply a restrict set of permissions in some applications such as Internet Explorer, Explorer, HTML Help viewer etc. And it seems Visual Studio / .NET 4.0 beta compiler.

It would be far more useful if the error text actually mentioned it.