ASP.NET: Could not load type - asp.net

I'm getting the following error:
Could not load type 'Intel.Intel'.
I copied my entire Visual Studio 2010 folder before I formatted my computer and I copy/replaced the same folder with this one after I installed windows again. I'm running this locally not on a host server. Anyone know what I'm doing wrong? I've search google and find many pages giving solutions for this, but none seem to fix my problem. Let me know if I need to provide anymore additional information. Thanks!
Update: Sorry I was unclear I copied the "Visual Studio 2010" folder from under my documents. I've installed Visual Studio 2010 Premium from my MSDN account.
Update 2: I also forgot that I was getting this error below before the Could not load type error. I fixed it by replacing the "~" with ".". The strange thing is that while that will seem to fix that error -- If I try locating the file through the "Pick Master.." option when retyping "MasterPageFile=" it will give me the path with the tilda and yet it wont work. I don't know if this helps identify the overall problem or not.
The file '/Intel.Master' does not exist.
And below notice the "~/Intel.Master" -- as mentioned above I can get rid of this error by changing that to "./Intel.Master"
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Intel.Master" CodeBehind="Index.aspx.vb" Inherits="Intel.Index" %>

Found a solution.
I looked in IIS Manager and I found that my application was a folder icon and not an application icon. So I right clicked it and selected "Convert to Application". After doing this it solved that error and now I have another one. I feel however that this solution did "fix" the problem.

There are a bunch of registry settings that would be missing installing in this manner. Also there are components (shared) that are installed outside of the VS2010 folder.
Your best bet would be to re-install Studio in the usual (from media) route.
Based on EDIT:
The types that are missing look like they were previously stored in the GAC. Delete the reference in the project and re-create referencing the actual assembly file (DLL)

To add the reference back in to you project, open your project, drop down your solution folder, then your projct - find the references node, right click it choose add refernce, go to browse .net assemblies and or file tab depending on where the dll is, find your dll and double click on it.

Replace the CodeBehind By CodeFile and remove the namespace. before the Inherits class name. For example:
Wrong:
<%# Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/Intel.Master" **CodeBehind**="Index.aspx.vb"
Inherits="**Intel.Index**" %>
Right:
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Intel.Master" **CodeFile**="Index.aspx.vb"
Inherits="**Index**" %>
it works I promise

Related

'MasterPage' does not contain a definition for

I'm wondering all the possible reasons i might get a errors like:
'MasterPage' does not contain a definition for ...
or
The name '...' does not exist in the current context
I know that these errors are NOT code related. This is a new project that i just pulled from source control. My colleagues are running perfectly fine with this same code which leads me to believe the issue is locally with my dev environment. I thought it might be a file permission issue and so i reset the file permissions on the entire solution which did not resolve the issue.
What am i missing? Why are my ASPX pages throwing these errors at me?
Any ideas on where to look next to resolve this would be awesome.
TIA
UPDATE:
I managed to resolve all the errors i was seeing by actually running
the solution (despite the Visual Studio errors i was getting). Once i
stopped and came out of debug mode, the errors were gone in Visual
Studio.
I would very much like to know what is happening with VS that after
running the solution the errors resolve?!?! Is VS creating some sort
of reference behind the scenes?
Very confused....
Check the code behind file. If you aspx page has something like this:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="AdminMaster.master.cs" Inherits="admin_AdminMaster" %>
(admin being the sub-folder name), then code behind should look like:
public partial class admin_AdminMaster : System.Web.UI.MasterPage

The 'CodeFile' attribute cannot be used without an 'Inherits' attribute

I'm new to building .net applications and I have done alot of research on this, I'm trying to publish a series of asp.net web pages and having been researching why the error is appearing and trying several ways to stop the errors. I've come to a dead end..So I get two types of errors which are :
Error 166 The 'CodeFile' attribute cannot be used without an 'Inherits' attribute. C:\Users\Aj\Code\admin\content.aspx 33
and
Error 148 Could not load type 'MasterPage'. C:\Users\Aj\Code\admin\content.aspx 2
The code identified is :
<%# Page Language="VB" AutoEventWireup="false" CodeFile="content.aspx.vb" Inherits="_content" MasterPageFile="../MasterPage.master" %>
<%# MasterType TypeName="MasterPage" %>
Key note:
This is one of many files which have the same error, and the master page file is in the parent folder.
Take a look for the output, it will show the real error instead of guess why CodeFile error.
You should look at the difference in Web Application Project vs Web Site Project. In a web application project, you publish the compiled assemblies while in a website project, you publish the source code. It looks like you may be trying to publish the source from a web app project. It is possible, with some work, to convert to a web site project.
Also, try changing your master file link to use ~/ syntax, it may be a path issue.

Where to find the codebehind?

I'm new to ASP, just inherited a database application. I'm having trouble with probably the most basic thing... how the file structures are set up.
I've confirmed I've found the right .aspx file of the page I'm working on, but it's just the template. I am looking for the code that is behind that file.
The page starts with:
<%# Page Title="" Language="C#" MasterPageFile="~/print.Master" AutoEventWireup="true"
CodeBehind="Servicecallreport.aspx.cs" Inherits="CrisisSupportApp.Secure.Reports.BriefSummaryReport" %>
I've done a search for "Servicecallreport.aspx.cs" and "CrisisSupportApp.Secure.Reports.BriefSummaryReport" on the server and I get nothing.
Where should I be looking for these .asp.cs files?
Look for a version control system like git, subversion, or TFS. The code is likely in there. ASP.Net does not need to deploy those code files to the web server at all, but instead allows you to pre-compile them.
try:
(what ever your root is)\CrisisSupportApp\Secure\Reports\BriefSummaryReport.cs

Error: "The file '/MasterPages/MainMaster.master' does not exist." (Yes, this file does exist!)

I just got a new desktop computer with Windows 7 Pro as the operating system. I installed Visual Studio 2008 on to this new computer and tried to open a previously existing ASP.NET 3.5 solution that displayed perfectly fine on my previous computer (this previous computer used the Windows XP operating system, IIS6, and IE7 browser). However, in Windows7/IE8, I’m receiving the following error:
Server Error in '/' Application.
Parser Error Description: An error
occurred during the parsing of a
resource required to service this
request. Please review the following
specific parse error details and
modify your source file appropriately.
Parser Error Message: The file
'/MasterPages/MainMaster.master' does not exist.
Source Error:
Line 1: <%# Page Language="C#"
AutoEventWireup="true"
CodeFile="default.aspx.cs"
Inherits="_Default"
MasterPageFile="~/MasterPages/MainMaster.master"%>
Line 2:
Line 3: <%# Register TagPrefix="SBLContent" TagName="SBLContentBlock"
Src="usercontrols/content.ascx"%>
Source File: /SBLWebSite/default.aspx
Line: 1
Version Information: Microsoft .NET
Framework Version:2.0.50727.4952;
ASP.NET Version:2.0.50727.4927
Please believe me when I tell you that the file ‘/MasterPages/MainMaster.master’ file does, in fact, exist.
In addition, this file’s location is properly referenced in the code (as indicated in Line 1 above), and as I said, was displayed properly by the browser in my previous computer. It might also be helpful to note that I’ve tried to navigate to other pages in this site, and this browser displays the same message for any and all master pages located in my MasterPages folder.
In summary, for some reason the browser cannot see any pages in the MasterPages folder. Can anybody tell me why I’m getting this error message when the folder and file is exactly where default.aspx says it is?
Thanks in advance!
I appreciate your response.
However, this issue turned out to be an IIS7 issue. The error message I described arose out of the distinction made in IIS7 between a "virtual directory" and an "application" (I don't know if such a distinction existed in IIS6). To fix this error, I opened IIS7, right-clicked on the virtual directory folder for this site, and selected "Convert to Application." I then refreshed the browser, and the error went away.
Sigh.
Two things to check:
When using "~" in a file path, make sure that the current application deployment believes the root directory is the same as it was before. (I've run into this sometimes moving an app from the VS Development Server and IIS.)
Make sure that the user account that the server is running under has permissions to access that directory. Since you just moved the code over from another computer and probably some intermediate storage devices, the security permissions may not be right.
the error comes on the web form like this
<%# Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="~/Site1.Master" CodeBehind="add_drivers.aspx.vb"
Inherits="au_transport.WebForm1" %>
correction
<%# Page Title="" Language="vb" AutoEventWireup="false"
MasterPageFile="Site1.Master" CodeBehind="add_drivers.aspx.vb"
Inherits="au_transport.WebForm1" %>
Instead of the "~" I was able to simply change the directory to a relative ".." So, what I originally had that gave me the problem was something like: "~/MasterPage/TheMainMasterPage.master" and this caused me to get the same error message. Changing it to "../MasterPage/TheMainMasterPage.master" fixed everything for me.
I recently had to move my websites from one server(32 bit) to another server(64 bit). On the new server I experienced the file not found error "Parser Error Message: The file '~/Master.master' does not exist"
NB: some of my applications were built for x86, you still need to convert your website to an application :-)
Solution:
In IIS8, click Application Pool -> select an app pool eg DefaultAppPool -> click 'Advanced Settings' -> Under the 'General' section set 'Enable 32-Bit Applications' to 'True' -> Click OK
Refresh your website/webservice and that should do the trick
previous code:-
<%# Page Title="" Language="C#" MasterPageFile="~/admin.Master" AutoEventWireup="true" CodeBehind="outgoingform.aspx.cs" Inherits="OCS.outgoingform" %>
after code changed:-
<%# Page Title="" Language="C#" MasterPageFile="../ocs/admin.Master" AutoEventWireup="true" CodeBehind="outgoingform.aspx.cs" Inherits="OCS.outgoingform" %>
change the code from everywhere from "~/admin.Master" to "~/ocs/admin.Master"
previous code:-
after code changed:-
change the code from everywhere from "~/admin.Master" to "~/ocs/admin.Master"
OK, so this is old and it is 2021 but, the path for your mater page has ~/site name/MasterPage.master or similar.
What I did to fix and because I uploaded to the server all in same directory, remove this ~/site name/ leave the name of the master page IE: MasterPage.master and all is well. make sure master page in same directory as other pages. Done.
What I had after edit...
<%# Page Title="" Language="VB" MasterPageFile="MasterPage.master"
do this for all pages
no site name or ~/ etc. What a pain but once you realize it is just a directory issue which in retrospect should have been obvious from the start.. all better now. Site up.

Visual Studio 2008 losing intellisense for ASCX with CodeBehind (but works for CodeFile)?

I have the following definition at the top of my .ASCX file:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ArticleView.aspx.cs" Inherits="MyNameSpace.ArticleView" %>
In that control I make use of <%= %> blocks to refer to members that I've declared in the code-behind file. If I compile and deploy the control, it works fine. But in Visual Studio I get a lot of design-time errors, "{some variable} does not exist in the current context." And Intellisense breaks too: it works for members of UserControl, but can't find my own declared members. There are other issues as well. In general, everything points to the fact that the ASP.articleview_ascx class getting generated is somehow not inheriting from the MyNameSpace.ArticleView class.
I've found that if I switch the CodeBehind attribute to "CodeFile":
<%# Control Language="C#" AutoEventWireup="true" CodeFile="ArticleView.aspx.cs" Inherits="MyNameSpace.ArticleView" %>
suddenly Intellisense works and all the design-time errors disappear. But I don't want to do runtime compilation, or deploy my .ASCX.CS files - so I can't use CodeFile.
I've checked the simple stuff, like making sure that my CodeBehind filename is correct & the Inherits class has the proper namespace, etc. (And since it works properly after changing the attribute to CodeFile, those must be pointing at the right place....) But what am I missing? Why can't it handle the CodeBehind attribute?
Thanks,
Steve
Update: from a thread below - basic question was, why not just use CodeFile? Answer: when I try to deploy using CodeFile= in my files, after deploying I receive the following stack trace (presented in its entirety):
/_layouts/Pages/ViewPage.aspx.cs' does not exist. at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath) at System.Web.UI.TemplateParser.ProcessCodeFile(VirtualPath codeFileVirtualPath) at System.Web.UI.TemplateParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)
(This is from a request to /_layouts/Pages/ViewPage.aspx. ViewPage is the page that has several other controls including the ArticleView mentioned in my original example. It just happens to be the first file that fails - if I go back to CodeBehind= in ViewPage, then included ASCX with CodeFile= will fail in the same way.) This seems to be the page compiler complaining because the inherited codebehind class can't be found in any loaded DLL, so it expects there must be a CS file to do on-demand compilation.
The issue here is that I don't want to deploy CS files, just ASPX/ASCX. Having read through many articles like this great one I'm aware of the various new models of deployment, although I've never used anything but a Web Application Project (converted forward from VS2003, we were late adopters of 2005 & the WAP model had already been added by the time we switched up from 2003.) Over many VS2005/8 projects, I've never had a problem with CodeBehind=, until this Intellisense issue showed up... though it doesn't help that in this case I'm deploying to SharePoint, which introduces a whole new level of complexity.
Since I've not deployed using CodeFile before, it's very likely that I'm missing some option I'm supposed to set in VS when building, in order to force a pre-compile. I just need to be able to deploy, as I do today, as a set of ASPX/ASCX with a single codebehind DLL. And that's working today with CodeBehind= ... it just has the originally mentioned Intellisense problem, which is really what I want to fix :)
Will post more as I identify what files might be relevant to the question...
Have you checked the Build Action on your project files? I have duplicated your issue by setting the Build Action on ArticleView.ascx.designer.cs to None. I can also compile when using CodeFile, etc..., I'm 99% sure that's your problem.
You are missing the [your-file].ascx.designer.cs file, which links your controls to your codebehind.
Just like CitizenBane suggestions, you need to right-click the file (or folders, or entire web project) and select "Convert to Application". Visual Studio will examine your ascx/aspx files for the server controls, and generate that designer file for you.
I actually ran into this myself, on a far larger scale... C#: How to convert a Website project to a Web Project
Check the answer.
This has happened to me before. Try right clicking the ascx/aspx and click on "Convert to Web Application". You may just be missing the generated controls. If you don't see it in the context menu, delete the designer generated file first.
CodeBehind is deprecated in .NET 2.0. I believe that only <= 1.1 uses "CodeBehind". Now it is "CodeFile" as you say.
Why do you not want to compile your code? If you compile you don't have to deploy your .cs files...
Why do you have the code behind for your ascx control as an aspx named page code behind?
A UserControl (ascx) usually has a codebehind of
CodeBehind="ArticleView.ascx.cs"
instead of what you have listed
CodeBehind="ArticleView.aspx.cs"
Notice the aspx instead of the ascx for a User Control.
That could be your problem... a simple typo or a copy and paste error. Couple possibilities come to mind:
Maybe you have the ascx control (User Control) specified above using a code behind file that is inheriting from System.Web.UI.Page instead of System.Web.UI.UserControl (that could be causing the Visual Studio errors).
You have the UserControl pointed at the code behind for a same name aspx page. Similar problem as #1 which would cause Visual Studio to get all confused.
Your files are name ArticleView.ascx and ArticleView.aspx.cs. This might confuse Visual Studio since I believe VS might expects a particular naming convention.
For a User Control (ascx) your files should be named:
ArticleView.ascx (CodeBehind="ArticleView.ascx.cs" Inherits="[NAMESPACE].ArticleView")
ArticleView.ascx.cs (inherits from System.Web.UI.UserControl)
ArticleView.ascx.designer.cs
For a Web From (aspx) your files should be named:
ArticlePage.aspx (CodeBehind="ArticlePage.aspx.cs" Inherits="[NAMESPACE].ArticlePage")
ArticlePage.aspx.cs (inherits from System.Web.UI.Page)
ArticlePage.aspx.designer.cs
This just happened to me in VS2010 after upgrading a web application project to .net 4.0.
The answer was to make sure you have targetFramework="4.0" set on the system.web/compilation section in web.config
i.e.
<system.web>
<compilation debug="true" targetFramework="4.0">
</system.web>

Resources