---
title: "Skumt kompileringsfel"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/166544-skumt-kompileringsfel"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Addeladde"
published: "2007-11-20T14:04:10.000Z"
updated: "2007-11-20T15:31:05.000Z"
replies: 1
views: 385
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/166544-skumt-kompileringsfel"
---

# Skumt kompileringsfel

## #1 — Addeladde, 2007-11-20T14:04Z

Hej

Jag har en webbapplikation i C# .NET 2.0 som använder Forms authentication. Jag använder mig av Global.asax för att ta hand om själva login requesten.

Applikationen kompileras utan varningar och fungerar. Men när jag väljer Refactor \> Encapsulate Fields så får jag compiler error när den kollar referenser.

Det är just global.asax som den klagar på. 

> The type 'Global' is defined in an assembly but not referenced. You must ad a reference.
> 
> Can not convert to type System.Web.HttpAplication to 'ASP'.global.asax

Här är ming global.asax

```
<%@ Application Language="C#" Inherits="InheritingHttpApplication.Global"%>
```

Här är Global.cs som ligger i App_Code mappen

```
using System;
using System.Web;
using System.Web.Security;
using System.Configuration;
using System.Security.Principal;

namespace InheritingHttpApplication
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_AuthenticateRequest(Object sender, EventArgs e)
        {

            if (HttpContext.Current.User != null)
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (HttpContext.Current.User.Identity is FormsIdentity)
                    {

                        FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
                        FormsAuthenticationTicket ticket = id.Ticket;

                        // Get the stored user-data, in this case, our roles
                        string userData = ticket.UserData;
                        string[] roles = userData.Split(',');
                        HttpContext.Current.User = new GenericPrincipal(id, roles);
                    }
                }
            }
        }

    }
}
```

Någon som vet varför jag får dessa meddelanden och om jag kan göra något för att få bort dem?

Permalänk: https://www.webforum.nu/p/166544

## #2 — Nickemannen, 2007-11-20T15:31Z

Du får inte kalla din klass för Global tror jag.

Permalänk: https://www.webforum.nu/p/2052729

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/166544-skumt-kompileringsfel
