How much time and manpower did Microsoft take to implement the Off menu?

by Miha Markič 27. November 2006 23:07

You will never guess, don't even try it. Here is the article that made Frans Bauma sad. Very very educational, highly recommended read (assuming that it is correctly written).

But what's even funnier is that none of those Sleep/Hibernate/Hybrid Sleep options work for my pretty decent new computer. It goes to sleep/hibernate/hybrid sleep but then immediately returns to normal functional state for no apparent reason (anybody knows how to pinpoint the source of the problem?). I guess they would have to duplicate the effort spent on sleep feature.

Tags:

Windows

Please, don't abuse try/catch

by Miha Markič 23. November 2006 15:06

You should have heard from experienced developers that you shouldn't abuse try/catch to handle a situation that is predictable and easily handled with an if statement. Even guys at [MS] preach this approach.

Take a look at this piece of code:

string fileName = "somefile.xml"; bool notFound; try { FileStream fs = File.Open(fileName, FileMode.Open); // do something } catch (FileNotFoundException) { notFound = true; }

While this method produces correct output (notFound=true) when file isn't found there are at least two problems in there:

  1. Method is slower when file isn't found (because of throwing exception overhead). This is just a small overhead.
  2. What's more annoying is that if you have Debugger/Exceptions... settings set to intercept all exceptions (shown in picture below) you will catch such exceptions even when there is nothing wrong with the code.

The reason why I am writting this post is that I get such an exception when creating an instance of IsolatedStorageFileStream class. Visual Studio correctly stopped on instance creation telling me that an exception of type FileNotFoundException occured.At first I was a bit puzzled why would I get FileNotFoundException when I was passing FileMode.Create flag. Doesn't make sense, right? Wrong. IsolatedStorageFileStream constructor internally implements similar (not same) code described above. It uses a handled exception for checking whether file exists even when using FileMode.Create!

Instead the code above could be rewritten as:

string fileName = "somefile.xml"; bool notFound; if (File.Exists(fileName) { FileStream fs = File.Open(fileName, FileMode.Open); // do something } else notFound = true;

This approach is more elegant, readable, faster and it doesn't throw anything on predictable problems. I guess [MS] guys could clean up a bit .net library.

UPDATE (gorazd pointed that there is a possibility that file disappears between File.Exists and File.Open - while I thought of this when I was writing this post I forgot to include it in the code). So, here is an improved v2:

string fileName = "somefile.xml"; bool notFound; if (File.Exists(fileName)) { try { FileStream fs = File.Open(fileName, FileMode.Open); // do something } catch (FileNotFoundException) { notFound = true; } } else notFound = true;

UPDATE: The good news is this behavior is a must only in Visual Studio 2003. Not because of a code change. No, there is actually an option to disable catching non-my-code exceptions. The option is turned on by default. So, here it is:

You'll find it in Tools/Options... Unfortunatelly that doesn't help if you are stuck in a Visual Studio 2003 world.

Tags:

.net

When Murphy kicks in on presentation

by Miha Markič 23. November 2006 00:18

I had my worst presentation so far today. While Matjaž delivered his usual good talk I created a mess but it wasn't my fault. At least not a huge part of it. The plan was to show how a get-process cmdlet is quickly and easily built with Visual Studio 2005 and to show a simple SqlServerDBProvider in action.

To save time I fired up Visual Studio 2005 before presentation (it talks quite some seconds on my laptop), opened "Add Reference..." message box (it takes time to enumerate all assemblies if they aren't in cache), closed dialog and waited for my turn. After Matjaž introduced Power Shell I started creating get-proc cmdlet. I created a new class library process and renamed default Class1 class to GetProcCmdlet. So far so good. Next I typed : and a letter C (inheriting from Cmdlet class). Here the disaster struck. Visual Studio 2005 has frozen for some reason. To make it worse I was unable to kill it. To make it worse the second Visual Studio 2005 instance has frozen at same point, too. To make it worse I was unable to kill this instance, too. To make it worse I had to restart (hardware reset) Windows XP SP2. To make it worse it takes quite a lot time for Windows XP SP2 to boot up after so cruel restart. And when I finally managed to start up Visual Studio 2005 again I lost a couple of minutes in Add References... dialog. After this the demo went smoothly until the time for second demo came. Brutal restart affected the other demo somehow, too. And I lost again quite a lot time repairing and restarting second demo. At least Matjaž had some fun and an opportunity to poke jokes on developers.

Oh well, an experience to learn from.

Tags:

Windows | Slovenia | .net

You have to license Ribbon UI on your applications

by Miha Markič 22. November 2006 09:57

This one might come as a surprise to developers: If you use [MS] like Ribbon UI (Word 2007, Excel 2007) in your application you have to get a license from [MS] in order to legally use it. And it doesn't matter if you buy a ribbon component from 3rd party vendor ([DevEx] makes very nice one) - you still have to get a license from [MS].

Quote from the link above:

"To that end, Microsoft has created a royalty-free licensing program that will enable developers to build applications that have the look and feel of the new 2007 Office system applications. The new program will license elements of the new UI to software developers and component vendors on a royalty-free basis."

[MS] has done something similar if you wanted to play with Office native file format - you have to sign an agreement that you won't use that knowledge in a competiting product. Now they are extending it with requirement to follow their UI guideliness, too. So we. developers, might be constrained in extending Ribbon functionality.

I wonder how much is this a precedence. Imagine that you are building a complex application and you have to obtain licenses for every part of it that is similar to something somebody already done. At least it is free for now but this might change in the future...

Tags:

Windows | .net

I'll be co-presenting Windows Power Shell at SLOWUG

by Miha Markič 22. November 2006 00:24

Tomorrow (Wednesday) I'll be co-presenting Windows Power Shell with Matjaž Ladava (MS dude) at Slovene Windows Users Group (SLOWUG). It will be quite a challenge talking about cmdlet development to a group of admins. I don't plan die-hard lessons, just a quick overview on how cmdlets and providers are built so they get an impression of what's behind all thos verb-nouns things and perhaps built easier ones on they own.

Tags:

Windows | Slovenia

VMWare Workstation 5.5.3 for ("experimental support") Vista

by Miha Markič 20. November 2006 11:02

Just after few days after Vista went RTM, [VMWare] released a minor update to its Workstation 5.5 product. For me, the most important feature is (experimental) Vista support - both host and guest. How can one live without [VMWare] Workstation?

So, another obstacle for Vista adoption is removed.

Tags:

Windows

Office 2007 is available for download on MSDN

by Miha Markič 13. November 2006 00:25

Office Professional 2007 and other Office 2007 programs are available for download on MSDN. Happy downloading.

Tags:

Windows

Red-gate's SQL Compare

by Miha Markič 12. November 2006 16:09

Recently I was facing this problem: I am developing an asp.net 2.0/remoting/winforms application which stores data in Sql Server 2005. From time to time I publish my application and its database to the public for testing purposes. The project is under development plus I don't create database at the beginning and never change it (because of various reasons). Instead I add metadata and change database structure here and there. No problems so far but when I need to publish a new version, I have a problem if I want to keep public date and not just overwrite them with new database. What were my options so far:

  1. carefully record each database modification and store SQL DDL statements. Run all these statements on public database at publish time. This approach works but it is tedious
  2. create new blank database with latest structure and somehow import data from public database. Substitute public database with this new one. Again, tedious.

Fortunately Red-gate comes to help with its Sql Compare product. It is able to keep database structures in sync, or better, at publish time I just say to SQL Compare that my target database structure (public one) has to look like the development one. SQL Compare compares two database structures and report what's and how's changed. After this step I could just press Synchronization Wizard... button and it would synchronize the target database. Or I can check out the proposed SQL statements SQL Compare creates for me. There is also plenty of options to tweak its behaviors one wishes (i.e. you can filter out the database objects that you don't want synchronized). As a cherry on the pie there is also a command line version and a set of .net API (SQL Toolkit) that lets you do the job from your .net application (I didn't test it yet but I see its great potential).

The bottom line is that Sql Compare is a great time saver tool when you are dealing with Sql Server database synchronization.

And there is much more from Red-gate. They have full set of tools that helps you manage Sql Server beast, the latest one and fresh from the owen being Sql Refactor. That's right, Sql Server refactoring tool - no more hassles when you need to rename an object and then search for all the spots where you have to rename it. I can't wait to try this one out...

Tags:

Windows | .net

About Visual Studio 2003 on Vista

by Miha Markič 8. November 2006 00:47

A while ago Somasegar's blog post about MS not supporting Visual Studio 2003 on Windows Vista caused quite a stir in community. A lot of people were very concerned about this issue.

A note at this point: .net 1.1 and newer will be fully supported. It is just the Visual Studio that has problems. While they are putting all their effort in Visual Studio 2005 (through Service Pack 1 - it will be required - and there might still be some minor issues) and Visual Basic 6 (apparently still alive) they are leaving Visual Studio 2003 behind. The suggestion here is to use virtual machine to run Visual Studio 2003 on some other OS within this virtual environment. However, this is not an ideal solution for several reasons - the most important being that not everything runs in virtual machine environment, such as DirectX applications. The other almost equally important is slowness of virtual machines.

Back to the cause of the problems. Most of the problems are caused by Vista User Account Control (UAC) which is very aggressive in protecting the OS from various threats. And the side effect is that it nukes debuggers. In other words, you can run Visual Studio 2003 but you can't debug (remember old times, when we were putting a ton of "Output" methods in code instead of debugging).

Here are the good and the bad news: It is possible to run Visual Studio 2003 including debugger (at least in normal debugging situations - debugging WinForms, Console applications - I didn't tested others) in Vista but it comes with a price. You have to turn off UAC (you can do it by running msconfig utility) and switching on/off UAC requires a machine restart. Yep, I have turned it off because I need Visual Studio 2003 for DirectX managed applications. I guess I won't be using UAC for a while.

In my opinion (and in opinion of many others) MS' decision to support VB6 instead of VS2003 remains very questionable.

UPDATE (23.12.2006): Dan posted a comment with link to "what's not working in vista and how to workaround it".

Tags:

Windows | .net

(Managed) DirectX versions confusion

by Miha Markič 4. November 2006 15:23

(Managed) DirectX 9.0x is the perfect example on how not to handle version numbering.

First, there is a "global" version problem which Jeff Atwood describes here. They are all 9.0c! Only the release date changes. So, you have plenty of 9.0c versions out there. Perhaps unmanaged libraries are all the same but managed wrappers certainly aren't.

And here we come to the most complicated and chaotic versions numbering ever. It is a true obfuscation masterpiece. Fortunately, ZMan unveils the mystery in this post.

The bottom line is: avoid such versioning. And if you need to know which managed DirectX version is installed on your computer make sure you check ZMan's post.

Tags:

Windows | .net

Miha Markic

About me
Righthand
 
Microsoft MVP
 
Developer Express' DXSquad
INETA Country Leader for Slovenia
INETA Country Leader for Slovenia

Slovene Developer Users Group Lead
Friends of Red-Gate
LLBLGenPro Partner

Miha currently works as a free lance consultant and software developer specialized in .net area.
He graduated in Computer and information science at the University of Ljubljana, Slovenia. He has accumulated experience in various programming languages such as Java, Visual Basic 3-6 (MCP), Visual C++, Delphi, C# and VB.Net through years.
He has experience in practically all (technical) stages of project development, including planning, framework development, user interface, business processes, as well as testing and documenting. He has worked on big and small projects in Slovenia and abroad (e.g. participated in completing level 3 IS for the Nucor steel plant, Hertford, USA).
Currently he enjoys programming in .net environment using C#. Since 2000 he has been active in Developer Express' DX Squad and has been ECDL trainer and tester. He also gives lectures on conferences and other events in Slovenia.

Month List

Tag cloud

Most comments

Paulius Paulius
1 comments
us United States
Meh Meh
1 comments
us United States
bart dm bart dm
1 comments
nl Netherlands

RecentComments

Comment RSS