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.
Enjoy!
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!
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 :-(
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!
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!
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!
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!
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
|
| Warning | Error and warning messages |
Info
| Information, error and warning messages
|
| Verbose | All kind of messages |
Enjoy!
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 :-)
Enjoy!
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 :-)
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!
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!
More Posts
Next page »