Home » SilverlightRSS

Object reference not set to an instance of an object

When I close the Add Reference dialog box I get the following error.

---------------------------
Could not show Add Reference Dialog
---------------------------
The Add Reference Dialog could not be shown due to the error:

 

Object reference not set to an instance of an object.

 

The error details has been saved to ...\AppData\Local\Microsoft\VisualStudio\10.0\ShowAddReferenceDialog.log
---------------------------
OK  
---------------------------

Any suggestions on how to fix this?

 

11 Answers Found

 

Answer 1

Could you post your code here?

It sounds like problem is in the code, you must be referencing an object not instantiated. 

 

Answer 2

It even does it from a fresh project because I was thinking I had done something wrong.  So I created a new Silverlight Application, and tried to add  a reference.  I did not select anything and just closed the box.  I still got the error.

I am thinking I might need to reinstall something.

I am using Visual Studio 2010 Professional.

 

Answer 3

Maybe, try to reinstall your VS 2010.

If the problem persist, you let us know in this thread.

Is it a silverlight 4 project?

 

 

Answer 4

When I first noticed it yes.  Based on your suggestion I created a new Silverlight 3 in .NET 3.5 project and got the same result.

I will do a reinstall tonight and let you know how it goes.

 

Answer 5

OK, Reinstall it and let us know. 

 

Answer 6

I was about to start when an idea hit me.  Perhaps it is one of the extensions I have installed.  I removed the two I had, Productivity Power Tools, and I forget the other one.

Things worked fine.

Reinstalled Power Tools and it messsed up again.

So, it appears to be something with the Productivity Power Tools.

I'm sorry to have wasted people's time on this one.

 

Answer 7

Uninstalling the Productivity Power Tools resolved the problem for me, too. Thanks. 

("This is obviously some strange use of the word "productivity" that I wasn't previously aware of..." ;-)

 

Answer 8

I did find out that if you have the extension installed you can disable the search reference.  That works too, so you don't have to uninstall it. 

 

Answer 9

I get the same error. It's to do with the Power Tools Extensions and it leaves a trace file in my local user appdata directory called ShowAddReferenceDialog.log. 

20/10/2010 11:11:09
System.NullReferenceException: object  reference not set  to an instance  of an object.
   at Microsoft.VSProjectPlus.AddReferenceDialog.AddReferenceDialogView_Closed(Object sender, EventArgs e)
   at System.Windows.Window.OnClosed(EventArgs e)
   at Microsoft.VisualStudio.PlatformUI.DialogWindowBase.OnClosed(EventArgs e)
   at System.Windows.Window.WmDestroy()
   at System.Windows.Window.WindowFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.UnsafeSendMessage(IntPtr hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel)
   at System.Windows.Window.Close()
   at Microsoft.VSProjectPlus.AddReferenceDialog.btn_Close_Click(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.ShowModal(Window window, IntPtr parent)
   at Microsoft.VisualStudio.PlatformUI.DialogWindow.ShowModal()
   at Microsoft.VSProjectPlus.AddReferencePackage.ShowAddReferenceDialogOnIdle(IdleComponent idleComponent)


 

Answer 10

I have looked into this a bit more and it is do with adding references to a Silverlight project only. If you create a non-Silverlight project - for example, a C# class library - and use the same Power Tools Add reference  dialog, everything works okay.

Add a Silverlight project then add  the reference to that, you will get the error.

It seems that Power Tools is not showing you the real error. If you disable the Power Tools extension, restart VS, and then do the same action using the standard Add Reference dialog  you will get an error  of some kind. Mine was, 'DLL was not compiled against the Silverlight assembly' or similar.

So it seems that you get the Power Tools nullref error when there is some incompatibility with the dll you tried to add the reference for.

This was true in my case but your error may have a different cause. Try reverting to the standard Add Ref dialog to see your real error.

 

Answer 11

I think it is still something to do with Silverlight but the problem occurs even if you quit the Power Tools Add Reference dialog  without doing anything. Maybe the writer of that could look at the stack trace.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter