Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Issue with AreaRegistration in Global.asax

Aperta
#25 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
backend, testing

Direzione di ricerca

Inizia in global.asax.cs, in Global.Application_Start, dove AreaRegistration.RegisterAllAreas() genera l’eccezione. Leggi il test CanIgetMasterPage e la configurazione di WebFormsTestBase.InitializeWebApplicationProxy, quindi esegui il test per riprodurre il problema. Il lavoro è completato quando è stato stabilito se la registrazione delle aree è supportata da questo harness e il comportamento osservato è stato risolto o documentato chiaramente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted Low Priority

Are areas supported?

This line:

        AreaRegistration.RegisterAllAreas();

in

   protected void Application_Start(object sender, EventArgs e

of

global.asax.cs

results in the error below (slightly munged).

The test is

    [TestMethod]
    public void CanIgetMasterPage()
    {
        var sut = WebApplicationProxy.GetPageByLocation("~/MasterPages/Main.Master") as Main;

        Assert.IsNotNull(sut);


    }

and the base test class is

namespace xxx.yyy.WebFormsTestSpike
{

public class WebFormsTestBase
{

    protected readonly MockRepository _mockery;
    protected readonly Mock<HttpContextBase> contextMock;
    protected readonly Mock<HttpResponseBase> responseMock;
    protected readonly Mock<HttpRequestBase> requestMock;

    public WebFormsTestBase()
    {

        _mockery = new MockRepository(MockBehavior.Loose);

        contextMock = _mockery.Create<HttpContextBase>();

        responseMock = _mockery.Create<HttpResponseBase>();
        contextMock.SetupGet(c => c.Response).Returns(responseMock.Object);
        contextMock.SetupGet(c => c.IsDebuggingEnabled).Returns(true);

        requestMock = _mockery.Create<HttpRequestBase>();
        contextMock.SetupGet(c => c.Request).Returns(requestMock.Object);

        InitializeWebApplicationProxy();
    }

    private void InitializeWebApplicationProxy()
    {
        Uri codeBase = new Uri(GetType().Assembly.CodeBase);
        var currentFolder = new DirectoryInfo(Path.GetDirectoryName(codeBase.LocalPath));
        var webFolder = currentFolder.Parent.Parent.Parent.GetDirectories("xxx.yyy.Web")[0];

        WebApplicationProxy.Create(webFolder.FullName, true);
    }
}

}

System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=This method cannot be called during the application's pre-start initialization phase.
Source=System.Web
StackTrace:
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.GetReferencedAssemblies()
at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.GetReferencedAssemblies()
at System.Web.Mvc.TypeCacheUtil.FilterTypesInAssemblies(IBuildManager buildManager, Predicate1 predicate) at System.Web.Mvc.TypeCacheUtil.GetFilteredTypesFromAssemblies(String cacheName, Predicate1 predicate, IBuildManager buildManager)
at System.Web.Mvc.AreaRegistration.RegisterAllAreas(RouteCollection routes, IBuildManager buildManager, Object state)
at System.Web.Mvc.AreaRegistration.RegisterAllAreas(Object state)
at System.Web.Mvc.AreaRegistration.RegisterAllAreas()
at xxx.yyy.Web.Global.Application_Start(Object sender, EventArgs e) in C:\zzz\Repos\MarketOnce2\Products\xxx\yyy\xxx.yyy.Web\Global.asax.cs:line 117
InnerException:

Lingua principale
JavaScript
Stelle
26
Fork
14
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di csharpfritz/WebFormsTest

Tutte le issue di csharpfritz/WebFormsTest

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.