[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.NET C#: "object reference not set to an instance of an object" in ASPNETCOMPILER

Posted on 2014-08-15
10
Medium Priority
?
424 Views
Last Modified: 2015-04-20
Hi

I have a website made in VS 2012. The site builds, complies and runs without problem on my localhost. However, when I try and publish the website I get this error:

"Oject reference not set to an instance of an object" in the file ASPNETCOMPILER.

I have searched the net for a solution, and I have found various solutions, but non of them have worked.

Here are some of the things I have tried so far:

- Deleting all dll files in the Bin folder with the extension .Compiled
- Deleting all dll files in the Bin folder with the extension .Refresh
- Disabling my anti virus
- Trying to compile the website from another computer
- Moving the website from the development server to my local computer and publish it from there

Anyone else how have had this problem and found a solution not mentioned above?

Thanks in advance.
0
Comment
Question by:poultarp
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 40262690
>>Oject reference not set to an instance of an object

If you looked within ExpertsExchange for this error you will find hundreds if not thousands of hits.
Basically it is the following where X is for example a class type.

X x;  //x has a default value of null - it does not exist
x.DoSomething();  //error

and the solution is simple
X x = new X();  //create an instance of X
x.DoSomething();  //is OK because x has been created
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40262704
Does your project use any third-party libraries that may be missing from your production server?
0
 
LVL 1

Author Comment

by:poultarp
ID: 40262720
@AndyAinscow

The problem is not when I build, complie or run the website, the error comes when I publish the website.

I can even copy the entire website to the server and the site runs as it should. I just need to be able to publish it so I don't have to copy every single file to the webserver.

@Carl Tawn

I don't think so, but I will check up on it as soon as I get the chance.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 45

Expert Comment

by:AndyAinscow
ID: 40262723
>>the error comes when I publish the website.

Yes, that is what puzzles me a bit.  It sounds like something is missing or the publishing tool has a bug.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40262899
Just to confirm: your project type is a web site or a web application?
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 40264948
There is some setting for publishing of website. The setting say to include files that are required by this website.

So I'm assuming that the compiler is not publishing some dll or the file that might be required for your website. I faced such issue when I published website with MySql.

The MySql.Web.dll depends on MySql.Data.dll file. But compiler wasn't publishing it for any reason. Therefore as hint to detect -

1. Build your project in release mode. As that is the by default mode for publishing too.
2. Cross-match files in Release folder with the published files.
3. I suspect that there might be some of files missing in published folder.
4. Copy those missing files in published folder.
5. Test your website. Should work fine if steps 1 to 4 matched.
0
 
LVL 1

Author Comment

by:poultarp
ID: 40267004
@kaufmed

Im 99% sure the type is a Web site. Anywhere I can confirm this?

@Vikram

No files are put in my publish folder - the error comes before any files are created.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40267158
Can you post the full build log from when you try and publish? i.e. the contents of the "Output" window.
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 750 total points
ID: 40267188
Please supply what options/settings you are using.  Is this just one application or do you have nested applications?
0
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 750 total points
ID: 40267410
I do agree with @AndyAinscow for his statement for nested applications.

Might be you are using multiple projects in a single solution. For e.g. projects named as A and B.

The project A might be referencing dlls from project B. However the build order would be opposite. Might you are building project A first instead of project B. So project A is not able to find respective dlls or references.

And so could be one of the reason for issue.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question