Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Do classes in the app code folder automatically get instantiated. Does the system automatically look for a default constructor?

I got an error the other day for something that was being called in the default constructor, but i never instantiated the class.

I have since fixed this problem by removing the code from the default constructor.

Any help on clearing up my confusion, i've not seen this issue before as usually i don't put my classes in the app code folder, they're usually in Dll's
Posted
Comments
CHill60 23-Oct-14 10:09am    
We'd sort of need to see the code that caused the problem. But in short, no, classes do not "automatically" get instantiated just because they are in a specific folder.
BillWoodruff 23-Oct-14 12:26pm    
See: http://www.codeproject.com/Articles/31557/A-Beginner-s-Guide-to-ASP-NET-Application-Folders

1 solution

No, there is no "automatic instantiation" - no instances get created unless they are specifically requested with the new keyword (except structs, but their constructor isn't called unless new is used).

I would suspect that you are creating an instance in a different class, or perhaps in a static constructor of a different class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900