Infosys Microsoft Alliance and Solutions blog

Main

September 11, 2013

Dispatcher in WPF: Under the hood

I was skimming through some of my blogs that I had shared internally with my team and came across this one WPF Dispatcher. While as part of our work, we don't actively focus on WPF anymore, but I thought the concepts I explained here will still be very relevant for those who are still working with WPF.

Continue reading "Dispatcher in WPF: Under the hood" »

August 30, 2010

Silverlight Error 2103

Recently while trying to integrate an existing Silverlight component into my ASP.NET based application, I got error 2103 "Message: Invalid or malformed application: Check manifest". Online search resulted in almost similar answers everywhere that talked about a change in project namespace and not correctly reseting the startup object.

Continue reading "Silverlight Error 2103" »

July 20, 2010

WPF - Disabled look for Button

If you check online forums, one of the issues that has caused possibly most grievances is the styling of the WPF button control. You set some property values for things like foreground color and background color and when you run the application things don't always work out. Either the button will show some default animation when having focus or will not use the specified background when is in disabled state.

Recently a colleague was styling a Button control and had a need for custom disabled look and we landed in the same problem. We had set a background color, but when disabled the button will default to the light gray color. Trying various options didn't work out. Interestingly the properties like Foreground or Opacity worked fine. The designer in us said that we can always create a custom style, but the developer in us wanted to know why this doesn't work.

Continue reading "WPF - Disabled look for Button" »

May 19, 2010

Silverlight - Using x:Key or x:Name

The other day I was discussing new features of Silverlight 3 and 4 with a colleague and we were talking about the ability of specifying styles in Silverlight 4 without using the x:Key attribute. To this my colleague responded that he has not been using x:Key at all, but always has used x:Name.

Continue reading "Silverlight - Using x:Key or x:Name" »

May 12, 2010

Working with Images in Silverlight Application

Working with images is fairly straight forward in an Silverlight application and there are already many articles about this on the net. So I am not going to get into that. However recently my team faced an issue and that is what I will share here.

Continue reading "Working with Images in Silverlight Application" »

March 4, 2010

Size of a .net object

While trying to debug a service call, where we suspected a buffer overrun situation, we wanted to find out the size of the object being returned by the service call. However finding size of a .net object is not trivial and if you thought you could do a sizeof(object), then you are wrong. This will only return the size of the object based on the size of each field in object that itself is based on the type of the field. This doesn't returns the size of the object in memory with data loaded into it.

Continue reading "Size of a .net object" »

December 28, 2009

VisualStateManager's Benefits

Many months back I had written about VisualStateManager (VSM) feature in Silverlight. Overtime, MS has been working on streamlining this and new additions are available with Blend 3 to support VSM. VSM got introduced in SL, as some say, mostly to address the lack of triggers, due to which creating control templates was a big issue. Eventually WPF 4 will also start to support VSM. There have been many interesting debates on this, which you can find here, here, here and here, but this parts and states model is here to stay.

Continue reading "VisualStateManager's Benefits" »

October 14, 2009

Silverlight on IE 8

My team members are working on a Silverlight based application to be deployed on Cloud. Things were going smoothly when one of us tried accessing this application via IE 8 and we were surprised to see the application not filling 100% height but taking about 25% space only. We tried various options for setting the height to 100% like setting it for body element, as well for the form element etc, but with not much luck.

Finally, found a workaround on the forum here. Setting the meta tag in the head to enable IE 7 compatibility (<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />) worked. This is surely not the preferred solution, but it got us going. Do share if there are any other options that may have worked for you.

July 5, 2009

Getting File Audit Rules List

Earlier today a friend was trying to invoke GetAuditRules API on a file using c# code, but it was always returning a count of 0 inspite of having set a specific audit rule on the file via windows explorer. The surprising part was that GetAccessRules API was working and the code was running locally so it had full security rights as well.

Continue reading "Getting File Audit Rules List" »

June 11, 2009

WPF - Performing Conditional Validation

When we look at conditional validation needs in WPF, the typical option that people talk about is the usage of UpdateSourceTrigger property in binding expression. There are many examples that one can find on setting this to explicit and managing the validation or things like setting this to PropertyChange when validating textbox input without having to focus out of it.

However there can be scenarios where you can't use explicit since you want the normal two way binding behavior, but have a need to validate based on value of some other control. I had a similar scenario the other day where we had a combo box with yes/no options and the validation had to happen only if a value of "yes" was selected in the combo box.

Continue reading "WPF - Performing Conditional Validation" »

April 24, 2009

WPF, XBAP, Silverlight - What do I use?

Microsoft introduced Windows Presentation Foundation (WPF) with .NET framework 3.0. What started as extensions to Visual Studio (VS) 2005 is a now a in-house native to VS 2008 and the VS 2010 designer is itself getting implemented in WPF (more details in Jason's blog here).

Needless to say that WPF is very powerful new presentation platform that really makes "imagination is the limit" a reality. Designers and developers can now work real closely like never before and create some really super cool user experiences.

Continue reading "WPF, XBAP, Silverlight - What do I use?" »

March 26, 2009

RESTing SOAP

As Service Oriented Architecture is becoming more and mainstream and enterprises start reaping the benefits of implementing them, there is a general trend in SOA implementation that each and every functionality be exposed as web service (read SOAP based service).

Many enterprises and external facing web sites have started following this and getting trapped into unduly excessive larger time to market and in turn losing business opportunities to competitors or else joining another failed SOA initiative.

If you happen to be part of team implementing SOA or following trends in web services implementation, surely you would have come across terms like Service Contracts, Policies, Web Services standards like WS* specifications–> WS- Reliable Messaging; WS-Security; WS-Interoperability; WS- Transaction; WS-policy; Service Discovery, Service registry, Service Governance, Service Versioning, SOAP message structure (header/body/faults), SOAP Protocols, XML Schema, etc..etc.

Each of the above term is quiet heavy and adds to complexity in rolling out web services based large SOA initiatives, however successfully dealing with these complexities fetches several benefits though.

To realize the Enterprise SOA vision and in turn expose functionality as services, does each one of the initiative have to go through this pain of dealing with so many complexities?

Probably not, and hence to address some of these complexities in web services implementation, there is a new style of web services architecture called REST (Representational State Transfer).

Continue reading "RESTing SOAP" »

February 26, 2009

Problem in Debugging .NET Reflection Code

The other day I was delivering a session on .net reflection and during the course of the session there were a few console based demo applications that I was showing to the audience. During one such demo, there was some change in code I did based on a query raised by one of the participants and to show how it worked, I put a breakpoint and happily started to debug.

Murphy, I guess had something against me that day and the debugging just won't work correctly.

Continue reading "Problem in Debugging .NET Reflection Code" »

February 11, 2009

Multiple AppDomains and Loader Optimizations

In my earlier blog Working with Application Domains in WPF, I had touched upon the usage of LoaderOptimization attribute. In recent days I have been playing around with WinDBG and hence thought to see how this attribute really affected to loading of assemblies and memory consumption of the application.

Continue reading "Multiple AppDomains and Loader Optimizations" »

January 27, 2009

Should developers touch XAML?

The other day I hit upon this blog - I hate it when a designer touches XAML.. and honestly I was surprised by the title. To me designers are the ones who should be creating the XAML (may not hand craft it and use tools like Expression Blend), and developers are the ones who should be working on the code behind and writing the backend logic. Hence I felt a more apt title is "Should developers touch XAML?"

Continue reading "Should developers touch XAML?" »

January 21, 2009

Comparing Objects for Equality

What do we do when we want to do something which we haven’t done before? Basic instinct of a developer says that Google and this is what I did. And what was i trying? Write a unit test case to compare two objects for equality. By equality here, I mean similarity of data present int he objects.The objects I had to compare had sub-objects, properties as lists and the usual primitive data type properties. Unfortunately .Net doesn't have any API which compares object for equality.

Continue reading "Comparing Objects for Equality" »

January 7, 2009

Silverlight - EnableRedrawRegions is a savior !

The other day we were ready to deploy an internal facing Silverlight 2.0 built application. As a final round of testing, I thought to put to use the EnableRedrawRegions settings that I had just learnt from Seema's talk in PDC 2008 as part of her session - Building an Optimized, Graphics-Intensive Application in Microsoft Silverlight.

Interestingly, after the application loaded, I could see a small portion in the middle of the page continuously changing colors. It could only mean that this region was getting redrawn again and again. But why? Checking the code we realized that we had some animation at load time and once the data was loaded, the animating panel was just pushed to back in Z order and another panel came on top. But this still meant that the animation was happening, but we could not see it. This EnableRedrawRegions flag really helped immediately identify and remove unwanted animation (we set the panel's visibility to collapsed).

December 15, 2008

Remote deployment of Clickonce application on IIS 7

Recently I was working on a WPF application that was being used by our entire team and I used to keep releasing new builds frequently and it became an issue as I had to inform everyone of the new bits and then they would all install it again. So we decided to go ahead with clickonce type deployment for the application and for this purpose used the wizard that is accessible from the project properties in VS 2008.

Continue reading "Remote deployment of Clickonce application on IIS 7" »

November 24, 2008

Configuring WCF on IIS 7

 We have been on Silverlight (SL) for sometime now on an internal project. During the development, we were mostly relying on the ASP.NET Web server. However for a review when we decided to host the application on IIS, we realized that the WCF service wasn't working on it. The machine was a Vista box with IIS 7 and since .net 3.0 comes pre-installed, we had assumed that WCF will also just work.

Continue reading "Configuring WCF on IIS 7" »

November 21, 2008

Silverlight Theming

If you have been following updates on Silverlight (SL) 2, you would already be aware of SL 2 Toolkit on codeplex. Scott in his blog has shared some amazing numbers on usage of SL and also given some indicators to where SL is headed in its next version.

I had been away from SL for some time due to other focus areas. However I decided to try my hands on the support for themes, a feature added with SL Toolkit.

Continue reading "Silverlight Theming" »

November 17, 2008

Handling Thread Exceptions

The other day someone asked "What is the best way to handle exceptions in a thread method and communicate back to the main thread?" The reason for the question is this - If you raise exceptions from a thread function (which is not the main thread) and if this is unhandled in the thread method itself, it causes an unhandled exception to be raised in the AppDomain and the application terminates.

Continue reading "Handling Thread Exceptions" »

November 3, 2008

WPF: Working with command line arguments

The other day I hit upon this blog that describes how to work with command line arguments and custom file extensions in WPF applications. We have been using this in our application for a while now. I am however surprised to note that double clicking a file required Avi to work with different syntax.

Continue reading "WPF: Working with command line arguments" »

October 17, 2008

Role of Claims based Authentication in Federated Security -- 5 (Zermatt)

Zermatt is the code name of the Single Sign On /Federated Security Solution which Microsoft is planning to offer. This is currently in its Beta. It is a set of classes which helps end users build Security Token Service (STS) of their own and generate the tokens as per their requirement. As long as it fits into the representation standard schema of SAML (Security Assertion Markup Language), the RP (relying party) is capable of understanding the same, the single sign on solution works.

Continue reading "Role of Claims based Authentication in Federated Security -- 5 (Zermatt)" »

October 16, 2008

Role of Claims based Authentication in Federated Security -- 4

I guess with part 3, I hope I have covered all the basics required for understanding Zermatt. Just to recap, Claims represent an identity as a set of attributes which can be anything like Email Id, name, Age, certificate, etc and can come from any source like AD/LDAP, WCS, custom DB, etc. These attributes are very similar to the attributes that exists in AD for any user/machine entry that exists in AD.

In a normal Application based Authentication, Application goes to these repositories like AD/DB to get additional attributes information for Authorization needs. In Claims based Authentication, the user does the Authentication and goes to the Application with Claims (attributes) to the Application (Application never goes to repositories for getting the attributes).

Continue reading "Role of Claims based Authentication in Federated Security -- 4" »

October 13, 2008

Working with Application Domains in WPF

In a few of my earlier blogs, I have written about how one can work with Applications domains (or AppDomain) in a Windows Presentation Foundation (WPF) applications. You can find these

  1. Creating and working with Applications in AppDomains
  2. WPF and AppDomains
  3. WPF – AppDomain – Cannot find type

The information however is scattered across these blogs. I hence decided to consolidate the learning from all of these in a single place so that it is easy for the reader to follow through. You can still go ahead and read the above blogs, or read this one, where I will capture all that I have captured in the earlier blogs with more explanation where possible. Special thanks to Hua Wang from Microsoft for clearing doubts around these concepts.

Continue reading "Working with Application Domains in WPF" »

October 1, 2008

Part 2: Manage Page level states with VisualStateManager in Silverlight

In part 1 we saw how using basic storyboarding/animation capabilities in Silverlight, we created a simple application where buttons move to new location when clicked and move back when another button is clicked. In this part we will see how using VSM, we can build the same capabilities with lesser animations and lesser code. The complete code (including code for part 1) can be downloaded from here - Download file. Note that I have built this using SL 2.0 RC0, but the concepts explained here will work with Beta 2 bits as well.

Continue reading "Part 2: Manage Page level states with VisualStateManager in Silverlight" »

September 30, 2008

Part 1: Manage Page level states with VisualStateManager in Silverlight

Silverlight 2.0 Beta 2 introduced the concept of Visual State Manager (VSM). If you haven't checked it out still, here are some articles that will get you started.

VSM not only helps keep the looks and behavior of a control separate, it allows you to manage the various states the control can be in, along with the transitions, in a very clean and effective manner. Though most of the examples online today show this in context of a specific control and working with its control template, there is no reason why this can't be applied to the UserControl itself, i.e. at the Page level. You can very easily create custom states for your page and manage transitions between the states. In fact this can actually help reduce the total animations that you may have to write and also simplify the backend code.

Continue reading "Part 1: Manage Page level states with VisualStateManager in Silverlight" »

September 29, 2008

Silverlight 2.0 RC0 Installation

You would already be aware of the release of RC0 of Silverlight 2.0. If not check Scott's blog here. The details on the links for downloading these latest bits can be found in the same blog.

Note that unlike the previous Beta 2, this version doesn't comes with a go live license and if you visit the Silverlight installer page online, you will see that it still points to the earlier Beta 2 version (2.0.30523.8).  

Continue reading "Silverlight 2.0 RC0 Installation" »

September 24, 2008

WPF - Displaying enums in ComboBox control

Displaying enums in ComboBox in WPF isn't really rocket science. The issue however comes when you want to display user friendly strings against the enum values. Enum unfortunately doesn't support this by a simple override to the ToString method.

The usual approach people take is the use the DescriptionAttribute. This attribute is assigned to each enum value and at runtime, using reflection, the value of the attribute is queried and is then displayed. The approach is definitely worth considering and I found an implementation of the same and a custom WPF ComboBox that will display such user friendly enum strings here.

Continue reading "WPF - Displaying enums in ComboBox control" »

September 22, 2008

Hiding from Debugger

When writing trivial get/set type properties, I have seen many developers still struggle during debugging since if they do a step into (typically F11), they end up going into the getter and setter methods as well.

Debugger related attributes have been available since early times, but somehow people seem unaware. Typically one can use DebuggerHidden or DebuggerStepThrough attributes, as shown in the following code snippet.

Continue reading "Hiding from Debugger" »

September 8, 2008

How to write custom Main method for a WPF application?

If you have been working with WPF applications you know that the current default behavior for adding the entry point (Main) method is via codegen. You don't write it yourself. The method is generated when you compile your application. A typical WPF project contains App.xaml which is marked as ApplicationDefinition in the csproj file.

Continue reading "How to write custom Main method for a WPF application?" »

September 5, 2008

Targeting .NET framework 3.5 SP1

If you working with VS 2008 you must be already aware about how to target your application to run on different .NET frameworks. With .NET framework 3.5 SP1 now available, I wanted to target my application for this version, but surprisingly VS 2008 doesn't shows this in the list of target .NET frameworks. Harish describes how to get this done. Check it out here.

It would have been much simpler to just provide this option in the existing drop down itself !

September 4, 2008

Debugging into .net source code

You may be aware of the availability of .net source code for debugging. Scott Guthrie had mentioned this along with release of VS 2008. Though Reflector still remains my personal favorite for quickly checking the .net source code during my regular work, it can't help much during debugging.

Recently the .net 3.5 SP1 code was also made available. In case you haven't checked this out, here are the instructions on how you can configure and use this feature from VS 2008. I tried this and it is awesome to be able to debug straight into .net source code and see what is really happening in there. Do note, however, as Shawn also mentions, the initial load time can be pretty high and i had to wait almost 30 min before I could start on with debugging. However since the symbols and the .cs files are cached locally, it is very fast thereafter. Go ahead and give it a try !

August 22, 2008

Reflector needs registration

There will be probably very few out there who haven't heard about Reflector and don't use it. Earlier today I noticed this blog that mentioned Red gate acquiring Reflector. I proceed to the mentioned site. I noticed that the latest version if 5.1.3 and I had 5.1.1. so I clicked the "Download your free copy now!" button.

Interestingly the tool may still be free, but laying your hands on it isn't that easy anymore. You are now required to register to download. This is a bit of a damper. I will eventually register and download the latest, but having to register to get the freely available tool earlier !! I don't like it.

August 21, 2008

WPF- AppDomain - Cannot find type

Sometime back I had blogged about AppDomains in WPF and also later updated this with another blog which mentioned the usage of Dispatcher to shutdown the AppDomain.

Recently in a project where we had to use AppDomain to launch a WPF application, we ran into issues when we had the application refer to external assembly for say some of the controls it was using. Confused? Let's take an example. I have a WPF application DummyApp.exe and a WPF User Control assembly WpfControlLibrary.dll. Now DummyApp uses user controls from this WpfControlLibrary.dll in some of its XAMLs. Finally, I launch this DummyApp.exe from my another WPF application (call it Tester.exe) in a new AppDomain.

Continue reading "WPF- AppDomain - Cannot find type" »

August 14, 2008

My .NET Application Runs

Why would I build an application that doesn't run? Somewhere I recently read about catchy titles and that it helps attract people to read it. So I thought of this title. Hopefully it is catchy enough :-).

Well, if you have been working on .net, you know possibly that .net applications when run from network path, are categorized as LocalIntranet and thus have reduced security priviledges and this causes exceptions when running the application. This has been addressed with .net 3.5 SP1 and now you can run your applications of the network path without issues. Read more about this here and here.

August 12, 2008

WPF DataGrid CTP

Visual Studio 2008 SP1 and .net framework 3.5 SP1 released versions are now available. See here the summary of fixes in this service pack. What is also now available is the WPF DataGrid CTP Release. See here for details on its features. It is available on WPF Codeplex site for download along with some information on WPF Futures.

A sample that Vincent has put together for DataGrid can be seen here. I am going ahead and downloading the DataGrid control. If you are also working with this version, do share your feedback on this control.  

July 10, 2008

Silverlight - Preventing direct editing in DatePicker control

In my earlier blog I mentioned about the custom DatePicker control. Towards the end where I mentioned about making the textbox read only, I also mentioned about not being able to edit this template in Expression Blend 2.5 June CTP. On the forums, someone clarified that since this control doesn't resides in System.Windows.dll, its template cannot be edited in current version of Blend.

One can however include the template as mentioned in MSDN and include that in the project and modify suitably. When I included that in a test project, I ended up with System.Stack.OverflowException. That can however be fixed easily as I mentioned here.

Continue reading "Silverlight - Preventing direct editing in DatePicker control" »

WPF - Text clips on some Vista machines

I love mysteries. So when a project team approached me the other day with an issue with their WPF application, I immediately jumped into it. The issue they were facing was really mysterious. Their WPF application was working and looking fine on all their Vista machines, but when shared with Client, it started to have problems. Text in some controls was clipping.

After trying on multiple machines locally, they found 1 Vista machine where the problem was reproduced. The mystery was that all these machines were using same resolution (1024x768), same dpi (96) and same theme, but text would clip on that 1 machine and work fine on all others. They were about to write this off claiming some issue with Vista.

Continue reading "WPF - Text clips on some Vista machines" »

July 9, 2008

Silverlight - Handling Start and End dates with Custom DatePicker Control

When working with DatePicker controls in application, very typically they get used to manage start and end dates. Like recently I was writing a tracking application in Silverlight and had the need to manage allocation and deallocation and hence start and end dates. There are typical requirements also associated with such implementations like start date cannot be in past, end date cannot be before start date.

Implementing this with Silverlight DatePicker controls was fairly trivial. If you haven't used these controls, you can find an introduction to them here. These controls also offer other interesting properties that I played with namely DisplayStartDate. I then thought that some of things I did in the logic, would be useful in multiple scenarios, so why not create a new custom DatePicker control that will have these functionalities in-built.

Continue reading "Silverlight - Handling Start and End dates with Custom DatePicker Control" »

July 8, 2008

ASP.NET, ASP.NET AJAX and Silverlight - Which way would you go?

Want to develop a web application using Microsoft Technologies? The choice today will revolve around the mature ASP.NET, the upcoming ASP.NET AJAX or Silverlight (Beta 2 currently available). Needless to say that all have their benefits and specific features that make them attractive options to use.

Choice will also depend very much on if the application is internet or intranet facing, so let's talk about internet facing application. Both ASP.NET and ASP.NET AJAX are pretty much server side applications in that most of their logic resides on server side. 

Continue reading "ASP.NET, ASP.NET AJAX and Silverlight - Which way would you go?" »

July 4, 2008

Silverlight - Animating Wrap Panel

Panels, as we know, are pretty much the basis of building any Silverlight application. They help arrange the other Silverlight controls in specific manner like Stack allowing you to stack controls either horizontally or vertically, Grid allowing you to position controls in rows an columns and Canvas giving you a free flow behavior. This blog however isn't however a primer on panels and you can easily find information about them on the net. Check this for information on how to layout controls using these various panels.

At Mix 2008, in one of the sessions the AnimatingStackPanel was demonstrated. I found the code for the same here. I decided to go ahead and try this. However my requirement was for a wrap panel and not a stack panel. I found one here. This would serve my purpose but there wasn't any animation in it. In my earlier work with WPF, I had looked at Kevin's bag of tricks and liked the AnimatingTilePanel.

Continue reading "Silverlight - Animating Wrap Panel" »

Silverlight - Are you missing WatermarkedTextBox?

One of controls that I had been using when working with SL 2 Beta 1 was WatermarkedTextBox and when this was taken off from SL 2 Beta 2, I had to rework our application code. It is great to see the control now posted on Kathy's blog here. The discussion seem to incidate that we won't get the updated TextBox with Watermark property in Silverlight 2 RTM.

I downloaded this, but wasn't able to use it as is since the code continues to use System.Windows.Controls.Extended assembly name. I was using other controls like Calendar and DatePicker from the released System.Windows.Controls.Extended assembly with SL2 and this caused conflict when trying to add the assembly for using WatermarkedTextBox. This was however easily fixed by changing the project properties to create the assembly with the name WatermarkedTextBox.dll. I also had to change the namespace in the WatermarkedTextBox.xaml to the following to get the control working.

   xmlns:local= "clr-namespace:System.Windows.Controls;assembly=WatermarkedTextBox" 

Till the new property is available, this will do !

July 2, 2008

Silverlight - CheckBox issue when in ListBox

Recently for an application I was building on Silverlight 2.0 Beta 2, I had a need to use CheckBox inside the ListBox. Getting the CheckBox into the ListBox item was fairly trivial via the DataTemplate. However the problem started after that.

I could click on the first CheckBox, but when I tried to click on any in the remaining rows, the click won't work. I could easily see the hover effect over the CheckBox so wasn't sure why the click had issues.

Continue reading "Silverlight - CheckBox issue when in ListBox" »

June 25, 2008

Silverlight - Getting Tooltip to work for individual ListBox Items

 The other day for a project work that we were doing in Silverlight 2.0 Beta 2, I was trying to get a tooltip to display for each item in the ListBox control. Things seemed to work fine if the content to be displayed in the tooltip was pretty much static or not dependant on individual items. I mean, I had a need that the tooltip should display different text per item, essentially data bind to some value for each item.

Does this makes sense? I guess it does to me, but you may be wondering about what exactly am I trying to achieve? Let me explain that with sample code. Below is the trivialized version of the code I was working on. There is a list of employees, who I am displaying in a ListBox.

Continue reading "Silverlight - Getting Tooltip to work for individual ListBox Items" »

June 24, 2008

Silverlight - missed compiler error

Recently during my attempts to program with Silverlight landed me with a runtime exception (System.Windows.Markup.XamlParseException) with error as AG_E_PARSER_BAD_PROPERTY_VALUE. Fortunately, the error also provided line and column number in XAML. However when I looked at the XAML, it looked well formed and there wasn't any compilation error as well.

It was then that i realized that the compiler had actually missed catching the fact that I had defined click event handler for a Button in XAML, but not written it in the code behind. Having worked with WPF, I know that such errors are caught at compile time. I am surprised why Silverlight compiler missed this.

 

June 12, 2008

Migrating Comparis Silverlight Challenge App to Silverlight 2.0 Beta 2

With the Silverlight 2.0 Beta 2 now available, I finally decided to take the plunge. So far, I had been focusing on WPF, but knowing that Silverlight is the next big wave for RIA development, I could not stay away longer.

A few fellow colleagues have been working with Silverlight 2.0 Beta 1 and I heard from them that Beta 2 has been a bit of a challenge considering the various breaking changes from Beta 1 to Beta 2. Fortunately these were mostly functional/API issues with Silverlight controls and not like the interesting issue faced by my colleague Kishore with his attempt to work with .net 3.5 SP1 beta. Since I was new, I started with the Comparis Silverlight Challenge Application and the HOL created by Swiss MSDN Team.

Continue reading "Migrating Comparis Silverlight Challenge App to Silverlight 2.0 Beta 2" »

June 11, 2008

Why I Love Working with the Betas...

Software in Betas are generally funny to work with. You never know what would work and what would not, when your machine would crash, what existing applications would stop working. And add on top of everything – lack of documentation. Worse still – incorrect documentation.

Continue reading "Why I Love Working with the Betas..." »

June 9, 2008

Silverlight 2.0 Beta 2

If you have been following Silverlight, you would already be aware that Microsoft released Beta 2 of Silverlight 2.0 last weekend. Check out more details on Scott's blog. The release also includes release of updated extension for VS 2008, Expression Blend 2.5 June Preview and DeepZoom composer. Also check out here for feature listing.

However moving from Beta 1 to 2 may not be a smooth sailing as there are many breaking changes. Read about them here. The list has been further updated and available here.

WPF - Bound property updates before Target property

Recently while answering a query on WPF forum, I found an interesting behavior. In case you have two way binding set on a property, the property to which you bind too, updates before the property to which the bound value is assigned. Check out discussion and a sample on this here.

This seems to similar to another behavior with ComboBox that i had described here.

June 5, 2008

WPF ComboBox SelectionChangedEvent

 When programming with the Combobox and handling its SelectionChangedEvent, you need to be a bit careful. The general expectation will be that when this event fires, the various properties like SelectionBoxItem or Text will give the new value, but that isn't the case.

The SelectedIndex does points to the newly selected item index, but the values of properties like SelectionBoxItem or Text still point to the old values and the new one selection hasn't really been updated. It is only after the event handler code that you write has completed execution that these properties update.

Continue reading "WPF ComboBox SelectionChangedEvent" »

May 13, 2008

WPF Label or TextBlock

Pre WPF days just had a Label control and hence there wasn't really a choice. Now in WPF you have Label and a new TextBlock control. I have been wondering on usually which one to use in the application when i hit upon this interesting comparison between the two by Josh. There is one additional difference mentioned in comments down below on that blog that talk about auto inversion of colors for TextBlock if it is part of say a ListItem. However to me it looked more like setting the Foreground to white, since when i tried with styling the item selection color to something else, the TextBlock still showed white color.

Honestly I am now left more confused. TextBlock is light weight and hence good from app performance perspective, but Label gives the access key functionality, something that people prefer to have in their applications. It will be really good to have this functionality extended to TextBlock.

What is it that you use in your applications and why? Comments welcome. 

April 28, 2008

WPF ObjectDataProvider vs Direct Object Use

When using object instances in XAML, there are two ways to use them. One is to directly create them as resources, assign and key and use where ever required and other is to embed them inside of ObjectDataProvider and then use.

I have worked with both ways and was curious to know the differences between the two and benefit of using one approach over another. I can across this old blog by Beatriz that explain this very well. Along same lines, here is some discussion on XmlDataProvider as well.

April 17, 2008

WPF makes Designers and Developers friends again

I have been playing around with WPF for a while and have been blogging about some of the technical aspects on it. However today I will like to touch upon another important aspect of WPF and that is designer-developer connect.

Having worked on Windows Programming using C++, MFC etc for a decade and working with the various controls, it is a real pleasure to see the capabilities now available to WPF developers. It is true to a large extent that with WPF and XAML and the tools like Expression Blend, designers and developers can work lot more closely than ever before. The working closely is more towards the ability for designers to style the UI for the WPF application and the developers to write the code for it.

Continue reading "WPF makes Designers and Developers friends again" »

April 11, 2008

WPF Data Binding

WPF data binding a very effective way to bind .net CLR objects to WPF UI controls and ensure appropriate updates (by proper use of binding mode and property change notifications). However it can become a bit tricky if not used properly. I recently found these interesting 10 points about WPF data binding. I am sure you would find them helpful as well.

April 10, 2008

WPF - Passing string to ConverterParameter

There are enough online sources that talk about how to buid and use custom Converters in WPF and also how to pass parameters to these converters. However for some reason, all these examples tend to either use a single integer or a single word string. So recently when I had a need for passing a sentence as parameter, I was confused.

Fortunately the simple trick of using single quotes inside of double quotes to provide strings worked in this case as well. Following are two ways you can pass a string that has multiple words to a converter.

Continue reading "WPF - Passing string to ConverterParameter" »

April 4, 2008

WPF - Binding to Image Control

Overtime, I have used different approaches to binding pictures to Image control in a WPF application. I have seen various questions on the WPF forum as well on this topic. The information is all available out there, but scattered. Hence, I decided to create a sample application to demostrate the various scenarios that can exist when you need to use the Image control to display pictures.

Continue reading "WPF - Binding to Image Control" »

April 3, 2008

ASP.NET AJAX Perils

ASP.NET AJAX is come a long way since its inception a few years back and my personal take it is that it in a hype cycle right now, where everyone is trying to jump on-board and create AJAX based applications. Needless to say that it has its own benefits, but there definite downsides to it as well. You can read a set of 10 important aspects around AJAX here.

It is known that though it gives a flicker free UX, the under-the-hood story tells a different tale. Having read about it, some days back, we did a small experiment to really see the kind of differences one can get with different approaches and you can read about our findings in this report (Download file). The scenario we took is very simplistic, but the results are still eye-opening.

March 26, 2008

WPF - Updating XmlDataProvider when source XML changes

Some days back i had answered a question on the WPF Forum on how to ensure that when the base XML file changes, the XmlDataProvider is udpated and hence the bound control on the UI.

The key is to set a watch on the particular XML file for changes and then update the provider appropriately. See details here. This solution works fine, but I didn't particularly like my initial code that I wrote since the FileSystemWatcher was set externally. It would be better if this could be self contained within the XmlDataProvider itself.  

Continue reading "WPF - Updating XmlDataProvider when source XML changes" »

March 18, 2008

Expression Blend issue with WPF Data binding debugging

Some days back I had pointed to the blog by Beatriz on how to debug WPF data binding errors. I have been using the PresentationTraceSources.TraceLevel feature (available with .NET 3.5) since then and have found it very easy to use and very effective in resolving my data binding errors.

However recently when I opened a XAML, which had this debugging feature enabled, in Expression Blend 2.5 March Preview, I got an error. The XAML won't open in designer and showed "Invalid XAML" with details as 'The member "TraceLevel" is not recognized or is not accessible'.

Continue reading "Expression Blend issue with WPF Data binding debugging" »

March 12, 2008

WPF TextBox Memory Issue

Some days back, I had blogged about this issue and suggested how to set global style to counter this. However it turns out that with that you may run into 'Cannot use UndoService while it is disabled' related error. To address that, you will need to modify the style using a DataTrigger as below.

        <Style TargetType="{x:Type TextBox}">

            <Style.Triggers>

                <DataTrigger Binding="{Binding Path=IsLoaded, RelativeSource={RelativeSource Self}}" Value="True">

                    <Setter Property="UndoLimit" Value="0" />

                </DataTrigger>

            </Style.Triggers>

        </Style>

MS has accepted the behavior behind this as a bug. Read more discussion on this here.

March 10, 2008

WPF XmlDataProvider, Working with External XML Files

Recently on the WPF Forum I came across an interesting problem about use of XmlDataProvider in XAML and its ability to load external XML files. It took a bit of a struggle, but eventually I did manage to get it working. Here I will try and explain it in some detail so that others can also benefit.

We all know that one can easily bind to inline XML in XAML or can load that from external file. If working with inline XML, you usually use XData to specify the XML file content.

Continue reading "WPF XmlDataProvider, Working with External XML Files" »

March 6, 2008

Expression Blend 2.5 still has some issues with Globalization

Last week I had blogged about an issue with Expression Blend Dec 2007 Preview when working with Globalization and Localization. Yesterday at MIX 2008 Microsoft has launched Expression Blend 2.5 March 2008 Preview along with SilverLight 2.0 Beta. For a list of all the products announced during MIX check here.

With the new version of Expression Blend available, I went ahead and upgraded my machine with it and decided to give it a shot for the Globalization issue I had faced earlier.

Continue reading "Expression Blend 2.5 still has some issues with Globalization" »

March 1, 2008

WPF - TextBox memory leak issue

Earlier today on the WPF Forum I hit upon this issue about memory leak in TextBox. MS has responded saying it is by design. I am not entirely convinced as to how consuming unlimited memory could be a good design decision. I have been using WPF for a while now and wasn't even aware of this property on TextBox. I am sure many others won't be.

Anyway, the solution discussed there is to set the UndoLimit property of TextBox to 0. Instead of setting this for all TextBoxes in your code, it can more easily set in App.xaml as an application resource so that it is applicable to all TextBoxes by default. You can explicitly undo for specific ones via code or local property setting.

    <Application.Resources>  
        <Style TargetType="{x:Type TextBox}"> 
            <Setter Property="UndoLimit" Value="0" /> 
        </Style> 
    </Application.Resources>

February 29, 2008

Expression Blend issue with Globalized WPF Application

Recently while supporting a project on converting their WPF application for globalization and localization support, we faced an issue in being able to work with Expression Blend 2 Dec preview. We used the recommended approach for globalization and localization and after doing all that Expression Blend failed to load the user controls in design view.

You would get an error like this - "MissingSatelliteAssemblyException: The satellite asembly named yourassemblyname for fallback culture 'en-US' either could not be found or could no be loaded. This is generally a setup problem. Please consider reisntalling or repariring the application."

Continue reading "Expression Blend issue with Globalized WPF Application" »

February 25, 2008

Group By Many/Multiple Criteria using LINQ to SQL (L2S)

Developers may find it annoying for not finding an out of the box query operator in L2S to group by many/multiple criteria, which is used very frequently in T-SQL queries.  No sweat, there is an easy way out, will try illustrate the same here.

Continue reading "Group By Many/Multiple Criteria using LINQ to SQL (L2S)" »

February 14, 2008

Debugging WPF Databinding errors

For an application I was working on recently, I had a tough time with debugging some of the data binding issues. Then I came across this excellent blog. My personal favorite is the new Trace Level feature of .NET 3.5. For some reason, I could not get the second option to work.

February 5, 2008

Required Field Validation in WPF

In my earlier blog on user input validation in WPF, I had discussed about how extension methods can be used to provide for custom valiation logic. If your need is more simply only mandatory fields, a validation that the RequiredFieldValidation control provides in ASP.NET, you could very well use the concept of Data triggers in WPF.

One of the key benefits triggers offer is that they can be effectively managed within the XAML without usually requiring much of procedural code. Also since triggers are raised on specific actions/events, they are automatically undone when the action/event is over. This comes handy and saves code, since otherwise in procedural code, you need to handle both cases (something that is seen in my work with extension methods).

Continue reading "Required Field Validation in WPF" »

February 4, 2008

Are Remote MSMQ Queues Reliable?

I have played around a bit with MSMQ private queues and documented some of my findings earlier. In my first blog on this topic, I had captured how the naming of the queue is critical to connect to the right queue.

If it was local private queue, you could use - ".\\private$\\queuename"

and if it was remote private queue, you use - "FormatName:Direct=OS:machinename\\private$\\queuename"

Continue reading "Are Remote MSMQ Queues Reliable?" »

January 31, 2008

Working with MSMQ Journal Queues

In one of our internal forums, recently, someone had posted a query regarding issues in connecting and receiving messages from journal queues. The exception they were getting was "Queue ID is not registered in DS". I hadn't worked with Journal queues before, but this error seemed to me to be related to the queue path.

In my earlier blogs (here and here), I had discussed about the importance of specifying the right name for the queue and also mentioned how the path will typically look like. I decided to give it a try and created a private queue on my local machine and enabled journaling on it. Enabling journaling is as trivial as checking a checkbox in the queue property window.  You can also enable it by setting the UseJournalQueue property on the message.

Continue reading "Working with MSMQ Journal Queues" »

January 28, 2008

Custom User Input Validation in WPF

Building any application that works with User Input cannot be complete usually without having some sort of validations for the input values. WPF is no exception. There is an interesting discussion around WPF validation on Paul Stovell's blog

Martin Bennedik has written a WPF Validation Block over Microsoft's Enterprise Library 3.0. WPF 3.5 also brings in additional validation support via the IDataEffortInfo Interface.

Continue reading "Custom User Input Validation in WPF" »

January 24, 2008

Importance of Application.DoEvents

Recently a colleague of mine shared a code that he was working on where he was playing around with Asynch ADO.NET. He had a simple WinForm application. On the click of a button, he was making calls to the DB to get data. To try out the asynch features, he had introduced delays in the code.

Continue reading "Importance of Application.DoEvents" »

January 23, 2008

Unit Test Trust Issue on Vista

Further to my unit testing experiments that I have been blogging about in the last few days, I was playing around with the DashCommerce starter kit. After installing and configuring the site, I started by creating some tests for the code in the App_code folder.

The test creation was successful and I was all set to run. But luck was against me and I got compilation errors regarding missing namespace. As I had mentioned in my earlier blog, the testing happens via private accessor and since its creation happened successfully, ideally I shouldn't  have had a need for adding explicit references and namespaces to my test project.

Continue reading "Unit Test Trust Issue on Vista" »

January 22, 2008

Debugging ASP.NET Unit Tests with VS 2008

In my previous blogs (here and here), I have been discussing about unit testing on an ASP.NET web site that is hosted on IIS. While doing the work on that, I also had a need to debug my test case. The documentation on MSDN talks about putting break points and attaching to w3wp process and then debug the tests.

This however didn't work for me on VS 2008. What worked was adding the System.Diagnostics.Debugger.Break() call in my code and then running the tests like normal. When the code hit the Debugger.Break line, it asked me, which debugger to use and I selected the already open VS 2008 instance and it took me to the correct line of code and i was able to debug.

January 21, 2008

ASP.NET Unit Testing on IIS

In my previous blog I had mentioned about the issue in generating private accessors for ASP.NET code that is hosted on IIS. Does this mean that we can't test the web site if hosted on IIS?

You can, but it will be a bit more complex and you may not be able to cover all scenarios. The idea is to work with the PrivateObject that is available from the test context. In the previous blog, I had talked about a web site with a Calculator class in the App_Code folder that i wanted to test. Let's continue with the same example.

Continue reading "ASP.NET Unit Testing on IIS" »

January 18, 2008

ASP.NET Unit Testing issue on IIS with VS 2008

I was recently trying to dirty my hands on using the Unit test framework that comes with Visual Studio. I decided to give it a try on my newly installed VS 2008. I created a pretty trivial ASP.NET site hosted on IIS with a Calculator class that I put in App_Code folder and generated the tests.

One of the key differences in working with Unit test framework for ASP.NET as compared to other projects like Winform or Class library is that the code in ASP.NET gets compiled dynamicall into various assemblies and hence we can't bind to a specific assembly upfront. Check more details on this here.

Continue reading "ASP.NET Unit Testing issue on IIS with VS 2008" »

January 2, 2008

Querying user details from Active Directory

During a recent project, we had need for querying and working with Active Directory. Searching on net, gave lots of help, but most were around creating and managing users. Our need was simple - to get some user specific details from AD.

The trickest part of working with AD is the AD structure and what properties have been defined and hence available for querying. Without really knowing this, one can continue to grop in dark for long hours without much success.

Continue reading "Querying user details from Active Directory" »

November 30, 2007

Silverlight 2.0

I have been playing around with Silverlight for a while now and like all, have been eagerly waiting to get some out-of-box controls that will ease the development effort.

It is good to hear that Silverlight 2.0 will contain a good initial set of controls. The beta of this new version is expected around Q1 2008 and there is lot of speculation that RTM will be around June/July 2008.

November 20, 2007

Visual Studio 2008 Available

The must awaited Visual Studio 2008 is now available. Those who have MSDN subscriber download access, can download it from here. You can directly download the trial version from the home page itself. More details around this can be found here. In case you are facing issues in uninstalling the old Beta version and installing the new version, check here.

I am however facing issues with the new download manager. I keep getting network connection error. I will keep checking this up as I want to quickly download and start using this version of Visual Studio.

[Edited:22 Nov 2007] Full version of VS 2008 Professional Edition is available on MSDN subscriber downloads now.

November 12, 2007

Visual Studio 2008 RTM

Visual Studio 2008 is expected to RTM later this month. It should be available on MSDN Subscriber download, but the general off-the-shelf availability is still early next year.

November 1, 2007

It is Today - 1st Nov 2007

You would be aware of the expiring of VS 2008 Beta 2 VPCs today. If you have watching the VS Developer Center, you would have noticed the new updates on this. Jeff has mentioned in his blog about what happens with the existing VPC and mentions the 3 alternatives going forward

  • Upgrade the base OS with valid license
  • download the newly published VPC images from here
  • continue to work with the existing VPC and keep rebooting every 1-2 hrs.

Since downloading the 8 files, required for the VPC (not including the base image), took quite a bit of time for me, I will continue to use the existing VPC as is, as I can live with the reboot requirements for now.

October 29, 2007

VS 2008 Beta 2 VPC Expiring on 1st Nov 2007

If you have been playing around with VS 2008 Beta 2 VPC, note that the VPC unlike earlier thought, will expire on 1st Nov 2007 itself. In case you have been using TFS along with the VPC, follow the steps mentioned at Moving Team Foundation Server to take a backup of your DB and prepare to move to the new VPC.

Since the timeout is at OS level, it is still being researched if anyone will be able to access their data on the VPC after 1st Nov 2007 or not. Additional guidance will be made available shortly. Keep a watch here for latest information. 

 

September 3, 2007

Logging Events with User details

The other day a colleague asked about how to provide information for the "User" column in the Event log. The EventLog.WriteEntry method has various overloads, but none that allows you to pass the user details.

There is an EventLogEntry class also that .NET provides, which has a UserName member, but it is read only property and is used to query event entries from the log. This means that by using .NET APIs there isn't a way to provide the user name for event log entries.

Continue reading "Logging Events with User details" »

August 21, 2007

Silverlight on VS 2008 Beta 2 VPC

The other day I decided to try my hands on building a Silverlight application using the Alpha 1.1 refresh on my newly downloaded VS 2008 Beta 2 VPC. I built an extremely trivial application with a text box to display some text. However on running, I didn't see anything and didn't get any error as well. I played around with the text foreground color, visibility and opacity properties but no luck. I could see things fine in the Expression Blend.

So what was wrong and why was IE not displaying it. I then found that this is due to the Enhanced security configuration for IE. I didn't get any warning. Probably when the VPC was built the Continue to prompt when Web site content is blocked option was unchecked !! Anyway, removing the enhanced security configuration did the trick and the application started to work properly.

August 2, 2007

WPF and AppDomains

In my earlier blog I had talked about how to work with AppDomains and the issues I had faced. I had a chance to interact with Hua Wang from Microsoft and it was very enlightening.

There are specific things that need to be taken care when creating and destroying AppDomains in WPF. .NET framework 3.0 supports new APIs for this purpose and these are to account for the threading model of WPF.

Continue reading "WPF and AppDomains" »

April 30, 2007

VSTS (Orcas Beta 1) Profiler - Comparing Performance Reports

In my earlier blog I had looked at March CTP of Orcas and talked about performance reports and performance comparison reports and raised a few issues.

I downloaded and started to play around with Orcas Beta 1 today and thought of checking the performance comparison report to start with. I ran the same code as I did earlier and compared the reports.

Continue reading "VSTS (Orcas Beta 1) Profiler - Comparing Performance Reports" »

April 23, 2007

LINQ and its linkage to new features in .NET Framework 3.5 - Part II,,,

In my previous blog “LINQ and its linkage to new features in .NET Framework 3.5 – Part I”, we have seen how a query can be expressed with clarity with object oriented programming notation and couple of code snippets that showed how a class can be extended through “extension” methods – a concept that is introduced in .NET Framework 3.5. It is really important to know that when the query gets executed at runtime. The following code snippet shows the usage of query expression.

IEnumerable<string> name = Names.OrderBy(s => s.Length)
                        .Where(s => s.Length >= 15)
                        .Select(s => s);

The query execution does not happen in this line of code, though it uses the assignment operation. Only when, looping is happening through the foreach statement of IEnumerable[] items, the query gets executed.

See the following code.

Continue reading "LINQ and its linkage to new features in .NET Framework 3.5 - Part II,,," »

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter