question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object reference not set to an instance of an object after publish

See original GitHub issue

I’m having trouble when publishing my application. Published output doesn’t work, with error:

Object reference not set to an instance of an object

Steps to reproduce

  1. Create Empty ASP.NET Core Web Application (.NET Core)
  2. Setup simple project.json
{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": { }
  },

  "buildOptions": {
    "emitEntryPoint": true
  },

  "runtimes": {
    "osx.10.11-x64": { },
    "win8-x64": { },
    "win10-x64": { },
    "ubuntu.14.04-x64": { }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
  1. dotnet restore
  2. dotnet run
  3. “Hello world” is visible in browser at http://localhost:5000
  4. dotnet publish -r win8-x64 -o “c:\tmp\Publish”
  5. Navigate to output directory “c:\tmp\Publish”
  6. dotnet run
  7. dotnet run -p WebApplication4.dll - doesn’t work either

Expected behavior

Application will start the same way as before publish

Actual behavior

Object reference not set to an instance of an object.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.2.9200
 OS Platform: Windows
 RID:         win8-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
tmdscommented, Jun 8, 2016

To run a published application, don’t use run, just dotnet myapp.dll.

0reactions
stevenshortcommented, Sep 6, 2016

Ugh, @tmds thank you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish Errors -> Object reference not set to an instance of ...
I installed SSMS 17.8, deinstalled SSM 16, and repaired JetBrains, after that rebooted. The issue is now gone. I repair the publish file...
Read more >
Error when I click publish | "Object reference not set to an ...
I'm trying to publish the files of a project I just created in Visual Studio 2012. ... Already created a new web project...
Read more >
Fix: "Object Reference Not Set to an Instance of ...
If you receive the "Object reference not set to an instance of an object" error on your Windows computer, it might be caused...
Read more >
Object Reference Not Set to an Instance of an Object
This exception is thrown when you try to access a member—for instance, a method or a property—on a variable that currently holds a...
Read more >
Solved: Can't publish - Object reference not set to an ins...
I have a couple of reports that I update monthly and then publish and share the dashboard. No major changes this month -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found