none
publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location

    Question

  • when i try to publish any project app on my server and i got this error

    publish has encountered an error Object reference not set to an instance of an object A diagnostic log has been written to following location 




    Log File:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.InitializeProvider(IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.<CreateViewAsync>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.ManagedPublishProvider.<CreateViewAsync>d__1.MoveNext()

    Saturday, February 10, 2018 7:33 PM

All replies

  • Hi Mike,

    Welcome to the MSDN forum.

    Did you meet this issue when you click the Publish tab? If you create a new ASP.NET web application and directly click the Publish tab, does this issue persists or not?

    If this issue happens for all ASP.NET applications, please try to re-run the VS 2017 installer as administrator, More-Repair to repair VS and test it again.

    Meanwhile, you can try to create a new project like Console app and right-click the project name, choose ‘Publish’ to check other publish function works fine or not.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Sunday, February 11, 2018 3:05 PM
    Moderator
  • Hi,
    I've got the same issue that's driving me crazy (it happened to all my laptops after the 15.5 update) and web publish doesn't work anymore. It's a hell!!!!
    Il'try to update to 15.6 and than I'll follow your suggestion.

    Tuesday, March 6, 2018 9:17 PM
  • I installed 15.6 update, then I tryed to publish (as Administrator): again error!
    Then: i tryed to repair the installation as you suggested (as Administrator), after that i published: again same error.
    How can i figure out a way to workaround this issue?
    Wednesday, March 7, 2018 9:28 AM
  • I solved the problem: I reduced the depth of my project's path and removed every blank space in the name of my first container folder of the project, than the publishing worked!!!
    Wednesday, March 7, 2018 9:47 AM
  • Hi Andrea Remedy,

    I'm so glad to hear that your issue is solved and thank you for your sharing, that will help other community members.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Proposed as answer by sdharshraj Monday, March 19, 2018 9:39 AM
    Thursday, March 8, 2018 7:40 AM
    Moderator
  • I was also having the same problem in VS 2017 but i found the solution

    Just open your folder explorer and delete all the files which does not have name, i had two such files i deleted and now its working fine.

    • Proposed as answer by sdharshraj Monday, March 19, 2018 9:41 AM
    Monday, March 19, 2018 9:41 AM
  • I was also having the same problem in VS 2017 but i found the solution

    Just open your folder explorer and delete all the files which does not have name, i had two such files i deleted and now its working fine.

    What does, "delete all the files which does not have a name" mean? What name?
    Monday, April 9, 2018 7:15 PM
  • Arg, very frustrating. I'm getting the same error. I think this is the first time I've deployed this project from this computer. It's a reason I try to stay with "generic" technology (e.g., php and ftp)...

    Here is the contents of my log file:

    4/9/2018 1:16:27 PM
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.InitializeProvider(IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.<CreateViewAsync>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.ManagedPublishProvider.<CreateViewAsync>d__1.MoveNext()
    ===================

    Thanks for your assistance.

    Monday, April 9, 2018 7:22 PM
  • I have the same problem. Visual Studio version is 15.7.1

    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.VisualStudio.Docker.DotNetCore.DockerWorkspaceService.GetCurrentTargetOSAsync(IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.Web.Azure.Publish.AppServiceContainerProfileVisualFactory.<>c__DisplayClass24_1.<IsApplicableTo>b__0()
       at Microsoft.VisualStudio.Threading.JoinableTaskFactory.ExecuteJob[T](Func`1 asyncMethod, JoinableTask job)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
       at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
       at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
       at Microsoft.VisualStudio.Web.Azure.Publish.AppServiceContainerProfileVisualFactory.IsApplicableTo(IVsHierarchy hierarchy, IReadOnlyList`1& tags)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.LoadFactories(IPublishServiceProvider serviceProvider, IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel..ctor(Dispatcher dispatcher, IAsyncServiceProvider vsServiceProvider, IPublishServiceProvider serviceProvider, IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.CreateViewAsync(IVsHierarchy project, IAsyncServiceProvider serviceProvider, CancellationToken cancellationToken)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.ManagedPublishProvider.<CreateViewAsync>d__1.MoveNext()

    • Edited by kiloolik Thursday, May 17, 2018 8:10 AM
    Thursday, May 17, 2018 7:01 AM
  • I encountered this problem recently and was surprised to see that I posted on this thread earlier this year (I hadn't found a solution). This time, however, I found another thread on this topic that said to upgrade VS. I did and the problem went away. Go figure.
    Thursday, June 7, 2018 5:39 AM
  • Hi,

    I also got a NullReferenceException when trying to publish a asp.net core project linked to a docker project. I finally found that if the docker project is unloaded then the exception occurs, if I load it again then the exception does not occur anymore.

    Hope that helps.

    • Proposed as answer by yashif Monday, May 13, 2019 5:38 PM
    Sunday, September 23, 2018 6:29 PM
  • Hi,

    I have encountered this error in the past and have determined that it can be related to 3 things.

    1.  After cleanup there are files left over in the debug folders of each project causing the error.

    or

    2.  You have common assemblies, nuget dlls, loaded to tfs that get pulled with readonly access.

    or

    3.  The .vs (hidden) folder is read only and can't be written to.

    Close visual studio.

    Go through each project folder in your solution and delete the debug folders in the bin.

    Then go to the folder where your solution file exists and show hidden files and folders.  the .vs folder will appear.  Ensure that this is not read only.

    4.  Go to the folder above that and ensure that all files and folder for the solution are not read only.

    Reopen your solution.  Should fix the issue...


    • Edited by CLShelton Wednesday, October 24, 2018 9:00 PM typo
    Wednesday, October 24, 2018 7:03 PM
  • I had the problem and tried a few other suggestions, i found that my .vs folder was read only, thanks CLShelton. It now nicely asks me to install the Publish extension.
    Thursday, January 31, 2019 2:55 PM
  • That worked for my case.
    Tuesday, February 5, 2019 1:03 PM
  • I have same Issue and i found the Problem and published Successfully.

    commonly this type of issue comes due to file missing check all file including Js and css file

    there may be a chance that some file is preset in project but physically not present look on all the file if there is missing of file include file if file is necessary for the project or Exclude if file is not present.

     
    • Edited by Praveen_jha Wednesday, February 6, 2019 5:24 AM
    Tuesday, February 5, 2019 2:32 PM
  • Win10 Pro - Visual Studio 2017 Pro v15.9.6

    Well I'm having exactly this same error message and logs on 

    2/11/2019 2:07:54 PM
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.InitializeProvider(IVsHierarchy hierarchy)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.DefaultPublishTabProvider.CreateViewAsync(IVsHierarchy project, IAsyncServiceProvider serviceProvider, CancellationToken cancellationToken)
       at Microsoft.VisualStudio.ApplicationCapabilities.Publish.Provider.ManagedPublishProvider.<CreateViewAsync>d__3.MoveNext()
    ==================

    But I did found out that Using the Web Publish Activity Tab Publish button I can publish without any changes to anything in the project. This behavior replicates all over my different apps +10.

    Any help solving this? 

    Monday, February 11, 2019 7:40 PM
  • I just want to add my two cents to this. I got the same message. In my case all I had to do was to open Visual Studio Installer and add Azure development tools. I don't know what exactly I was missing but something fixed it. Maybe this will help someone, maybe not.
    Wednesday, February 13, 2019 11:36 AM
  • Hello guys!

    I ended up having this same problem, after a lot of research and testing I discovered the reason for this error.

    As commented in some answers, it has a lot to do with permission of the projects / files folders, to solve this problem, simply access your solution in Administrator mode, so the permission issue is resolved and you can publish your project.

    Any doubts I am available!
    Monday, February 25, 2019 3:45 PM
  • Thank you Ldoppea. This solved it for me!
    Thursday, March 7, 2019 6:22 PM
  • had the same issue worked when I reload the docker project

    thanks @Ldoppea


    • Edited by yashif Monday, May 13, 2019 5:40 PM
    Monday, May 13, 2019 5:39 PM
  • Really,Thank you so much

    Tuesday, June 18, 2019 1:25 PM