PreApplicationStartMethod Attribute causes exception

Posted by Joop on Stack Overflow See other posts from Stack Overflow or by Joop
Published on 2010-05-21T08:21:19Z Indexed on 2010/05/21 8:30 UTC
Read the original article Hit count: 413

Filed under:
|
|

Strange thing happening to me with the PreApplicationStartMethod Attribute. I did implement it in my latest project. In the AssemblyInfo.cs I have the following line:

[assembly: PreApplicationStartMethod(typeof(MyAssembly.Initializer), "Initialize")]

The Type and method look like this:

namespace MyAssembly
{
    public static class Initializer
    {
       public static void Initialize()
       {
           TranslationKeys.Initialize();
       }
    }
}

When I rebuild my application and load it in the browser I get the following error:

The method specified by the PreApplicationStartMethodAttribute on assembly 'MyWebApp, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null' cannot be resolved. Type: 'MyAssembly.Initializer', MethodName: 'Initialize'. Verify that the type is public and the method is public and static (Shared in Visual Basic).

I really have no idea what the problem is.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET