The Problem Solver

Tell me and I will forget
Show me and I will remember
Involve me and I will understand
- Confucius -

Google Ads

This Blog

Syndication

Search

Tags

News





  • View Maurice De Beijer's profile on LinkedIn

Community

Email Notifications

Explore

Archives

September 2006 - Posts

One of the neat features of Windows Presentation Foundation (WPF) is that you can combine WinForms and WPF in a single form. That is pretty neat but the two are very different so there are a number of limitations and gotchas you need to be aware of.
 
If you know about them I suggest you read the blog post by Scott Berry titled Gotchas For Working With Windows Forms/WPF Interop at http://blogs.msdn.com/scoberry/archive/2006/09/01/735844.aspx.
 
Enjoy!
 
 
 
 
 
Maurice de Beijer
 
Posted by Maurice | with no comments
Filed under: ,
I just love Refactor :-)
 
Some of my favorite refactoring options are:
  • Move Type to File
    Sometimes I am just plain lazy and create a new type in the same source file as an already existing one. Only later I need to clean up and move it to a separate file. I used to do so with cut and paste but no longer :-)
  • Rename Local
    Renaming a local variable, or a field for that matter, becomes a breeze. And best of all you don't need to go to the declaration, you can do it at any place the variable is used.
  • Optimize Namespace References
    This removes unneeded namespace references at the top of the source file. While I like this a lot it needs to be improved just a bit because it sometimes misses a place a namespace is used :-(. And one thing I would like to see it do is sort the namespace references as well. Still very useful :-)
 
Below a small demonstration of how these refactorings can be used.
 
 
 
Enjoy!
 
Maurice de Beijer
 
Posted by Maurice | 2 comment(s)
Filed under:
Are you still developing software using Visual Studio 2003 (or 2002 for that matter) and planning an upgrade to Windows Vista later this year? Well you might want to reconsider your plans! Why? Well Microsoft has no plans for supporting either on Vista. Kind of funny really because they will support Visual Basic 6, both the runtime and IDE, on Vista.
 
So what does this mean for the average software developer?
 
Well I am sure most of you are in a similar situation as I am in myself. That is do most of my work in VS2005 but occasionally go back to VS2003 to support some already finished project. Now I am unsure of what the exact result is, after all unsupported might mean almost everything works but Microsoft won't be any help is something doesn't all the way to it won’t even start up. But one thing is sure it will slow my upgrade from XP to Vista down. And that is regrettable :-(
 
 
Maurice de Beijer
 
Posted by Maurice | 1 comment(s)
Filed under: ,
If you are tracking the progress of events in a workflow using a SqlTrackingService object you might have noticed you aren't seeing any events in the database until the workflow is either finished or unloaded. In fact you won't get to see any event until the WorkflowPersisted event has fired. The reason for this is that the default for the SqlTrackingService is to be transactional. Even though the docs claim the default for the SqlTrackingService.IsTransactional is false in fact it is true. This results in the records being written to the database but you won't see them when querying because they are still locked in a transaction. So if you need or want to see the up-to-date events while the workflow is still executing you need to set the SqlTrackingService.IsTransactional to false before adding the service to the WorkflowRuntime.
 
If you want to see the tracking data itself you might start running SQL queries against the database. An easier way is to use the SqlTrackingQuery.TryGetWorkflow() to load an SqlTrackingWorkflowInstance instance with the tracking data. Te SqlTrackingWorkflowInstance object as properties to inspect the workflow status, the workflow events, the activity events and more.
 
Enjoy!
Maurice de Beijer
 
Posted by Maurice | 1 comment(s)
Filed under: , ,
Sometimes you need to know just that little bit more about the time zone a user is in. You might need to know the time difference between their local time and UTC, whether they are in daylight saving time or when the daylight saving period starts and ends.
 
Well the TimeZone type is our friend. The TimeZone.CurrentTimeZone will give you all sorts of information like if daylight saving time is in effect, the IsDaylightSavingTime() function, or offset from UTC, the GetUtcOffset() function.
 
Additionally the GetDaylightChanges() functin will give you more detail about when the daylight saving period starts and ends and the time change involved.
 
Enjoy!
 
Maurice de Beijer
Posted by Maurice | 2 comment(s)
Filed under:
But than again you probably knew that already if you have done any work with reflection. But Stephen Erisman got creative with the problem and tried generating dynamic IL at runtime to solve the problem. And guess what it works and not a bit faster but a lot :-)
 
So if you find yourself doing a lot of the following:
PropertyInfo pi = someObject.GetType().GetProperty("SomeProperty");
object value = pi.GetValue(someObject, null);
you really should take a look at his article at the Code Project and try it. In my case the performance boost was almost 100 fold!
 
Thanks to Scott Hanselman's show about reflection.
 
Enjoy!
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
If you are using the Red Gate - ANTS Profiler I suggest you check their web site as they have recently released version 2.7 and it’s a free maintenance release.
 
And if you aren't using ANTS yet and need a profiler I suggest you go to their site and download the trial version and give it a try. I have been using it for some time now and think it’s a great tool :-)
 
These are the fixes according to their website:
Vista compatibility, UI tweaks, engineering for larger code bases and bug fixes
  • The timings for recursive methods are now accurate (in previous versions they had a tendency to grow alarmingly)
  • We have built ANTS Profiler 2.7 with .NET 2.0. This means that you only need to have .NET 2.0 installed to use the tool. This has the knock on effect that 2.7 will work on Vista beta 2.
  • We have fixed the bug with profiling ASP.NET on machines that have both .NET 1.1 and .NET 2.0 installed. This is a fairly common problem reported on the forums under ‘Error: The web application has not loaded the .NET Framework’.
  • When profiling ASP.NET on Windows 2003 Server we no longer stop the web server to profile a web site. This means that people can profile a particular ASP.NET web app, but still keep all their other web apps running as normal
  • Some multithreaded apps were causing the profiler to crash. We have fixed this in 2.7.
  • Small UI tweaks to improve usability
  • We have improved the logging so that if anything does go wrong we can offer better informed support.
 
 
Recommended!
 
Maurice de Beijer
Posted by Maurice | 4 comment(s)
Filed under:
I think Windows Workflow Foundation is one of the more interesting features in WinFx, oops the .NET 3.0 framework. But figuring out what to do can be a challenge. Fortunately they added a number of trace switches to allow you to track what the components are doing. Add the following to the app.config file to see what is going on:
 
<system.diagnostics>
  <switches>
    <addname="System.Workflow LogToTraceListeners"value="1" />
 
    <addname="System.Workflow.Runtime.Hosting"value="Verbose" />
    <addname="System.Workflow.Runtime"value="Verbose" />
    <addname="System.Workflow.Runtime.Tracking"value="Verbose" />
    <addname="System.Workflow.Activities"value="Verbose" />
    <addname="System.Workflow.Activities.Rules"value="Verbose" />
  </switches>
</system.diagnostics>
 
Valid value are:
Off
No messages
Error
Only error messages
WarningError and warning messages
Info
Information, error and warning messages
VerboseAll kind of messages
 
Enjoy!
 
Maurice de Beijer
Posted by Maurice | 3 comment(s)
Filed under: , ,
One of the problems facing a WinForms developer is choosing which event handler to pick when he wants to handle a certain event. Now this sounds easy, you might say: I want to do something when the user click on the form so I add an event handler to the form Click event. And in this case that works just fine but suppose you want to do something when a user tabs from one TextBox to the next. In this case a number of events are raised.
 
To help the developer pick the right event I have started developing an event tracer utility. This utility gives the developer insight into which events are raised and in what order. This way a developer can see that the Validating event is raised when tabbing between controls. But equally important the developer can spot an event that isn’t raised. For example he might set the CausesValidation property to false and the Validating event is no longer raised. Now he watch the trace, confirm the event is no longer raised and pick another suitable event instead.
 
Note: This version of the EventTracer is still an early 0.5 beta version so it isn’t exactly finished yet :-)
 
You an download a beta version of the Event Tracer from: http://www.theproblemsolver.nl/dotnet_file_0003.htm
 
Enjoy!
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
It you are trying to install the Workflow extensions for Visual Studio as per Pail Andrews instructions on http://blogs.msdn.com/pandrew/archive/2006/09/07/745701.aspx you might run into the same problems as I have. The problem occurs while trying to install Visual Studio 2005 extensions for Windows Workflow Foundation (Visual Studio 2005 Extensions for Windows Workflow Foundation RC5(EN).exe) after installing the Visual Studio "Orcas" CTP (vsextwfx.msi). The problem I was having is that the last installer seems to restart the previous one and offers a change/repair/reinstall option, clearly not what I needed. The solution was suggested by Bill McCarthy and that fixed the problem.
 
The solution is to rename the installer "Visual Studio 2005 Extensions for Windows Workflow Foundation RC5(EN).exe" to "Visual Studio 2005 Extensions for Windows Workflow Foundation RC5(EN).zip". Now extract the zip file to a directory and start the install from there. Now you do get the option to install the workflow extensions and everything works as expected.
 
Enjoy the workflow :-)
 
Maurice de Beijer
Posted by Maurice | 24 comment(s)
Filed under: ,
There seems to be no end to the flow of free add-ons for Visual Basic 2005. This time the first two Power Packs are released.
 
The first Power Pack, the Microsoft Interop Forms Toolkit 1.0, is aimed developers still forced to work in Visual Basic 6. Using this Power Pack they can add .NET WinForms in their application.
 
 
 
 
The second Power Pack, Microsoft PrintForm Component 1.0, makes it easier to print .NET WinForms.
 
 
 
 
Enjoy!
 
 
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
Intentionally in Dutch :-)
 
Er zijn niet veel Visual Basic boeken in het Nederlands te krijgen. Nu spreken de meeste Nederlands ontwikkelaars op zijn minst best redelijk tot vloeiend Engels maar het blijft toch moeilijk om alles te begrijpen. En dat laatste niet in het minste omdat veel boeken over software ontwikkeling wel eens een steekje laten vallen in het gebruik van de Engelse taal. Daarom zal het voor vele goed nieuws zijn dat we nu ook een goed boek over Visual Basic hebben in het Nederlands. Geschreven door André Obelink, een bekende Nederlandse MVP en expert op het gebied van Visual Basic. En er staat zelfs een interview met ondergetekende in :-)
 
Van harte aanbevolen!
 
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
November 7th till 10th Microsoft is hosting the Tech-Ed Developers show in Barcelona. So that is still some time away but the end of the early bird discount isn't. In fact that has less than two weeks to go as it is valid up to September 29th. And with Barcelona being a nice party town the € 300,- will make for some nice extra pocket money :-)
I have already registered, have you?
Maurice de Beijer
Posted by Maurice | with no comments
Filed under: , ,
Need to dynamically alter the dropdown contents to a ContextMenuStrip item?
 
Well the Opening and, if needed, the Closed events are your friends. Use the opening event to dynamically enable/disable items. You can also dynamically add new items in which case the Closed event is the place to remove them again.
 
Enjoy!
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
Just released, Visual Studio 2005 tools for Office 2007 SE (Beta). This seems like a nice addition to Visual Studio 2005. And even though it says Office 2007 it also works for creating Office 2003 addins, including Word, Excel, Outlook, PowerPoint and Visio.
 
And the best thing is that it is a free download. Well almost, you need to have a licensed copy of VS2005 Pro or higher or VSTO 2005 so the Express developers are out of luck this time.
 
 
Enjoy!
 
 
 
Maurice de Beijer
Posted by Maurice | 7 comment(s)
Filed under:
One of the questions I frequently get is how to get the same behavior as Excel when entering numeric values. With the same behavior I mean that Excel detects the current users locale setting for decimal separator and makes the decimal point on the numeric keyboard input the correct character. This is only done for the numeric keypad, the point and comma on regular part of the keyboard remain unchanged. Doing so is very easy but finding the right place is not completely obvious as in most events the KeyEventArgs or Message parameters cannot be changed or changing them has no effect.   The proper place to do this is the PreProcessMessage() function of a control. The code below does just that, just subclass the a TextBox control and override the PreProcessMessage() function and you are done.
 
 
PublicOverridesFunction PreProcessMessage(ByRef msg As System.Windows.Forms.Message) AsBoolean
   If msg.Msg = &H102 Then
      If msg.WParam.Equals(New IntPtr(&H2E)) _
         AndAlso msg.LParam.Equals(New IntPtr(&H530001)) Then
         ' Point in the numeric keypad pressed
         If Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ","Then
            ' And the decimal separator is a ',' for the current settings
            ' Change the message to enter a comma instead of a poin
            msg.WParam = New IntPtr(&H2C)
            msg.LParam = New IntPtr(&H330001)
         EndIf
      EndIf
  EndIf

  ' Do the default actions
   ReturnMyBase.PreProcessMessage(msg)
EndFunction
 
Now if you are using a DataGridView things are a little more complicated :-(. The code is a little long for this blog post but I did put it up on my web site. Take a look at this FAQ entry if you are interested.
 
Maurice de Beijer
Posted by Maurice | 11 comment(s)
Filed under:
There seem to be a lot information being publicized about the future of Visual Basic .NET at the moment. I missed this video at first but after just watching it I can only say its and interesting listen when Erik Meijer speaks about what they are working on. And anyway its always nice to see a Dutch guy be really successful in Redmond. Ok Erik is a bit smarter than the average Dutchman but its still nice :-)
 
Erik Meijer: Democratizing the Cloud
 
 
Maurice de Beijer
Posted by Maurice | with no comments
Filed under: ,
Paragliding is a nice sport but it isn't without its risks as I found out this weekend :-( Not that I didn't know I could get hurt but there is a difference between knowing and experiencing.
 
So I crashed my glider during the landing and hurt my back. In fact I broke of part of a vertebrae. Guess that has me immobilized quite a bit. Fortunately the stay in the hospital wasn't too long and I am back home but it appears that it will take 4 to 6 weeks of rest. Guess that gives me ample opportunity to catch up on my WinFx study.
 
Maurice de Beijer
Posted by Maurice | 4 comment(s)
Filed under:
If you are interested in the future of VB and what kind of features we might be expecting while the language evolves the Brian Beckman video in Channel 9 is interesting to watch. Keep in mind that Brian is a scientist so it isn't exactly bite size chunks he delivers but provided you like that kind of thing it’s a fascinating story he has to tell.
Brian Beckman
See the video at :http://channel9.msdn.com/showpost.aspx?postid=230438
Maurice de Beijer
Posted by Maurice | 2 comment(s)
Filed under: , ,
IronPython 1.0, the Python release for the .NET framework has its first release. I haven't tried it yet but in the past I have used the original version of Python as build by Guido van Rossum and though it was a great and very productive programming language.
Take a look at Jon Udell's screen cast for an overview about Python at http://weblog.infoworld.com/udell/screenroom/ironpython_flv.html.
Enjoy.
Maurice de Beijer
Posted by Maurice | with no comments
Filed under:
More Posts Next page »