Bug 54329 - [Inspector] Error preparing project for inspection: System.NullReferenceException: Object reference not set to an instance of an object.
Summary: [Inspector] Error preparing project for inspection: System.NullReferenceExcep...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Inspector Integration ()
Version: unspecified
Hardware: PC Windows
: High major
Target Milestone: ---
Assignee: xamarininteractive
URL:
: 53876 ()
Depends on:
Blocks:
 
Reported: 2017-03-31 12:11 UTC by Jerome Laban
Modified: 2018-05-08 10:52 UTC (History)
14 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jerome Laban 2017-03-31 12:11:20 UTC
VS2017 (15.0.0+26228.10, Xamarin 4.3.0.784) takes a lot of CPU at a particular (unknown) point, and this exception pops-up very frequently when hooking up a debugger to devenv:

[Inspector] Error preparing project for inspection: System.NullReferenceException: Object reference not set to an instance of an object.
   at Xamarin.VisualStudio.Inspector.ProjectExtensions.GetProjectFlavor(IAdaptable`1 adaptableProj) in C:\d\lanes\4368\73f58d6d\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\Extensions\ProjectExtensions.cs:line 62
   at Xamarin.VisualStudio.Inspector.VSAgentExecutionTarget..ctor(Project proj) in C:\d\lanes\4368\73f58d6d\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\VSAgentExecutionTarget.cs:line 42
   at Xamarin.VisualStudio.Inspector.VSInspectorSession.CreateAgentExecutionTarget() in C:\d\lanes\4368\73f58d6d\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\VSInspectorSession.cs:line 84
   at Xamarin.Interactive.IdeSupport.InspectorSession.Prepare() in C:\d\lanes\4368\73f58d6d\source\xamarinvs\External\inspector-ide-integration\Xamarin.Interactive.IdeSupport\InspectorSession.cs:line 95
   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.RefreshInspectorSession() in C:\d\lanes\4368\73f58d6d\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 136

The loaded solution contains cross-targeting projects (using the TargetFrameworks property).
Comment 1 Jahmai 2017-04-02 08:25:12 UTC
This is really, really, really annoying.
Comment 2 Sandy Armstrong [MSFT] 2017-04-06 15:44:28 UTC
Fixed in Visual Studio 15.2.
Comment 3 Sandy Armstrong [MSFT] 2017-04-06 21:36:10 UTC
*** Bug 53876 has been marked as a duplicate of this bug. ***
Comment 4 Luke Pothier 2017-04-11 16:10:43 UTC
Does anyone have a workaround for this? VS 15.1 was released yesterday, when is 15.2 due to be released?
Comment 5 Sandy Armstrong [MSFT] 2017-04-12 04:20:02 UTC
You can disable inspector support by uninstalling Xamarin Workbooks & Inspector.
Comment 6 Jahmai 2017-04-12 04:33:31 UTC
Only in VS2015. In VS2017 there doesn't seem to be a way to uninstall or disable it.
Comment 7 Sandy Armstrong [MSFT] 2017-04-12 14:09:47 UTC
You must uninstall from Add/Remove Programs.
Comment 8 Jahmai 2017-04-13 12:01:45 UTC
There is no entry in Add/Remove Programs for VS2017 because it's integrated in the VS2017 installer. However, I found in the VS2017 installer if you Modify the installation you can then uncheck "Xamarin Workbooks" under "Mobile Development with .NET".
Comment 9 Sandy Armstrong [MSFT] 2017-04-13 14:47:16 UTC
Did you check Add/Remove Programs? It is a global install even if provided by the VS2017 installer. If it doesn't show up in ARP, that's a bug.
Comment 10 Jahmai 2017-04-14 01:16:51 UTC
I have both VS2015 and VS2017. Xamarin msi installs into VS2015 only. To install in VS2017, you must use the VS2017 installer.

In Add/Remove programs, Xamarin Workbooks and Profiler was listed, which I uninstalled. This fixed VS2015, but not VS2017.

Then I opened the VS2017 installer, and unchecked Xamarin Workbooks from Mobile development with .NET - this fixed VS2017.
Comment 11 Mike Griffey 2017-05-04 20:10:18 UTC
I can confirm that "Xamarin Workbooks" is not in Add Remove programs. It is unfortunate that the solution is to uninstall the application. What impact will this have on Xamarin project creation/editing/debug/runtime? I am assuming it does more than just flood the debug window with useless buggy messages.

Jahmai's suggestion works though.
Comment 12 Haunted Man 2017-05-27 01:37:51 UTC
I have a C++ console application and get the following error (no Xamarin in use at all):
[Inspector] Error preparing project for inspection: System.NullReferenceException: Object reference not set to an instance of an object.
   at Xamarin.VisualStudio.Inspector.VSAgentExecutionTarget..ctor(Project proj) in C:\d\lanes\4699\c8715752\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\VSAgentExecutionTarget.cs:line 38
   at Xamarin.VisualStudio.Inspector.VSInspectorSession.CreateAgentExecutionTarget() in C:\d\lanes\4699\c8715752\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\VSInspectorSession.cs:line 84
   at Xamarin.Interactive.IdeSupport.InspectorSession.Prepare() in C:\d\lanes\4699\c8715752\source\xamarinvs\External\inspector-ide-integration\Xamarin.Interactive.IdeSupport\InspectorSession.cs:line 95
   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.RefreshInspectorSession() in C:\d\lanes\4699\c8715752\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 136

using VS 2017 Community 15.2 (26430.6)...
Comment 13 Sandy Armstrong [MSFT] 2017-05-27 13:41:55 UTC
Mike Griffery, Haunted Man:

This error can be safely ignored. It has no impact on anything, short of polluting the Output window.

It goes away completely in an upcoming 15.3 update.
Comment 14 Travis Whidden 2017-06-05 19:52:18 UTC
Still, annoying in the output window when you are debugging something in the output window. Is there an estimated date on the 15.3?
Comment 15 Sandy Armstrong [MSFT] 2017-06-05 20:21:37 UTC
Sorry, I don't know the schedule for it. But the code is merged and previews should be releasing soon.

If you are not currently using Workbooks or Inspector, you could uninstall it as a temporary work around.
Comment 16 Sandy Armstrong [MSFT] 2017-06-05 20:23:47 UTC
And to be clear, we've also changed Inspector output to appear in the Xamarin pane of your Output window, so even if other errors occur they shouldn't be as in your face.
Comment 17 Shimmy 2017-07-17 21:20:52 UTC
I'm still experiencing the issue.
I keep on getting an error message popping up each time VS fires up. I'm on VS 15.2 (26430.16).

Here are latest relevant entries from the ActivityLog.xml:

 <entry>
    <record>833</record>
    <time>2017/07/17 21:10:17.653</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [XamarinInspectorPackage]</description>
    <guid>{91D3BF5A-049A-4C78-AF4B-9AC149ADD84B}</guid>
  </entry>
  <entry>
    <record>834</record>
    <time>2017/07/17 21:10:17.665</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>LegacySitePackage failed for package [XamarinInspectorPackage]Source: &apos;&apos; Description: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))&#x000D;&#x000A;System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))&#x000D;&#x000A;   at EnvDTE.SolutionBuild.get_StartupProjects()&#x000D;&#x000A;   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.GetStartupProject() in C:\d\lanes\4699\fec6f88f\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 272&#x000D;&#x000A;   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.RefreshInspectorSession() in C:\d\lanes\4699\fec6f88f\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 132&#x000D;&#x000A;   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.Initialize() in C:\d\lanes\4699\fec6f88f\source\xamarinvs\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 99&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)</description>
    <guid>{91D3BF5A-049A-4C78-AF4B-9AC149ADD84B}</guid>
    <hr>80070057 - E_INVALIDARG</hr>
    <errorinfo></errorinfo>
  </entry>
  <entry>
    <record>835</record>
    <time>2017/07/17 21:10:17.674</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [XamarinInspectorPackage](null)</description>
    <guid>{91D3BF5A-049A-4C78-AF4B-9AC149ADD84B}</guid>
    <hr>80070057 - E_INVALIDARG</hr>
    <errorinfo></errorinfo>
  </entry>
  <entry>
    <record>836</record>
    <time>2017/07/17 21:10:17.680</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>End package load [XamarinInspectorPackage]</description>
    <guid>{91D3BF5A-049A-4C78-AF4B-9AC149ADD84B}</guid>
    <hr>80070057 - E_INVALIDARG</hr>
    <errorinfo></errorinfo>
  </entry>

HTH
Comment 18 Sandy Armstrong [MSFT] 2017-07-17 23:11:27 UTC
Thanks Shimmy. This is fixed in 15.3.
Comment 19 Shimmy 2017-07-17 23:14:13 UTC
Oh I missed that in the previous comments, sorry and thanks Sandy!
Comment 20 softlion 2017-11-28 13:57:27 UTC
[Inspector] Error preparing project for inspection

Just Appeared in 15.4

Uninstalling workbook + inspector.
Impact for me: no more connection to mac.
Comment 21 Sandy Armstrong [MSFT] 2017-12-04 16:45:32 UTC
@softlion can you share your logs from %LOCALAPPDATA%\Xamarin\Logs\{VS version}\Inspector {date}.log ?
Comment 22 Delbert Matlock 2018-05-08 10:52:49 UTC
It looks like this error may have come back.  I updated Visual Studio 2017 to 15.7 yesterday and started getting the inspector errors.  Here is my log.

Xamarin.Inspector: Information: 0: Inspector extension loaded
Xamarin.Inspector: Error: 0: [Inspector] Error preparing project for inspection
System.NullReferenceException: Object reference not set to an instance of an object.
   at Xamarin.VisualStudio.Inspector.VSInspectorSession.Create(Project proj, IServiceProvider serviceProvider) in E:\A\_work\6\s\src\Features\VisualStudio.Inspector\Vsix\VSInspectorSession.cs:line 54
   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.RefreshInspectorSession() in E:\A\_work\6\s\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 166
Xamarin.Inspector: Error: 0: [Inspector] Error preparing project for inspection
System.NullReferenceException: Object reference not set to an instance of an object.
   at Xamarin.VisualStudio.Inspector.VSInspectorSession.Create(Project proj, IServiceProvider serviceProvider) in E:\A\_work\6\s\src\Features\VisualStudio.Inspector\Vsix\VSInspectorSession.cs:line 54
   at Xamarin.VisualStudio.Inspector.XamarinInspectorPackage.RefreshInspectorSession() in E:\A\_work\6\s\src\Features\VisualStudio.Inspector\Vsix\XamarinInspectorPackage.cs:line 166