Showing posts with label Error. Show all posts
Showing posts with label Error. Show all posts

Wednesday, 22 June 2011

The XAML Message From Hell: "Error HRESULT E_FAIL has been returned from a call to a COM component."

The most irritating thing in XAML-based projects (Silverlight, WPF) is the infamous "Error HRESULT E_FAIL has been returned from a call to a COM component."

Why Microsoft didn't decide to catch it and give a more appropriate exception escapes me. However, some things I've learned about this:

Your XAML is failing to load!


Now, your XAML may actually be correct, is the funny thing -- but maybe your project is missing the references. For example, I'm using the Silverlight Toolkit and setting styles at runtime on the fly, allowing for potential theming. I kept getting this error, even though my other projects which use the same code are building fine -- so why is my latest project failing to build?

I missed a reference that was used in the other project. When it came to load the XAML style, it was likely getting hung up on the missing reference and saying, "OK, I see you want to use System.Windows.Controls.Layout.Toolkit... but what in the world is that?"

To rectify this issue, it was necessary to add references all over again.

So, my troubleshooting advice is:


  1. Make sure the XAML is correct. When writing cross-platform (i.e. Silverlight and WPF), some of the controls/targets behave differently or have different properties. Visual Studio generally points this out as a build error.
  2. Make sure that you are referencing all dependent assemblies. Due to Silverlight's dependencies, if I write a library on top of Silverlight Toolkit, which then gets used in an application, that application needs to have the references to Silverlight Toolkit.

Good luck and when in doubt -- get an extra set of eyes!

Saturday, 20 November 2010

Why can’t we Create a Folder by name CON

While browsing through the orkut community, I came across the discussion that folder can’t be name as Con. Then I started googling about Con and got some cool solution to it.
Also read this amazing fact:-
An Indian discovered that nobody can’t create a FOLDER anywhere named as “con“. This is something pretty cool….and unbelievable . At Microsoft the whole Team, including Bill Gates, couldn’t answer why this happened!!!
Source-lists.evolt.org
I am sure that many people still don’t know that they can’t create a Con folder in windows XP and in some other Operating System.
So Why cannot we create a folder by a name Con? What’s the reason behind it?
It’s pretty simple, Con is a reserved name from the early days from DOS, it stands for the “CONSOLE” I/O device, Since it is already used by the system. If we create one with some evil tricks then the system will get confused. There will be an ambiguity.
Check out other reserved words to understand what are all the reserved words using which you can’t create folders in windows.
Like Con, many other reserve words are there which we can’t create. They are
PRN – It stands for printer.
AUX – It stands for Auxiliary device.
COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 – They stands for serial ports.
LPT1, LPT2, PRN – They stands for Parallel ports.
NUL - It stands for Bid Bucket.
Did I said that the Con folder can’t be created, what a big typo. Well friends, There’s a evil trick to create a Con folder. Here goes the evil tricks.
Open the Command prompt by Start->Run and type in cmd
Type MD\\.\\C:\CON
C is the drive path, you can change this drive to your own choice of path.
Now Open My Computer and browse through the path where you created the Con folder. surprising huh!!! yeah buddy, you have successfully created a Con folder.
Now try to delete the folder, it won’t get deleted by simple delete option. Better try this:-
To delete the folder, type RD\\.C:\CON
Another method to create Con folder without the use of the Dos.
Create a new folder. Name it Con and press Alt + 255 simultaneously.
Well Alt+255 stands for a blank character in ASCII so it allows you to use this folder name.
Note:- Actually you’ll have to press the number’s of the number pad or else it won’t work. That is, create a new folder, rename it Con but don’t press enter yet. Hold down Alt and type 255 on the number pad and then press enter. (for laptop users, press Fn key and press the letter keys k-i-i to make use of number pad).
The next time when someone asks the question that why can’t we create a folder by name Con, say with confidence that it is not true…