I have a solution with many projects and 2 of them are a Webservice
and a ConsoleApplication
. Webservice
is the start up project in solution. My solution build order is as follows
ProjectA and ProjectB are referenced in both the projects. Now when I clean my solution and try to build the solution it fails for the first time. The error comes constructor of a class in ConsoleApplication project where I am instantiating XYZ class of ProjectA. Error is
The type 'XYZ' is defined in an assembly that is not referenced. You must add a reference to assembly 'ProjectA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. ProjectPath\Program.cs
However when I build the solution again it builds successfully. Can anyone help me to understand the behavior. It is not lethal for my project in any way but I don't want Visual Studio to decide when to do what. I want to know the reason for this behavior.
Also, when I build the solution for first time I could see no .dll
of ProjectA or ProjectB in debug folder of ConsoleApplication. However on second attempt these dlls are visible in debug folder and build succeeds.
Any suggestions on how to fix this?
Typically that's a build order problem... On your solution do right click and go to Build Order.
Then set the correct project build order.
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With