[Solved-5 Solutions] Parser Error Message: Could not load type 'TestMvcApplication.MvcApplication'



Error Description:

Parser Error Description: An error occurred during the parsing of a resource required to service this request.

  • Parser Error Message: Could not load type 'TestMvcApplication.MvcApplication'.
  • Source Error:
    1. Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="TestMvcApplication.MvcApplication" Language="C#" %>
    2. Source File: /global.asax Line: 1

Solution 1:

    • Running the project from Visual Studio works fine. This is the source code from Global.asax:
    namespace WebApplication5
    {
        public class MvcApplication : System.Web.HttpApplication
        {
            protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }
        }
    }
    
    
    click below button to copy the code. By - .Net tutorial - team
    • This leads us to believe that we might not have something install or some configuration is not correct that IIS sets globally.Here is what steps we followed for a new web application in Visual Studio 2015:
    1. File -> New Project -> ASP.NET Web Application -7gt; MVC
    2. Runed the project on visual studio it works with the default templates
    3. On IIS we created a new website and in that website we created a new web application which is mapped to the folder of the project.
    • we created an application pool for the newly created project inside the website that has the following configuration.
      • .NET CLR versions is set to .NET CLR Version v4.0.30319
      • Managed Pipeline is set to integrated

    After doing all this we tried the following to fix the issue:

    • Clean and Rebuild for Visual Studio
    • Restart Visual Studio Clean Rebuild an PC Reset Clean rebuild
    • we made sure that the project adds its assemblies in the bin folder
    • we made sure that in Solution ->Properties -> Configuration Properties the proejct is set to debug
    • we made sure that the namspace in Global.asax xml file points to the correct type in Global.asax.cs

    Solution 2:

      • We had this a couple of times and the error message holds no clue as to what might be the issue.
      • To fix this, right click our project title, in this case "TestMvcApplication" and click build.
      • This forces the code to compile before we run it. this has been the solution 100% of the time for all.

      Solution 3:

        Here's another one:

        • We had been working on a web api project that was using localhost:12345.
        • We checked out a different branch from source control containing the same project.
        • We ran the project on the branch and got the error.
        • we went to "Properties > Web > Project Url" and clicked "Create Virtual Directory"
        • A dialog came up telling me that the url was mapped to a different directory (the directory for the original project).
        • we clicked Okay and the virtual directory was remapped.
        • The error went away.

        Solution 4:

          • We need to read the Python Unicode HOWTO. This error is the very first example.
          • Basically, stop using str to convert from unicode to encoded text / bytes.
          • Instead, properly use .encode() to encode the string:
          p.agent_info = u' '.join((agent_contact, agent_telno)).encode('utf-8').strip()
          
          click below button to copy the code. By - .Net tutorial - team

          or work entirely in unicode.

          Solution 5:

            This is a classic python unicode pain point! Consider the following:

            a = u'bats\u00E0'
            print a
             => batsà
            
            click below button to copy the code. By - .Net tutorial - team

            All good so far, but if we call str(a), let's see what happens:

            str(a)
            Traceback (most recent call last):
              File "<stdin>", line 1, in <module>
            UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 4: ordinal not in range(128)
            
            click below button to copy the code. By - .Net tutorial - team

            To fix the error, encode the bytes explicitly with .encode and tell python what codec to use:

            a.encode('utf-8')
             => 'bats\xc3\xa0'
            print a.encode('utf-8')
             => batsà
            
            click below button to copy the code. By - .Net tutorial - team
            • The issue is that when we call str(), python uses the default character encoding to try and encode the bytes we gave it, which in our case are sometimes representations of unicode characters.
            • To fix the problem, we have to tell python how to deal with the string we give it by using .encode('whatever_unicode').
            • Most of the time, we should be fine using utf-8.
             server error in app

            Learn dotnet - dotnet tutorial - server error in app - dotnet examples - dotnet programs


            Related Searches to Parser Error Message: Could not load type 'TestMvcApplication.MvcApplication'