1

I want to show my application assembly loaded first when starting application.

After application starts running, my code does not show anything.

public Form1()
{
    InitializeComponent();

    AppDomain.CurrentDomain.AssemblyLoad += new    
    AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad);
}


void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
   Debug.WriteLine("Loaded " + args.LoadedAssembly.FullName);
   label1.Text = "Loaded " + args.LoadedAssembly.FullName;

   Thread.Sleep(500);
}

Where is the problem?

wonea
  • 4,783
  • 17
  • 86
  • 139
Joe Martiniello
  • 323
  • 1
  • 3
  • 13
  • Its possible that by the time you've added your event handler the code is already loaded, or, that you havent loaded your code yet... – BugFinder Jul 27 '16 at 07:02
  • For one thing, I don't think it's safe to assume you can access UI controls within that event handler. Beyond that, it's unclear what you're expecting here - the code you've shown is too little to understand what's happening. – Damien_The_Unbeliever Jul 27 '16 at 07:02

1 Answers1

3

You should call it in your Main(); When the form is showing up, all assemblies are loaded, see https://msdn.microsoft.com/pl-pl/library/system.appdomain.assemblyload(v=vs.110).aspx

Dominik S
  • 176
  • 4
  • 18