ASP.NET Page says I need to reference an assembly that does not exist!

My asp.net site has to run on several client servers. It’s working fine on a majority of them, but a couple have run into an error message on a few pages:

Compiler Error Message: CS0012: The type ‘MetaNameValuePair’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘App_Code.t_3vcono, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’.

The type ‘MetaNameValuePair’ is actually defined in a .cs file within my App_Code folder, not an external assembly. Is it failing to compile that .cs file?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Attempt 1:

A similar question was asked a couple of months back and look at those answers.

Attempt 2:

Have you cleared the “Temporary ASP.Net Files” for the site, usually found at C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files? There may be an old copy lingering around.

Method 2

For some special cases you could get rid of this if you disable batch compilation in the Web.config file like this:

<system.web>
    ...
    <compilation debug="true" targetFramework="4.0" batch="false" />
    ...
</system.web>

After compiling, you can change the value back to True or remove the “batch” attribute, and then rebuild successfully.

Method 3

Had this numerous times. The solution is to close and open Visual Studio.

In my case at least it seemed to hove something to do wit

Method 4

None of the solutions worked for me. The code that it is complaining about is this:

thisSession = ((SiteMasterPage)this.Master).foo;

I’m casting the page’s generic master page to the specific master page which grants me access to the foo object on the page’s master page which is a complex object with trivial user data.

If you want to know why I’m doing this, it’s because so far it’s the best solution. Requirements dictate that I cannot extend the page class, no session variables, or cookies, and it must be user specific data.

I don’t have enough reputation to comment, so I have to reply in an answer. 🙁

Method 5

The above solutions have worked for me in the past, but not this time.

I finally found the cause: one of those server side tags (like <%# Eval(“Something”) %> ) from the attribute of a control on the aspx page.

I’d added it shortly before the problem appeared, and removing it made the problem go away. It was in a TemplateField on a GridView.

Bizarre, but that’s what did the trick.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x