Solved

Class Library - Call Method when main app starts

Posted on 2010-08-19
6
463 Views
Last Modified: 2013-11-07
Hello, i have a solution with a windows forms app and some additional class library projects..

i want to know if there is anyway to make a method on one of the class library to execute the moment the main application starts without having to manually make the call in the main application..

(so that it wont matter where the class library is referenced it will always execute a method when the main app starts)

is it possible ?
0
Comment
Question by:eguilherme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 33475251
>>is it possible ?

As you describe it I don't think so.  The method would need to be called explicitly somewhere, I haven't heard of an 'autostart' method specifier.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 33475516
Or - this might not be suitable: Just use the class via a singleton wrapper class, you can then call this method the very first time the 'real' class is to be used because it is going via this singleton class you have coded.
0
 
LVL 3

Expert Comment

by:kooswillem
ID: 33476235
Why don't you just call each of the methods in the classes from your main class at application start?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:eguilherme
ID: 33477150
since some of those classes will be in different applications, i would like that they would get called automaticly, instead of having to manually call them at every application..

but i guess its not possible =/

i ll leave this open for now..maybe someone else has an answer
0
 
LVL 2

Accepted Solution

by:
robertlevy earned 500 total points
ID: 33482899
this type of question often means that what you really need is some refactoring to use a Dependency Injection framework.  see http://visualstudiomagazine.com/Articles/2010/08/01/Inversion-of-Control-Patterns-for-the-Microsoft-NET-Framework.aspx for a good primer on DI
0
 
LVL 4

Expert Comment

by:fromer
ID: 33483745
I don't think it's possible. Even static members are initialized just before access..
No way to execute code from class libraries at application start before accessing them..
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question