8

I'm Trying to publish a website, using Visual Studio 2013. I'm getting an error:

ASPNETCOMPILER(0,0): Error ASPRUNTIME: Object reference not set to an instance of an object.

It happens also on Visual Studio 2010. I tried to restart VS, and PC. I removed *.dll.refresh from my bin directory. I don't have <clear/> tags in my web.config. I think it all started when I accidently removed my *.suo file.

Any ideas?

Update:

I just noticed it happens only when I try to precompile my site. If I publish without precompilation it works fine...

Shoham
  • 7,014
  • 8
  • 40
  • 40
  • Would be better if we see your work as well. Please read [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Soner Gönül Nov 10 '14 at 07:42
  • @SonerGönül dear sir,i read your comments many times,I want to thank you for your polite comments and trying to help us – Nima Derakhshanjan Nov 10 '14 at 09:00
  • 1
    @SonerGönül Thanks but thats not the case. The error is just in the publish process. Not on runtime. The website runs just fine. – Shoham Nov 10 '14 at 10:15
  • This seems to be a known issue with the ASP.NET website precompiler. We also have the issue on the build machine, but not on desktops... – leppie Nov 10 '14 at 12:54
  • @leppie did you solve it somehow? I tried 2 versions of VS but no luck – Shoham Nov 10 '14 at 15:58

7 Answers7

9

I also had this problem and it was not solved by any of the ideas mentioned previously. The problem was that somehow compresssion had been enabled on the subfolder of my drive containing the ASP.NET website. The solution is to right-click, choose properties and in the general tab, click Advanced and under the 'Compress or Encrypt attributes' section, make sure 'Compress contents to save disk space' is unchecked. Upon prompting do this for all files and subfolders (note it may take some time). Hope this helps someone.

Alexis
  • 1,325
  • 1
  • 11
  • 14
  • I had the same problem too - caused by folder compression. Took ages to pin that one down. – daughey Jun 08 '15 at 14:38
  • I publish to an encrypted BitLocker drive. I wonder if that is why I sometimes experience this (more often with lager projects) – Radderz Jun 07 '19 at 12:26
8

OK. After wasting so many hours I somehow got to this blog: http://thesoftwarepractice.net/development-things/object-reference-not-set-to-an-instance-of-an-object

Turned off the McAfee Real Time Scanning and its works...

Shoham
  • 7,014
  • 8
  • 40
  • 40
  • Hi Shoham, I have McAfee agent in my laptop and can't turn it off. But I can still manage to run from the command line `C:\Windows\Microsoft.NET\Framework\v4.0.30319>MSBuild.exe /t:build /p:Configuration=Release /p:Platform="Mixed Platforms" "D:\Test.sln" > "D:\Build.log"} ` but when I put the same script inside a bat file and run this bat file from the command line, I got the error you have got. What could be the possible issue. – kevin Apr 17 '15 at 06:37
  • Are you running the script as administrator? Also, when I say turn the McAfee off I mean: Right click on McAfee icon > Quick settings > On access virus scanning. This should turn it off for a few minutes. If this is not possible, I saw somewhere an option to exclude the build target directory from scanning... Try to search that. – Shoham Apr 19 '15 at 07:41
  • I can't turn it off since I don't have Admin rights. Oh we can exclude the build target directory from scanning ? Let's me google it. Thank you. – kevin Apr 20 '15 at 08:59
  • This was my issue as well. What's puzzling is that the McAfee logs show NO record of blocking the compiler. There's plenty of entries for McAfee blocking itself from doing an update, but nothing for the compiler. I'm guessing the policy being broken is "Disallow programs from being run from temporary/download folders" since the compiler puts everything in a Temp folder to prepare for publishing. Going to look and see if it's possible to change the temp folder location, because I doubt my company wants me turning off my AV. – Andrew S Nov 17 '17 at 18:04
1

This is a hard to catch issues, which usually comes with webforms aspx pages.

If you are deploying the app with pre-compiled option and you have selected the "Do not merge, create a separate assembly for each page and control" here:

enter image description here

then you need to make sure that there are no compiled assemblies for any of the aspx pages in the bin folder of the project you are trying to compile. Go to your bin folder and delete any assemblies related to your web pages and try publishing again. This will fix this issue.

Zeeshan Adil
  • 1,937
  • 5
  • 23
  • 42
0

Have you tried creating a new website, adding all the files from old website to the new one and adding all the references used?

0

I also had this issue, and I fixed it by clearing and re-configuring all the dependencies and the dll's of the project.

RomanY
  • 376
  • 2
  • 9
0

I have deleted files from bin folder and then build solution and publish application. It works for me.

0

In my case was only failing from commandline (msbuild), and from CI agents. The solution I've found is to disable the check "Allow precompiled site to be updatable in Project->Page Properties->MsBuild

enter image description here

dave
  • 2,291
  • 3
  • 19
  • 25