Question Class Build Order

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have several classes in my solution that depend on each other, so the classes need to be built in a certain order for the solution to work. How can I force one class to be built before it tries to build another? Thanks.
 
Let's say that you have two classes in your project and both of them refer to the other. How could you possibly get that project to build if you had to make sure that the classes were compiled in a specific order? You're trying to solve a problem that doesn't exist. The compiler will take care of it and you don't have to worry. Is something actually going wrong when you try to build? If so then please explain that specifically because your question is completely moot.
 
Everything in one project is built to one assembly, so it is not possible classes in one project has been partially built.
Only multiple projects in one solution may have dependency and build order, and even multiple ordered startups. Those options is available in context menu for solution node, or in Project menu when solution node is selected in Solution Explorer.
 
I have several classes in my solution that depend on each other, so the classes need to be built in a certain order for the solution to work. How can I force one class to be built before it tries to build another? Thanks.
After reading JohnH's response I reread this post and realised that you did say "solution" rather than "project". Do you actually have more than one project in the solution? If not then there's nothing to do. If you do have multiple projects then you still may not need to do anything because I've never encountered an issue with build order in multi-project solutions, even with about 10 projects. VS knows what projects reference what other projects so it ensures that dependencies are built in the correct order. You also asked how to order the build of classes, not projects, so there's no specific way to do that.
 
My basic situation is that, in an ASP.NET/VB.NET project of mine, I have several controls defined in *.vb files by inheriting from System.Web.UI.Control. These classes must obviously be built before any pages that use the controls, otherwise I would be trying to use controls that don't exist. How can I make sure the control classes get built before the pages that try to use them? Thanks.
 
You can have a look at compilation model for web sites and web applications here:
ASP.NET Compilation Overview
Compiling Web Application Projects
Basically web applications build as single assemblies, and web site build each folder as separate assemblies (with application folders before main folder). Normally, like in client projects, the compilation order would be a non-issue.

I am also wondering why you posted in Visual Studio generic forum, and not in ASP.Net section, and also not mentioned anything about this being about ASP.Net in your post?
 
Back
Top