Thursday, March 05, 2009
TFS Build Node Problem Fix
Yesterday (in the midst of trying to get some builds done to get to a release), the Build node of my Team Explorer window for all Team Projects under my main user account went stupid and was displaying a red X for unavailable. Very frustrated, I did some searching and found very little other than one post suggesting that killing my user account and recreating it from scratch would clear the problem. That would also have cost me hours of reconfiguring other programs and settings that are customized under my account, so I dismissed that. Based on that though, I went and created a separate user account and was able to run builds from there and switch back and forth with Switch User to get through the day. The sweet thing was that when I fired up VS 2008 this morning and went to Team Explorer with no project loaded, I noticed a bunch of stuff get spit into my output window. Looking closely, it was a nice little error message from Team System telling me the BuildPackage was not being loaded due to previous errors, and if I wanted to have it try again, just launch VS from the command prompt with the following line: devenv /resetskippkgs Worked like a charm and my environment is totally happy again. You gotta love software that detects its own problems and suggests simple things that actually work to fix it. Well done VSTS team!
Thursday, February 26, 2009
Prism 2 Bits Refresh
Update: Great post by Julian Dominguez from the Prism team here that tells exactly what files changed in case you just want to update those in your source control: http://blogs.southworks.net/jdominguez/2009/02/prism-20-download-bits-refreshed-whats-changed/ In case you have already jumped on downloading Prism 2 (Composite Application Guidance for WPF and Silverlight) when it released about a week ago, time for you to go get some fresh bits. There were a couple of minor issues that have been fixed and the download links now have the updated code behind them. So remove what you have for Prism 2, go to the download links and get the latest. In WPF the main thing affected was that certain containers, TabControl in particular, did not bring their View to the foreground with an Activate call on the region. There was also a build issue for Silverlight projects that was fixed. So go get yer fresh hot bits!
Sunday, February 08, 2009
Avoiding Login Dialogs with TFS Remote Access
I’ve been working on a project for a remote customer for a number of months and something that constantly bugged me is the way TFS wants you to log in every time you open your solution or fire up Team Explorer. Unlike other login dialogs in Windows and Internet Explorer, the one presented by TFS does not have the magic checkbox to “Remember my password”. But at some point I did something on one machine and it stopped asking and was logging me in automatically if I was online. Excellent! Now how to get it to behave the same on my other two dev machines? I did a little thinking and realized that TFS just uses HTTP Web Services for it remote access. The team project I was working on was using SSL and a particular port, lets say it was 8089. So I just fired up the browser, hit http://tfs.somecompany.com:8089 and I got the standard IE login dialog which does have the Save password checkbox. Checked that box, got and error of course because the web service is not designed to be used from the browser, but now whenever I hit the team project in VS through opening the source controlled solution or opening Team Explorer, viola it logs me automatically now. 10 seconds of effort on any machine to avoid the repeated hassles of logins. Nice.
Sunday, January 04, 2009
Friday, January 02, 2009
.NET Technical Forecast 2009
Beginning of the year is always a good time for reflection and speculation on what is to come, so I thought I would put a few thoughts out there on what the technical forecast for 2009 looks like to me. I'll do it in the context of some of the key technologies I work with on a regular basis. WCF: Because this got great adoption from the outset, I don't see a huge change in the rate of adoption of WCF. What I do see is more and more use of the REST programming model that came available in .NET 3.5. Unfortunately, I predict that more people will end up using that model instead of SOAP-based messages than probably should, just because it has the hype right now. REST makes a lot of sense for externally exposed, resource-oriented services to put a minimum bar for consumption of data out there. For secure, reliable enterprise services though, you need the additional protocols that the WS-* stack gives you. Consumption of a SOAP based service is also still far easier due to simple code generation of the proxy. So internal services should still be using SOAP in my opinion, but REST makes perfect sense for public exposure of data, whether read only or read-write. Cloud Services: With the Azure platform announced and PDC, the .NET Services piece of that which has been available for a while in CTP form in its previous incarnation as "BizTalk Services", third party vendors building lots of cloud-like services, expansion of the mobile application market with the explosion of iPhone and the chasing touch devices out there, cloud services will certainly grow in importance and early adopter attention, but since a released Microsoft variant will not come until possibly the very end of 2009 or early 2010, most production projects will probably not accept the risk of building against the platform for at least 6-9 months. WF: One word: hesitation. WF has had very low adoption as it is because it requires a pretty significant shift in the way you think about designing your systems as well as how you go about that. Couple that with a number of rough edges in the programming model and the fact that you have to build a fair amount of infrastructure around your solution to run it effectively in production, and you can understand the slow adoption. It is still a vary rich platform for building complex business applications, but certainly can use some improvement. The good news is, that improvement is coming in .NET 4.0, in a big way. At an SDR I attended in the Spring of 2008, I commented to one of the product team members that I was very pleased because they were fixing or improving every single aspect of the WF model that causes difficulty for me or my customers with the current version. The bad news is that to do that, they are making some pretty sweeping changes in the programming and even hosting model of WF. That doesn't mean that you will have to rewrite anything you build today, there is an easy interop story to run 3.5 workflows and activities in the 4.0 model. But it does mean that if you start building on 3.5 now, you will have to learn a set of skills that you will then have to relearn in about a year to start building things the new way. It is not 100% relearning of course, but the changes are sweeping enough that I would guess that 60-70% of the time you spend on the workflow part of your application will be done at least slightly differently in 4.0 than in 3.5. WPF: Adoption should start to take off more than it has in 2008 due to a combination of factors. One of the impediments are the tools, and those are not going to change substantially until VS 2010 comes out (don't know if that will be its name, but it is reasonable speculation to guess that). However, a bigger impediment has been the learning curve, and having companies willing to bite the bullet to acquire those skills. Competitive pressure, both for the companies and the developers themselves, will continue to mount quickly though as more companies ship nice looking WPF apps that demonstrate the ways you can substantially alter the user experience by using WPF. That will help force people to learn the WPF way of doing things to stay competitive. The other factor is Silverlight adoption. With rapidly growing interest and adoption of Silverlight, companies will quickly realize that the skills investment in either WPF or Silverlight cascades to a large degree into the other technology, so that will allow them to build the best kind of app for their users without needing to master two completely different UI skill sets. And finally of course, the closer we get to better tools, the shorter the period of productivity hits you will have to endure by being on WPF, so that barrier becomes less as well. Silverlight: Although there have been some media hits with a public announcement of dropping Silverlight, there have been many more success stories out there due to Silverlight 2, and I think people are really seeing the light there. Some stuff still belongs in web pages and web forms. But for rich interactive applications that are web delivered, you can't beat Silverlight as a platform when you are a .NET developer. Add to that all the cool new stuff coming to enhance Silverlight development in .NET 4 and VS 10, and you have even more reason to make this a first consideration for any interactive web application. The only caution is similar to what I said about REST services. Don't overuse Silverlight just because it is the shiniest new toy. WPF or Windows Forms smart client apps still make sense for a broad assortment of internal corporate type applications. Economic impacts: OK, the market sucks and we are all feeling the impacts in one way or another. But the fact is that the world already runs on software. And short of a total global economic collapse, we can't stop making or at least maintaining software. So I think there is room for plenty of work in our sector even if things get bad. And if you can align yourself with markets that are doing well, then you should be able to weather the storm. So that is about it. Nothing too startling or earth shaking there. But a view through my eyes based on what I see from working with lots of customers around the globe.
Friday, December 19, 2008
Cloud messaging made easy with Linxter
Want to allow different applications to communicate over the Internet without requiring any service infrastructure of your own and without needing to learn and understand the complexities of WCF? There is now a solution that you might want to take a look at. I've been working with a company called Linxter helping them build out a cloud messaging infrastructure that makes building cloud-connected applications even easier than building them using WCF. Basically they have set up the infrastructure and provided an easy to use SDK that encapsulates all the scary code required to really do reliable messaging over the internet, while supporting occasionally connected scenarios, security, reliability, and other aspects. Basically all you do is download the SDK, add a reference to a single DLL, run a tool to generate a supporting database (file based, SQLite), and start making calls. The API is really simple, you just call CreateMessage to send a message, subscribe to an event to know when you have received a message, and there is a one time step to register your program instance with the back end Linxter Internet Service Bus (ISB) infrastructure. So a simple Hello World app could look something like this: // The API is separated into three interfaces focused on
// the three aspects of using the SDK
ILinxterMessaging messaging = new LinxterSDK();
ILinxterRegistration registration = messaging as ILinxterRegistration;
ILinxterCommunicationChannel commChannels = messaging as ILinxterCommunicationChannel;
// Subscribe so received messages raise an event
messaging.MessageReceived += OnMessageReceived;
// One time step in the life of a program instance - register
registration.RegisterProgramInstance();
// Tell the SDK to start retrieving messages based on a configurable schedule
// On demand also supported
messaging.StartScheduledReceive();
// Create a channel to another instance based on an ID or alias name
ProgramInstanceInfo responder =
commChannels.FindProgramInstances("HelloWorld Responder",
FindProgramInstanceType.ByAlias)[0];
commChannels.CreateRequest(responder, "Invitation message");
// Send on demand or on schedule supported
messaging.SendNow();
// Wait for channel to be opened to the receiver
while (!IsOpenCommunicaitonChannels(commChannels, responder))
{
Console.WriteLine("Waiting for comm channel creation");
Thread.Sleep(1000);
}
// Construct a message to send to the receiver, can be many
List<Guid> receivers = new List<Guid>();
receivers.Add(responder.ProgramInstanceId);
// Each message can have an activity ID to separate different message types
string activityId = "b9501157-be9a-4a98-aab6-1c1e17ac8d99";
// The message body is simply a string
// (in which you can encode whatever data you want, however you want)
Guid msgID = messaging.CreateMessage(receivers, activityId, "Hello World");
// Messages are always queued in the client DB supporting offline scenarios well
messaging.SendNow();
Then of course you need the event handler that receives the messages: static void OnMessageReceived(MessageReceivedEventArgs e)
{
Console.WriteLine("\nNOTICE: Message Received: {0}", e.Body);
}
There is a lot more to it of course, but the point is that you can integrate Linxter into just abobut any kind of .NET program including smart client applications, web applications, and Windows services. You don't have to learn anything about how to get the distributed messaging done, they have done all the work for you.
Eventually there will be support for using Linxter in other platforms, so it can form the glue to integrate applications from different platforms.
Of course you could do these things yourself with WCF and .NET services, but to do it that way you would have to master a much more demanding set of skills and may have to set up some infrastructure of your own. With Linxter, you just need a reference to a library, a few method calls into that library, and an account and your applications can be connected really quickly.
If you want to learn more, you can visit the Linxter Developer site at http://linxterdeveloper.com. You can download the SDK and QuickStarts there as well.
Linxter should be releasing version 1.0 by early 2009, so that is another advantage for the near term compared to building it all yourself with WCF and .NET Servicces.
Check it out and you can give me any feedback, which I can pass along to the development team.
Thursday, November 13, 2008
Visual Studio Connections Slides and Demos
I gave three talks at Visual Studio Connections in Las Vegas this week: - Selecting the Right Client Technology
- This session summarized the capabilities, pros, cons, and influencing factors for deciding between smart client or web, WPF, Windows Forms, ASP.NET, Silverlight and Mobile. It also summarized the client software factories and guidance from Microsoft p&p at the end.
- Leverage Routed Events and Commands in WPF
- This session covered how routed events and commands work in WPF, how to hook them up, how to handle them, how to implement custom commands, and best practices for employing them.
- Developing Service Oriented Workflows
- This session covered building workflow services with WF and WCF. It covered the Send and Receive activities, context bindings, and Workflow Service Host. I showed using workflows as a business process orchestration that calls other services, multiple clients calling into the same workflow, implementing custom send activities to overcome the limitations of the built-in Send Activity, and calling between workflow instances.
You can get the slides and demos for all these sessions here.
Sunday, November 09, 2008
The Truth about Routed Commands Routing
In my article on Routed Events and Commands in the September MSDN Magazine, I made a quick reference to a very subtle, confusing, and misunderstood aspect of how routed commands are actually routed. It was only a brief reference because it was only made clear to me through some excellent tech review feedback from the Product Team (thanks Dwayne and Varsha!) a couple days before going to print, so I couldn't add a big explanation without trashing the print flow for the magazine. I had a question from a reader who is a well known WPF expert himself, so I figured I'd better expand my explanation. The short simple answer if you don't want to understand all the complexities of what is going on under the covers is this: Always put your command bindings on the root element (Window or Page) and your command binding will always be consulted. You can do this explicitly in the XAML, or you can inject it there through CommandManager.RegisterClassCommandBinding. But if you want to deviate from that guidance, you really have to understand the following. With WPF routed commands, routed events are used under the covers to dispatch calls to the command handlers both to determine when the command should be enabled, and to invoke the handling for that command when the command is invoked. For example, if I have a Save button in a toolbar, and I have a command binding at my Window root level, a routed event will be used to ask the CanExecute method of that binding if the button should be enabled. And then when the user clicks it, a routed event will be used to call the Executed method of the command binding. Where things get confusing is if you try to place that command binding somewhere deeper in the visual tree because you have to have a good understanding of where the routed events are started and where all they flow to. There are a lot of people that believe (myself included until Dwayne and Varsha from the product team showed me the light) that the routed events for commands flow from the focused element to the root of the visual tree with tunneling and bubbling events. That is really only a part of the picture. The fact is that the routed events for a routed command ALWAYS are initially raised on the command invoker or source control, not the focused element. Any control that implements the ICommandSource interface can be a command source. This includes buttons (and checkboxes... anything deriving from ButtonBase), menu items, hyperlinks, and input bindings (i.e. keybinding) out of the box in WPF. These events follow the standard pattern for routed events in WPF - a tunneling event is routed down the visual tree from the root to the target and then a bubbling event is routed up the visual tree from the target back to the root. The focused element in the UI only gets the events routed to it if the command source is contained in a focus scope (the Toolbar). When that is the case, as the bubbling event reaches the focus scope boundary, the event is re-raised on the focused element. So what is a focus scope? A focus scope is any container element that sets the FocusManager.IsFocusScope attached property to true. Toolbars and menus have this property set, so those are the main focus scopes you will deal with other than a Window or Page which is always the root focus scope, but you could easily create your own by setting that property to true on a container control. So in my Save button example above, the flow looks like this when the button is clicked: - CommandManager.PreviewExecuted tunneling event raised on the Save button in the toolbar. This means it starts at the root element of the visual tree and tunnels down to the Save button through whatever element tree is in between.
- CommandManager.Executed bubbling event raised on the Save button in the toolbar. This means the bubbling event flows from the button up to the root element of the Toolbar.
- CommandManager.PreviewExecuted tunneling event raised on the focused element in the root UI.
- CommandManager.Executed bubbling event raised on the focused element in the root UI.
To make it even more concrete, I wrote a little form whose element tree looks like this with several sources of the Cut command: <Window x:Class="CommandFlow.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<DockPanel>
<ToolBar DockPanel.Dock="Top" Height="30">
<Button Width="75" Height="25" Command="Cut">Cut</Button>
</ToolBar>
<StackPanel>
<Button Width="75" Height="25" Command="Cut">Cut</Button>
<TextBox Width="150" Height="25"/>
</StackPanel>
</DockPanel>
</Window>
I then added attached event handlers for the PreviewExecuted and Executed events to each element in the tree and did a Debug.WriteLine so it would be very clear where the Executed events were flowing. I then ran it, put the focus in the Textbox, and clicked the button in the toolbar. The result is below.
Window Preview Executed Called
DockPanel Preview Executed Called
Toolbar Preview Executed Called
Toolbar button Preview Executed Called
Toolbar button Executed Called
Window Preview Executed Called
DockPanel Preview Executed Called
StackPanel Preview Executed Called
Textbox Preview Executed Called
As you can see, a tunneling (Preview) event works its way down from the root element to the Toolbar button that is the command source, followed by a bubbling event back up. The important thing to notice here though, which is where the confusion about how the focused element is involved, is that the bubbling event seems to have stopped after firing on the toolbar button, and then a new tunneling event is raised which tunnels down to the Textbox and ends.
What is happening is that the Toolbar is actually handling the bubbling Executed event (Handled = true), which stops the bubbling process. The CommandManager then re-raises the event on the focused element (Textbox) and a Preview event tunnels down to it. The Textbox has an internal handler for the Cut command, so that is why nothing bubbles back up from there.
If that wasn't confusing enough, you then also have to look at what goes on for command enabling. The CanExecute part of ICommand has a similar pair of tunneling and bubbling events that fire. They too always get raised on command source controls first. These events are triggered by things that change the focus of the UI. If there is more than one command source, each one gets consulted in turn. Then the path to the focused element in the UI gets consulted. Below is the sequence of events after the UI is up and idle, then I click in the Textbox to set the focus there.
Window Preview Can Execute Called
DockPanel Preview Can Execute Called
StackPanel Preview Can Execute Called
Window button Preview Can Execute Called
Window button Can Execute Called
StackPanel Can Execute Called
DockPanel Can Execute Called
Window Can Execute Called
Window Preview Can Execute Called
DockPanel Preview Can Execute Called
Toolbar Preview Can Execute Called
Toolbar button Preview Can Execute Called
Toolbar button Can Execute Called
Window Preview Can Execute Called
DockPanel Preview Can Execute Called
StackPanel Preview Can Execute Called
Textbox Preview Can Execute Called
So the bottom line to me is this: it is very difficult to explain and understand where the events are flowing in even a simple UI, let alone a very complex one. Trying to rationalize that in your development process to put command bindings anywhere except on the root element is the path to command routing hell. You are better off just always placing your command bindings on the root element, or if you don't want to do that, consider using Prism Commands which get the handlers decoupled from the visual tree and the focus. If you are a control developer, and you need to handle commands (such as Cut) that are inherently coupled to whether your control has the focus, then putting command bindings in your control will also make sense.
I hope that helps to clarify the magic that is happening under the covers of routed command routing.
|





| August, 2010 (5) |
| July, 2010 (6) |
| June, 2010 (8) |
| May, 2010 (2) |
| April, 2010 (2) |
| January, 2010 (1) |
| December, 2009 (3) |
| November, 2009 (2) |
| October, 2009 (3) |
| September, 2009 (3) |
| August, 2009 (2) |
| July, 2009 (3) |
| May, 2009 (3) |
| April, 2009 (2) |
| March, 2009 (1) |
| February, 2009 (2) |
| January, 2009 (2) |
| December, 2008 (1) |
| November, 2008 (2) |
| October, 2008 (5) |
| September, 2008 (4) |
| August, 2008 (2) |
| July, 2008 (1) |
| June, 2008 (2) |
| May, 2008 (2) |
| April, 2008 (3) |
| February, 2008 (6) |
| January, 2008 (3) |
| December, 2007 (1) |
| November, 2007 (1) |
| October, 2007 (5) |
| September, 2007 (1) |
| July, 2007 (3) |
| June, 2007 (8) |
| April, 2007 (2) |
| March, 2007 (4) |
| February, 2007 (1) |
| December, 2006 (2) |
| November, 2006 (9) |
| October, 2006 (5) |
| September, 2006 (3) |
| August, 2006 (2) |
| July, 2006 (4) |
| June, 2006 (5) |
| May, 2006 (10) |
| April, 2006 (4) |
| March, 2006 (2) |
| February, 2006 (12) |
| January, 2006 (7) |
| December, 2005 (2) |
| November, 2005 (15) |
| October, 2005 (6) |
| September, 2005 (7) |
| August, 2005 (3) |
| July, 2005 (10) |
| June, 2005 (11) |
| May, 2005 (7) |
| April, 2005 (8) |
| March, 2005 (6) |
| February, 2005 (2) |
| January, 2005 (6) |
| December, 2004 (3) |
| November, 2004 (5) |
| October, 2004 (2) |
| September, 2004 (5) |
| August, 2004 (13) |
| July, 2004 (6) |
| June, 2004 (14) |
| May, 2004 (17) |
| April, 2004 (12) |
| March, 2004 (8) |
| February, 2004 (10) |
| January, 2004 (14) |
| December, 2003 (9) |
| November, 2003 (13) |
| October, 2003 (3) |


Sign In
|