Project Dependencies in Visual Studio - c#

I have a three projects in the solution WinSync. I have WinSyncGui, WinSyncLib and Setup. WinSyncGui requires files from WinSyncLib. How can I get it to include WinSyncLib in WinSyncGui?
VS complains The type or namespace name 'WinSyncLib' could not be found (are you missing a using directive or an assembly reference?)
I've set the dependencies so that WinSyncGui depends on WinSyncLib (so Lib is built first), but it's still not working.

Right click your project (WebSyncGui) and select Add Reference, Projects tab, and then select the project you need to reference.

You need to add WinSyncLib as a reference in your WinSyncGui project.
Adding a project reference.

I've set the dependencies
That sounds wrong. Did you set the "dependencies" or did you set the "references". Dependencies just determine build order, references are used to link projects.

Are you sure all of the types are public? if you omit the modifier, it's internal by default.

Right click on solution, choose Project dependencies and set dependencies whatever you want. It's useful, for example, when you have two exe files in one solution. It's bizzare to add another exe as reference, so I use this option to firstly build depended executable, and then post-build event is copying it into target directory. Very useful toy.

Related

MVC Solution builds locally but not on TeamCity

Please can somebody help.
I have a solution that build locally and on another machine when checked out from Subversion however when I try to build it using the MSBuild tool on my TeamCity server I get some form of assembly referencing problem
[08:33:32][Csc] Controllers\AccountsController.cs(422, 26): error CS1061: 'PF.ENTITIES.PF022.Item' does not contain a definition for 'OperationStatus' and no extension method 'OperationStatus' accepting a first argument of type 'PF.ENTITIES.PF022.Item' could be found (are you missing a using directive or an assembly reference?)
The PF.ENTITIES.PF022 assembly does have the correct property for OperationStatus and as I said it runs fine locally.
Can somebody help?
Thanks
Have you checked if this dll is set as "Copy locally"?
To set the Copy Local property to True or False
In Solution Explorer, click the Show All Files button to display the References node.
Open the References node for the project.
Right-click a reference in the References list, and click Properties.
The properties associated with that reference appear in a list in the Properties window.
Select Copy Local from the left-hand column, and then click the arrow in the right-hand column to change the value to True or False.
https://msdn.microsoft.com/en-us/library/vstudio/t1zz5y8c%28v=vs.100%29.aspx
It was a problem with Project Dependencies.
I wanted to build the whole Solution in TeamCity but I would now advise against this. Rather build individual projects always within the solution, that way you can arrange your build order and set some dependencies (do the same for your CI Deployment System too)
That way you can ensure certainly libraries are in place before you build other projects.

missing references at debug time

hi there i know its most be a silly mistake but i couldn't find it. i add two references to my project by Right click on References and browse them, i simply use component of these Dlls in my program with no problem, auto complete code is work fine for classes of these Dlls. But when i run my program got error like:
The type or namespace name 'GlobalizationDateTimePicker' does not exist in the namespace 'GHDiamond.Windows.Forms' (are you missing an assembly reference?)
for this line in myform.Designer.cs:
this.DateTimePicker_AZ = new GHDiamond.Windows.Forms.GlobalizationDateTimePicker();
References names are: GHDiamond.dll and GHDiamond.Win.dll. they are in Object browser too when a add them, but when i Build my project, GHDiamond.Win is not there anymore ! any help will be appreciated
Select the Reference in the Solution Explorer and go to the property window. Make sure that the property "Copy Local" is set to "True". This causes the dll to be copied to the output directory.
I have had something similar which was caused by missing dependent dlls. Autocomplete worked until i built then i would get a load of compile errors. make sure there are no other dlls that you need.

Why one project (exe) does not see the namespace of another project (dll) in the same solution?

Why one project (exe) does not see the namespace of another project (dll) in the same solution?
You need to add a reference from the using project to the DLL first.
Select Project|Add Reference, Projects Tab.
A "solution" in Visual Studio is a collection of projects. Each project is independent of all the others. The solution is just a convenient way of organizing projects and opening them all together.
If one project is going to use the public objects defined in another project, then it must be compiled with a reference to the other project. This is true whether the projects are part of a single solution or not.
To signal to Visual Studio that the EXE must be compiled with a reference to the DLL, you must add the DLL to the EXE's list of references in the Solution Explorer.
You need to add a reference to the DLL.
Right-click the EXE project, click Add Reference, go to the Projects tab, and select the DLL.
Also, make sure that the classes in the DLL are public.
Sounds like you need to add a reference to the dll
Right click on the project --> Add Reference

How to set "Specific Version" property for project references in Visual Studio

I have got a Visual Studio Solution containing several projects and have set up the references between the projects as project references.
When a reference to an assembly is added, the references' properties contain a setting for
Specific Version = True|False
This property is missing for project references. How can it be set? I'd like my solution to load any available assembly (no matter what version) in the bin folder.
I've had a problem when a workflow instance (Workflow Foundation) was deserialized and the dependencies were updated meanwhile.
I think the problem is that what you are asking is not possible directly with a project reference, I think that always implicitly turns into an 'explicit version', because of the nature of the link.
The way you could do this (calling the currently referenced project A, and the referencing project B):
Have the project you want to reference in your solution, just like you do now with the project reference
Explicitly set the dependency chain so the 'referenced' project is built first
Build the referenced project A once first manually
Create an assembly reference in project B to the results from the build in project A
Set the assembly reference to 'Specific Version = false'
The build order (dependency) will guarantee that A is always built before B, and B will reference it from the binary output directory of A.
(altho, it's a little brittle and I would not recommend it since it's easy to get wrong results if the settings are not all right, or the sun aligns with the stars wrong, or some such)
I might be misunderstanding your question, but when you add a project reference, the project's assembly is always loaded into any project that references it when the project is built. Therefore, you'll always have the latest available assembly in the bin folder for that project. VS treats projects differently than other assemblies in that regard.
You can add references to project output dlls instead of projects. Then you will be able to set Specific Version setting.
I have found the solution to my problem. It's described pretty detailed here.
The problem is not a matter of wrong project references, but more a de/serializing of workflow instances question.
Thanks to everybody who tried to help.

Assembly dependencies with .Net projects

If I have an assembly (A) which references another assembly (B).
I want to reference A in a project, I add the reference and it copies A into my BIN directory. It does not copy B as well, even though A depends on it, so the code doesn't compile.
How can I set things up so that whenever I reference A, both A and B get copied to my bin directory?
In Visual Studio, add each project to the same solution. Ensure you use Project References instead of direct file references (ie browsing for the assembly).
I dont think there is any way around what you ask other than to explicitly add both. I dont think however adding projects for the sake of getting references copied is a viable solution to the issue. Not all projects that a solution depends on should necassarily be added to the solution. This would completely depdend on your overall project structure, processes, source control, division of labour, etc
Reference both A and B.
Unfortunately you'll have to manually add both. This is what happens to me as well whenever I use pre-3.5 versions of NHibernate: it requires both log4net and Iesi.Collections assemblies. So I have no choice but to manually include a reference to both in all my solutions that implement NHibernate.
This is more of an issue, of course, if you only have the DLLs. If it's a project that you have a codebase to Visual Studio itself will warn you beforehand that the references are missing.
How about adding them to Global Assembly Cache?

Categories

Resources