Bug 14817 - ArgumentNullException thrown when attempting to add a file a solution
Summary: ArgumentNullException thrown when attempting to add a file a solution
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Add-in ()
Version: 4.1.11
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: master
Assignee: Greg Munn
URL:
Depends on:
Blocks:
 
Reported: 2013-09-17 15:24 UTC by Stephen Rawlins
Modified: 2014-12-11 15:48 UTC (History)
2 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 or GitHub 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 NOT_REPRODUCIBLE

Description Stephen Rawlins 2013-09-17 15:24:36 UTC
Whether by right-click "Include To project" (pointing at a revealed file in the folder) or by any of the include (all files, or some files) from folder, I get an Exception (see traceback details below).

My workaround is to go to VisualStudio2012, add the file(s), then go back to Xamarin.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Argument cannot be null.
Parameter name: path2
  at System.IO.Path.Combine (System.String path1, System.String path2) [0x000be] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.IO/Path.cs:126 
  at MonoDevelop.Core.FilePath.Combine (System.String[] paths) [0x00018] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs:160 
  at MonoDevelop.MonoDroid.MonoDroidProject.GetDefaultBuildAction (System.String fileName) [0x000e7] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/md-addins/MonoDevelop.MonoDroid/MonoDevelop.MonoDroid/MonoDroidProject.cs:904 
  at MonoDevelop.Projects.Project.AddFiles (IEnumerable`1 files, System.String buildAction) [0x00030] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:352 
  at MonoDevelop.Projects.Project.AddFiles (IEnumerable`1 files) [0x00004] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:314 
  at MonoDevelop.Ide.Gui.Pads.ProjectPad.SystemFileNodeCommandHandler.IncludeFileToProject () [0x0015b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs:178 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.Reflection/MonoMethod.cs:230 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00069] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.Reflection/MonoMethod.cs:238 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.2.1/mcs/class/corlib/System.Reflection/MethodBase.cs:114 
  at MonoDevelop.Components.Commands.DefaultCommandHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00019] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:2094 
  at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00009] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CustomCommandTargetAttribute.cs:101 
  at MonoDevelop.Ide.Gui.Components.NodeCommandHandler+TransactedNodeHandlerAttribute.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x0002d] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeCommandHandler.cs:296 
  at MonoDevelop.Components.Commands.CustomCommandTargetAttribute.MonoDevelop.Components.Commands.ICommandTargetHandler.Run (System.Object target, MonoDevelop.Components.Commands.Command cmd) [0x00004] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CustomCommandTargetAttribute.cs:58 
  at MonoDevelop.Components.Commands.CommandHandlerInfo.Run (System.Object cmdTarget, MonoDevelop.Components.Commands.Command cmd) [0x00021] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1963 
  at MonoDevelop.Components.Commands.CommandManager+<DispatchCommand>c__AnonStorey7A.<>m__C9 () [0x0005f] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1054 
  at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x002b0] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-4.0.12-branch/593d7acb/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1071
Comment 1 Stephen Rawlins 2013-09-17 15:51:53 UTC
NOTE: I updated on the Alpha channel, installing 4.1.11, but got the same error.
Comment 2 Mikayla Hutchinson [MSFT] 2013-09-19 15:08:56 UTC
Does your csproj have a MonoAndroidAssetsPrefix value?
Comment 3 Stephen Rawlins 2013-09-19 15:44:48 UTC
Hi Michael,
I searched my csproj (Droid.Container.csproj) and, no, there is no MonoAndroidAssetsPrefix.

So I added:
     <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
into the:
  <PropertyGroup>

Reloaded my project and now the "Include To project" succeeds, where it was failing before.  The file(s) I was attempting to include were in the Asset folder, so this relationship makes sense.

Thank you!   I appreciate your quick response.   May I please squeeze-in a follow-up question?

This csproj was created in Visual Studio, then opened in Xamarin.  The VS project does not, apparently, add the <MonoAndroidAssetsPrefix>.

Why is this required in Xamarin Studio when Visual Studio does not require it?
Comment 4 Greg Munn 2014-12-11 15:48:25 UTC
Closing as the workaround in comment#3 has solved the issue and this does not appear to be a recurring issue. Likely it was resolved long ago.

Feel free to reopen and add additional information if this is still a problem for you.