Overhead of adding references

Hello,

Does adding a reference to the project have any negative effect on the program exe (e.g. in terms of speed, size, ...)

I have a console application in which I need to know the actual path of the executable on the hard disk. The only way I could find was to use System.Windows.Forms.Application.StartupPath. But this is the only thing that I'm using from System.Windows.Forms. Is there any other way to get the StartupPath without adding the System.Windows.Forms reference to my console application

thank you,
--mehrdad.


Answer this question

Overhead of adding references

  • Jean-Michel Hervé

    This should work:

    Assembly.GetExecutingAssembly().CodeBase


  • LesleyW

    Just to answer the other question, too: just adding the reference to the project does not produce any overhead, but once anything from the referenced assembly is used, that assembly is resolved and loaded into the application domain which produces some overhead. But I don't think that you would notice "the impact" of that overhead at all if you load a single additional aseembly.
  • Overhead of adding references