Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

publishing asp.net website give "Object reference not set to an instance of an object." error

I am getting fed up with this error. I have search all over the web and tried every possible suggestion to this error I could find.

  1. delete app_code, build, add files back, publish. (did not work)
  2. delete temporary asp.net files (did not work)

In the end I even tried the command line and get the following stacktrace.

error ASPRUNTIME: Object reference not set to an instance of an object.

[NullReferenceException]: Object reference not set to an instance of an object.
   at System.Web.Compilation.BuildManager.CopyPrecompiledFile(VirtualFile vfile,
 String destPhysicalPath)
   at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.CopyStaticFilesRecursive(VirtualDirect
ory sourceVdir, String destPhysicalDir, Boolean topLevel)
   at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath star
tingVirtualDir)
   at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirt
ualDir)
   at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallba
ck callback)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCa
llback callback)
   at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCa
llback callback)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuil
dManagerCallback callback, Boolean forceCleanBuild)
   at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuil
dManagerCallback callback)
   at System.Web.Compilation.Precompiler.Main(String[] args)

I used the following command line:

aspnet_compiler.exe -p d:\code\websites\brokerweb -v / d:\code\websites\published -f -c -errorstack -u
like image 233
Johan Avatar asked Feb 18 '10 14:02

Johan


People also ask

How do I fix object reference is not set to an instance of an object?

To fix "Object reference not set to an instance of an object," you should try running Microsoft Visual Studio as an administrator. You can also try resetting the user data associated with your account or updating Microsoft Visual Studio to the latest version.

How do I fix object reference not set to an instance of an object in IIS?

To resolve this, modify the Application Pool identity of IIS: Open IIS Manager. In the Connections pane, expand the server node and click Application Pools. On the Application Pools page, select the application pool that you want to specify an identity.

How do I fix NullReferenceException in C#?

You can eliminate the exception by declaring the number of elements in the array before initializing it, as the following example does. For more information on declaring and initializing arrays, see Arrays and Arrays. You get a null return value from a method, and then call a method on the returned type.

What does the error'object has no reference'?

This error's description speaks for itself but when you do not have much experience in development, it is very difficult to understand. So, this error description says that an object that is being called to get or set its value has no reference. This means that you are trying to access an object that was not instantiated. Why should I know this?

What is object reference not set to an instance of an object?

Object reference not set to an instance of an object error is one of the most common errors when developing .NET applications. Here are five most common mistakes that result in this error. In this article, also learn how to fix error, object reference not set to an instance of an object. Why does this error happen?

What is error 102 in ASP NET?

Error 102 :Object reference not set to an instance of an object. Our Error list contains Description,file,line ....columns.But this error contains only description and all other deatails are absent.So i am unable to find error location. Thomas Sun –... Please make sure there is not build error in your ASP.NET project.


3 Answers

This error was occurring for me when I tried to compile the project with MSBUILD - it would build fine within Visual Studio, and would even Debug in my local browser. The Publish option within VS worked, as well. But the command-line MSBUILD was causing the project to error out every time.

I managed to fix this problem in VS 2012 by opening the Property Pages on my Website, opening the 'MSBuild Options' tab, and unchecking the 'Allow this precompiled site to be updatable' option, then hitting 'save all'.

like image 107
Chris Stafford Avatar answered Oct 29 '22 11:10

Chris Stafford


This typically happens when a *.dll.refresh file in the bin directory points to a location that is no longer available. Deleting the *.dll.refresh files should resolve the issue.

like image 39
samiz Avatar answered Oct 29 '22 10:10

samiz


I had the same experience and removing the compressed flag from the solution directory tree, set the compiler working again.

like image 29
PTBW Avatar answered Oct 29 '22 12:10

PTBW