Parser Error Message: Could not load type 'webmarketing'
Asked Answered
B

14

40

After finishing the web application and publishing it online no matter I try I keep getting the following error, keep in mind that it runs locally as it should...

Parser Error Message: Could not load type 'webmarketing'.

enter image description here

I ran through that solution though supposedly I'm doing the same as the solution, yet I'm still facing the same issue...

ASP.NET Parser Error Cannot load code behind


Here is the code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webmarketing
{
    public partial class Masterpage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string admin = (string)Session["Admin"];
            if (string.IsNullOrEmpty(admin))
            {
                logout.Visible = false;
            }
            else
            {

            }
        }
    }
}
Buhl answered 22/4, 2014 at 12:58 Comment(1)
Possible duplicate of Parser Error Message: Could not load type 'sometype'Viscoid
C
78

I had same problem before i just change CodeBehind to CodeFile and it worked.I remember it works in local but i had this problem after uploading.

Cacka answered 22/4, 2014 at 13:45 Comment(4)
It answered with the following error: Compiler Error Message: CS0101: The namespace 'webmarketing' already contains a definition for 'Masterpage'Buhl
This worked for me but seems like a workaround... it requires the source code (.cs) file to exist. The application should be running the code from the compiled .dll in the bin folder. Any ideas on a solution?Mosul
Changing it to "CodeFile" worked for me, but then changing it back to "CodeBehind" also worked. I don't understand why toggling it like that made a difference, but maybe that's helpful.Hogle
Thanks, I don't know if I ever would have found that one. I was moving a page from a web application from a newer version of visual studio to one created with VS 2012.Dyeline
S
36

This is normally happening when you copy files from a Web application projects to Website Project.

When you create a Web Application the Page directive is CodeBehind for the web pages. enter image description here

If you create your application as Website then the Page directive is CodeFile enter image description here

So if you copy from a Web application to Website the Namespace as well as the page directive will not change automatically, you should do this manually to rectify this error.

Semaphore answered 25/2, 2016 at 8:14 Comment(1)
This is exactly the problem I just encountered!Medallion
P
8

I had this error message. The problem was my .cs and aspx files were not added to the project. They were in the folder, but were not added. I solved it by adding them to the project (right click, Add). And then after I built the project, it was compiled into a dll in the bin folder. There was no need to change the text from CodeBehind to CodeFile.

Pigeontoed answered 9/6, 2016 at 19:13 Comment(0)
E
5

what i did to solve my problem giving the same message was to go to IIS and check if it is configured as an Application or simply as a virtual directory. The App icon was just a folder icon. So i right clicked it and Manage Virtual directory > Advanced Settings > convert to Application changed the icon of virtual directory to a green earth icon. Of course the app was targeting framework 4.5, so changed App pool to 4.0 from default app pool, which was there earlier. This solved the issue for me.

But some things i did not say, 1. I am running it locally on IIS 6.1. 2. I am accessing with domain credential and not with 'pass through' authentication. Hope this helps

Electroacoustics answered 2/12, 2015 at 12:35 Comment(0)
S
3

regarding the Inherits is should reflect the full name space with class name such as x.y.webmarketing, not the class name or the file name. to wrap it up it should look like below

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.Master.cs" Inherits="Lync_Billing.ui.MasterPage" %>
Spiritualism answered 22/4, 2014 at 13:4 Comment(2)
Like this? <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Masterpage.master.cs" Inherits="webmarketing.Masterpage.Masterpage" %> | Note: Master page name is Masterpage and the project name is webmarketingBuhl
a better way to see check the code behind namespace lets assume it is x.y and then add the classname for the masterpage so you will end up of haveing the FQN like 'x.y.MasterPage'Spiritualism
C
3

If your application works in your local but fails when deployed to the server, then this issue is most likely related to your IIS settings.

To resolve this, Make sure the “Enable 32-Bit application” property of the target Application pool in IIS is set to “TRUE”. It WORKS!

Curtal answered 15/6, 2015 at 5:9 Comment(0)
W
1

I think you find the problem is you need to update the files in the BIN folder. When you run the app it recompiles the files in the BIN folder too. Copy those up to the WEB site and that should fix the problem, it did for me. This is especially true if you create a new page that was not already there which was my case.

Ways answered 21/2, 2017 at 14:26 Comment(0)
H
1

In case you encounter this during debugging on your Visual Studio running on a 64-bit operating system, and your application is a 32-bit, set your configuration manager to x86 (32 bit). This agrees to the previous answer to the set IIS to enable 32-bit application on 64-bit.

Visual Studio - Configuration Manager on Build

Head answered 23/6, 2017 at 6:26 Comment(0)
R
0

If you are facing this error after Hosting your Website on server make sure that you create the directory And/Or go to Hosting server -> Site Manager -> Application Starting Point ,select the proper path or folder of your uploaded Published Folder.

It resolve my same problem , I hope it will help you also.

Rotgut answered 30/3, 2016 at 11:55 Comment(0)
C
0

Using VS2015, I checked "Delete all existing files prior to publish" under File Publish Options within the "Publish Web" right-click menu option and this problem went away.

Counterirritant answered 14/8, 2017 at 19:28 Comment(0)
M
0

For me, I rebuild the individual projects and then rebuild the entire solution. That worked for me somehow. Simply building the solution may not work. I think when you "Clean" the solutions that will fix the issue.

Mulcahy answered 3/4, 2018 at 9:17 Comment(0)
W
0

I'm using "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version 1.0.8. When rebuilding there was a warning about not being able to copy files into bin\roslyn. So I stopped IISExpress, deleted the bin folder and rebuild the project. There were no build warnings and the application worked fine.

Weak answered 28/5, 2018 at 7:51 Comment(0)
V
0

Non of the mentioned answers worked for me.

My error was the same but I made the mistake and published the Debug version and not release, so make sure before Publishing your project, switch to Release, Clean and Rebuild the solution and the build!

enter image description here

Valadez answered 30/11, 2018 at 12:44 Comment(0)
T
0

Note: I was compiling my WebForms pages at build time.

I had aspx files not referenced in the project but were on disk and that was causing the build errors.

Troublous answered 26/8, 2019 at 20:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.