Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 853821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:49:24+00:00 2026-05-15T07:49:24+00:00

Strange thing happening to me with the PreApplicationStartMethod Attribute. I did implement it in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:49:25+00:00Added an answer on May 15, 2026 at 7:49 am

    Strange, we use this feature a lot in the ASP.NET team, and have not run into this. To help debug this, can you try running the following code, which does something similar to what ASP.NET does to locate the method?

    The best way to run it is to create a Console app and put that code in there. Then just call it, passing it the assembly where you are seeing the issue. You’ll then want to debug it and trace through it carefully to see what goes on.

    BTW, before doing this, double check that you are putting the attribute on the same assembly that contains the class. i.e. it can’t point to a type in a different assembly.

    Here is the code to try:

    using System;
    using System.Web;
    using System.Reflection;
    
    public class TestClass {
        public static void TestPreStartInitMethodLocation(Assembly assembly) {
            var attributes = (PreApplicationStartMethodAttribute[])assembly.GetCustomAttributes(typeof(PreApplicationStartMethodAttribute), inherit: true);
    
            if (attributes != null && attributes.Length != 0) {
                PreApplicationStartMethodAttribute attribute = attributes[0];
    
                MethodInfo method = null;
                // They must be in the same assembly!
                if (attribute.Type != null && !String.IsNullOrEmpty(attribute.MethodName) && attribute.Type.Assembly == assembly) {
                    method = FindPreStartInitMethod(attribute.Type, attribute.MethodName);
                }
    
                if (method == null) {
                    throw new HttpException("Couldn't find attribute");
                }
            }
        }
    
        public static MethodInfo FindPreStartInitMethod(Type type, string methodName) {
            MethodInfo method = null;
            if (type.IsPublic) {
                method = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase,
                                binder: null,
                                types: Type.EmptyTypes,
                                modifiers: null);
            }
            return method;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 433k
  • Answers 433k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer sys.databases only exists once (actually in the hidden resource database)… May 15, 2026 at 2:51 pm
  • Editorial Team
    Editorial Team added an answer Have a look at the page navigation section in the… May 15, 2026 at 2:51 pm
  • Editorial Team
    Editorial Team added an answer I would recommend a tableview hierarchy three views deep. The… May 15, 2026 at 2:51 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.