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

  • Home
  • SEARCH
  • 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 308669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:40:18+00:00 2026-05-12T07:40:18+00:00

Suppose I have a class with 3 constructors, a default (no argument) constructor, a

  • 0

Suppose I have a class with 3 constructors, a default (no argument) constructor, a parameterized constructor, and a static constructor. like this:

public MyClass()  { ... }
public MyClass(string arg) : this()  { ...  }
static MyClass()  { ... }

Supposing I invoke the parameterized constructor, in what order do these constructors execute?

I thought it was static, then parameterized, then default. But … my experience isn’t agreeing with that.


The background: I have an app that embeds a referenced DLL as a resource. At runtime, the application registers an assembly resolver via

static MyClass()
{
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Resolver);
}

where the Resolver method is defined like this:

static System.Reflection.Assembly Resolver(object sender, ResolveEventArgs args)
{
    ....
} 

I understood that the Resolver can produce an assembly any way it darn well chooses. In my app’s case, it does a

Assembly.GetExecutingAssembly().GetManifestResourceStream(name);

where name is the name of the embedded resource. Then read all the bytes of this resource, and do an Assembly.Load(byte[]) on the block of bytes that is read.

This may sound strange to you, at first, but it works.

You might say, why in the world would you embed an assembly, rather than just ILMerge? Good question. I think I need to embed because the embedded assembly is signed, and I don’t have the key to re-sign the merged assembly. So I embed.

The problem is this: suppose I declare a private instance member variable on the class, which is of a type that is defined in the embedded assembly. In my case, it’s an enum, and I also initialize the value of that enum.

Now, if the static constructor has already run, then the initializer on that private member will have no problem running. But what I see is a “file not found” error – your basic Fusion error.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'MyApp, Version=1.1.4.1, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The system cannot find the file specified.
File name: 'MyApp, Version=1.1.4.1, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

If I remove the private instance variable, then I don’t get the Fusion error.

I can use variables of that type, or any other type defined in the embedded assembly, later, as long as they are not initialized on as member instance variables in the class. I can use the types in a instance method, no problem.


Writing this up, I am thinking I may have come up with the answer to my own question. Maybe it is a JIT timing issue: maybe the instance constructors are being JIT’d before the static constructor is run. This would, maybe? lead to the Fusion error?

anyone have any insight?

It’s not a huge crucial problem, because I can redesign the class to avoid the issue, removing all instance variables that depend on the embedded assembly. But I’d like to understand it.

  • 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-12T07:40:18+00:00Added an answer on May 12, 2026 at 7:40 am

    You are right, in terms of the order.

    The static constructor runs first, then the non-parameterized constructor, then the parameterized constructor.

    The JIT timing should not be an issue. The CLR guarantees that your static constructor will complete prior to any instance being constructed.

    However, the assembly resolution is happening BEFORE your static constructor fires. The runtime needs to resolve the assembly (and its dependencies) prior to invoking any static construction. That’s why you’re running into this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • 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 There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

Is there a standard acceptable convention for parameters in Java to straightforward constructors and
The problem I have is this: I have a table (just an example) with
I have a problem in a Windows Forms application with Bitmap.Save failing when I
I have a high-level goal of creating a static utility class that encapsulates the
Suppose I have several small test cases. Easy enough to setup and easy enough

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.