Parser Error Message: Could not load type 'som

2019-01-23 13:20发布

I am experiencing an error that I am unable to resolve for some time now. I was wondering if someone can help identify the cause of this error? I am completely new to asp / asax. After some research, I think that the error I am getting is due to the web application trying to use outdated code. I was thinking to rebuild the c# file using Visual Studio and/or the entire project. However, I am completely new to C# and asp, and was wondering can give me some suggestions if this may fix the problem and/or if there is an possible alternate solution.

Error message

Parser Error Message: Could not load type 'Inventory1.Global'.

Source Error:   <%@ Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>

Entire Global.asax contents:

<%@ Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>

16条回答
唯我独甜
2楼-- · 2019-01-23 13:37

It can't find the necessary file in dll assembly. Rebuild the project, Rebuild the solution and then try it again.

查看更多
We Are One
3楼-- · 2019-01-23 13:38

Could not load type

means that a type could not be loaded. (In this case, "type" refers to Inventory1.Global). Types are located in compiled DLLs. So, either the DLL isn't available, is out of date, or doesn't contain a public type with the given name.

Some possible causes are:

  • You have no type declared with the given name. For your example, you should have the following:
namespace Inventory1 {
  public class Global {
  ...
  }
}

Note: avoid names like Inventory1. They imply that there is an Inventory2, Inventory3, etc., which is bad practice as they're abmiguous and not very descriptive. Also, Global is pretty vague, and may introduce confusion with the global namespace.

  • Make sure your cases match (Inventory1, not INVENTORY1.)
  • You haven't compiled the project. In VS, rebuild the solution.
  • The assembly that declares the class has a compilation error, so the relevant DLL is either missing or out of date. Make sure you've resolved all errors.
  • The class is not marked as public.

If I had to guess, I'd put my money on a compilation error. Unlike PHP and other interpreted languages, C# have to be successfully compiled before they can be used.

查看更多
Viruses.
4楼-- · 2019-01-23 13:40

Try replacing CodeBehind with CodeFile

查看更多
神经病院院长
5楼-- · 2019-01-23 13:40

After scouring around for what could have caused this I found a few things that I needed to do to get my project running...

(Note: You may not need to do all of these - it is a case-by-case thing)

  • If you did any changes from IIS Express to Local IIS you may need to change the build configuration from bin/debug to bin. (Right click on solution >> Properties >> Build >> Output)

  • If you have a URL rewrite then you will need to install URL rewrite on your Local IIS.

  • Navigate to your applicationhosts.config file (usually it's some place like C:\Users\username\Documents\IISExpress\config) and rename the file to applicationhostsOLD.config.

  • Clean and rebuild your project. You may need to go manually empty out the bin.

Now you should be good to go.

查看更多
孤傲高冷的网名
6楼-- · 2019-01-23 13:44

This happened with me on my local machine. The issue was incorrect IISExpres config. If you are getting this issue on your local environment (Visual Studio debug runs), check the IIS Express config file. Make sure your local site/application path is pointing to the correct location.

The configuration file is called applicationhost.config. It's stored here: My Documents > IIS Express > config . Usually (not always) one of these paths will work:

  • %userprofile%\documents\iisexpress\config\applicationhost.config
  • %userprofile%\my documents\iisexpress\config\applicationhost.config
查看更多
Summer. ? 凉城
7楼-- · 2019-01-23 13:44

I just got this error today. It turns out that it was because I reverted by mistake the project file to an older version that didn't include the page anymore.

查看更多
登录 后发表回答