Initialize Component throws a null reference exception

Little late, but when you get a null reference exception like this, it can be misleading. The inner exception may be null (was in my case.)

The way I discovered the issue was to enable first chance exceptions in VS 2010.

Goto Debug -> Exceptions then check all the boxes.


You need to look at the inner exception. When initialcomponent is called it can fire off other code which must be causing an exception. The inner exception should give you all the information you need. Note that it is possible that the inner exception will have an inner exception itself. Modify your app to write all these to a file or the clipboard or something.

Tags:

C#

Wpf