2016-04-07 8 views
0

私はasp.net mvcアプリケーションを使用しています。私はこれをIIで構成しました。それは前に働いていた。同じアプリケーション私は設定やビルドをしていないが、ただ実行しているが、次のエラーを出す。アセンブリ/タイプをロードできませんでしたか?

また、WebSystem.Web dllがdllフォルダにあります。私は解決策を働かせずに再構築しますが、私は解決策をクリアしますが、作業はしません。私は\binフォルダにGlobal.asaxとGlobal.asax.csが見つかりましたので削除しましたが、IISから実行すると自動的に\binフォルダの下に作成されます。

また、100%確実なアプリケーションフォルダに仮想ディレクトリを設定しました。 WebSystem.Webはdllと名前空間とこのDLLの\ binフォルダ内のMvcApplicationクラスが100%確実に存在します。

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: Could not load type 'WebSystem.Web.MvcApplication'.

Source Error:

Line 1: <%@ Application Codebehind="Global.asax.cs"Inherits="WebSystem.Web.MvcApplication" Language="C#" %>

また、この仮想ディレクトリのすべてのファイルを削除(削除)しました。

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files 

上記のエラーを解決するにはどうすればよいですか?

は、ここではその初めてのMVC 5アプリケーションを実行しようとしているときに、私は最近、同じ問題を持っていた私のGlobal.asaxファイル

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Security.Principal; 
using System.Text; 
using System.Web; 
using System.Web.Http; 
using System.Web.Mvc; 
using System.Web.Optimization; 
using System.Web.Routing; 
using System.Web.Security; 
using WebSystem.Common; 
using log4net; 

namespace WebSystem.Web 
{ 
    public class MvcApplication : System.Web.HttpApplication 
    { 
     private static readonly ILog log = LogManager.GetLogger(typeof(MvcApplication)); 

     protected void Application_Start() 
     { 
      AreaRegistration.RegisterAllAreas(); 

      WebApiConfig.Register(GlobalConfiguration.Configuration); 
      FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 
      RouteConfig.RegisterRoutes(RouteTable.Routes); 
      BundleConfig.RegisterBundles(BundleTable.Bundles); 
      AuthConfig.RegisterAuth(); 

      ModelValidatorProviders.Providers.Clear(); 
      ModelValidatorProviders.Providers.Add(new DataAnnotationsModelValidatorProvider()); 

      //Configure log4net 
      string l4net = Server.MapPath("~/Log4net.config"); 
      log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(l4net)); 
     } 

     protected void Application_Error(Object sender, EventArgs e) 
     { 
      Exception ex = Server.GetLastError().GetBaseException(); 
      StringBuilder objStringBuilder = new StringBuilder(); 

      string ToEmail = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["ErrorNotificationEmailID"]); 
      string subject = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["ErrorNotificationEmailSubject"]); 
      string loggedInUserName = string.Empty; 

      if (HttpContext.Current.Session != null) 
      { 
        loggedInUserName = Convert.ToString(HttpContext.Current.Session["UserFirstName"]) + " " + Convert.ToString(HttpContext.Current.Session["UserLastName"]); 
      } 

      if (ex.Message.ToLower().Contains("file does not exist")) 
       return; 

      System.Diagnostics.StackTrace objStackTrace = new System.Diagnostics.StackTrace(true); 
      System.Diagnostics.StackFrame objStackFrame = objStackTrace.GetFrame(0); 

      String SourcePath = string.Empty; 

      if ((objStackFrame != null)) 
      { 
        SourcePath = Request.Path; 
        objStringBuilder.AppendFormat("Source File:" + Request.Path + " " + "{0}", Environment.NewLine); 
      } 

      // Send Mail to authorized person 
      string URL = Request.Url.Scheme + "://" + Request.Url.Authority; 
      string fullURLpath = Request.Url.AbsoluteUri; 

      objStringBuilder = Utility.MailTemplate(Server.MapPath("~/Templates"), loggedInUserName, Server.GetLastError().Message.ToString(), ex.Message.ToString(), ex.StackTrace.ToString(), fullURLpath, URL); 

      string msgData = objStringBuilder.ToString(); 

      if (isMailSent == false) 
      { 
      } 

      // log.Error("App_Error", ex); 
     } 

     protected void Application_AuthenticateRequest(object sender, EventArgs e) 
     { 
      HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; 

      if (authCookie != null) 
      { 
        FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); 
        GenericIdentity identity = new GenericIdentity(ticket.Name); 

        String[] MyStringArray = { "Admin", "User" }; 
        GenericPrincipal principal = new GenericPrincipal(identity, MyStringArray); 

        HttpContext.Current.User = principal; 
      } 
     } 

     /// <summary> 
     /// Use Application End Request for Ajax Session Timeout Issues. 
     /// </summary> 
     /// <param name="sender"></param> 
     /// <param name="e"></param> 
     protected void Application_EndRequest(Object sender, EventArgs e) 
     { 
      //If we have Session Contact Item is False then we will set Status Code=401. so, we will handle this Ajax Request 
      //Under Common.Js - > RedirectToLoginOnSessionTimeout Function. 
      if (HttpContext.Current.Items["AjaxPermissionDenied"] is bool) 
      { 
       HttpContext.Current.Response.Clear(); 
       HttpContext.Current.Response.StatusCode = 401; 
      } 
     } 

     protected void Session_Start(object sender, EventArgs e) 
     { 
      // event is raised each time a new session is created  
     } 

     protected void Session_End() 
     { 
     } 
    } 
} 
+1

はGlobal.asax.cs –

+2

は、この名前空間.... 'WebSystem.Web'を聞いたことがない私たちに示してください。 .. !! – SamGhatak

+0

それは*自分のプロジェクトの*ネームスペースです@SamGhatak –

答えて

0

です。

この問題は、次のいずれかの理由によって発生します。 異なる(web.configファイルで)プロジェクトによって

  1. ターゲット.NETバージョンの使用場所IISのアプリケーションプールで使用されるバージョンをアプリケーション がホストされています。
  2. 私の場合と同じように、global.asaxファイルが使用するMvcApplicationクラスの名前空間を誤って変更して、global.asaxが別の名前空間を参照するようになりました。この場合の問題を解決するために、

Ensure that the fully qualified classname passed to the inherit attribute in global.asax is the same as defined for the MvcApplication code behind class.

My name space was this

But global.asax was referencing this - missing the cousant in the namespace

関連する問題