Parser Error Message: Could not load type 'sometype'

前端 未结 19 1718
情话喂你
情话喂你 2020-12-09 15:46

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 /

相关标签:
19条回答
  • 2020-12-09 16:02

    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.

    0 讨论(0)
  • 2020-12-09 16:02

    Since it was only happening with IISexpress, changing output from bin\Debug\ to bin\ solved it for me. Changing tag CodeBehind to CodeFile only created even more problems.

    0 讨论(0)
  • 2020-12-09 16:03

    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
    0 讨论(0)
  • 2020-12-09 16:04

    I tried all the solutions listed above and none of them worked. I finally created a new web page (webform) and copy blocked all the code (cs and aspx files) into it from the old one, deleted the old cs and aspx file, recompiled, and now I'm back in business. I know it makes no sense. It should not have mattered, but it worked.

    0 讨论(0)
  • 2020-12-09 16:04

    If you just added the new aspx File, rebuild the project it is located in. The problem comes from your Code Behind file that isn't compiled at the moment, therefore you want to access a newer page that doesn't exist in your current compiled project dll

    0 讨论(0)
  • 2020-12-09 16:06

    Parser Error Message: Could not load type __

    After doing everything suggested in the comments above, with no luck, refreshing (uploading) the contents of /bin to the server worked. The files uploaded to bin are the: dll, pdb and xml. Don't know which one did it.

    The problem I had here was induced by renaming a file (_.aspx) in Solution Explorer.

    0 讨论(0)
提交回复
热议问题