I am trying to reference a single project from two different projects in VS 2012. Example: both 1 and 2 are referencing 3. This despite not being a circular dependency, is still not working for me. Project 1 gives the error "The type or namespace could not be found", whereas project 2 can successfully reference project 3. I need this kind of setup because of my architecture and can't reference 1 and 2 directly.
As example, that third project is class library. You should be able to reference it from project1 and project2. Maybe close visual studio, clean, rebuild it and also check if project1 or project2 is not referencing each other. Try to delete those references and add again: class library reference to project1 and then to project2.
Changing the .Net framework for project 1 from Version-4 to Version-4.5 did the trick for me.
This is the answer to my question. stackoverflow.com/a/6090384/1099142
Related
Yes, everywhere I can learn how to make a module from a project that will copy the library project. But that's no good, since a change in the library project would have to be replicated on every project that uses it. So, how can I reference it from a folder that's outside the project in a dynamic way?
Got it:
In your project, go in settings.gradle and declare something like this:
include ':LibReferenceName'
project(':LibReferenceName').projectDir = new File(settingsDir, '../relativePath/toThe/libraryModule/fromTheProject')
And at the modules that requires the library, include something like this in the build.gradle of it:
compile project(path: ':LibReferenceName')
You can also not use settingsDir and just put the absolute path of the project.
I know that this is a question that has been discussed before but I have a situation that I don't understand.
I have the following projects
Project A
Project B
NuGet Package "log4net"
NuGet Package "ServerAppFabric.Client"
Project A has a visual studio reference to Project B. I'm using both packages in code in Project B and I am building in debug mode. Project B config looks like this.
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Core">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
*Why is only the dll-file from log4net copied into the bin folder of Project A and not the Client and Core files? Any help or explanation is appreciated! *
I had the same problem with a somehow complex dependency graph.
Go to the Reference Properties and set Copy Local=True.
Compile and check if the assembly was copied to the bin folder.
If that doesn’t fix your issue try this answer: https://stackoverflow.com/a/19889803/1074245
In order to answer your question precisely, we'd need to know a couple of things.
One explanation depends on what references you have in Project A. For example, it could be that project A, other than referencing project B, also includes additional references, among which there are Microsoft.ApplicationServer.Caching.Client and Microsoft.ApplicationServer.Caching.Core, maybe with the option Copy local set to false - but not log4net. In this case, the copy of the former two will happen only for Project B.
Another possible explanation depends on what your code does with the references in project A and project B. The MSBuild process does not automatically copy assemblies of references that are not actually used in a project.
Finally, in case you are relying on Build Events to copy references, have a look at the Output panel to make sure that there are no errors despite a successful compilation.
In any case, in order to make sure that all NuGet packages are copied, I find it useful to edit the .csproj file and, among the <PropertyGroup> tag, add this:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
From the documentation:
If you set this CopyLocalLockFileAssemblies to true, any NuGet package dependencies are copied to the output directory. That means you can use the output of dotnet build to run your plugin on any machine.
I don't think this is related to NuGet. It should be related to how references work in Visual Studio or MSBuild. If you just reference a library in ProjectB, it won't show up in ProjectA's bin folder. However, when you use some type from the referenced library,only then it will show up in bin folder.
Consider the following setup:
ProjectA
References
Foo
Bar
ProjectA uses in his code only static references to Foo, not Bar, this one is only opened through reflection.
Then we have ProjectB
ProjectB
References
ProjectA
Compiling this with MSBuild yields the ProjectA.dll and Foo.dll in ProjectB's output folder.
However, is there a way that I can tell MSBuild (VS seems to do this by default) that I also need Bar.dll, without adding Bar to the references of ProjectB?
I had this same problem a couple days ago. The solution that I found was to create a dummy class that instantiates an object from Bar in ProjectA. This should then generate the Bar.dll. I don't know why Msbuild works like this but it does. Does anyone know a better solution?
I have a sample solution that has a different "test" icon on one of the test projects, but not on the other two.
I thought that maybe the project type guid was different on this project, but in the solution file they all have the same project type (C#)
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainModel.Tests", "DomainModel.Tests\DomainModel.Tests.csproj", "{61A4733D-4C5B-4705-98CB-8048751BBEFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extensions.Tests", "Extensions.Tests\Extensions.Tests.csproj", "{1D6AA1C5-1FEC-44E4-9258-ACF84A20353C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Repository.Tests", "Repository.Tests\Repository.Tests.csproj", "{248434B7-3690-4705-85F0-66B765AEB431}"
EndProject
And in each project file they have idential project types (Test and C#)
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Why does DomainModel.Tests have the correct test icon, but Extensions.Tests and Repository.Tests have a plain C# library icon?
This can also happen in VS2013 when starting with a class library project and then adding test classes from there.
Adding the following child node to the main PropertyGroup node in the project file fixes the icon in this case:
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
This is fixed in the Visual Studio 2013 preview.
This problem isn't fixed in VS2012 Update 2 (VS2012.2).
I would expect that it will be fixed in the next version of Visual Studio if it isn't fixed in a quarterly update before then. With all of Microsoft moving to shorter release cycles (approximately 12 monthly) then we shouldn't have that long to wait; at least not compared to how long we've had to wait in the past! :-)
I have been using CC.Net successfully for some time, but now I have a problem. I added new solution to CC. It is compiled fine in VS2008, but fails in CC. The main reason is - projects in solution are built in wrong order, with no regard to dependencies. CC just tries to build them in the same order as they are stored on disc (alphabetical order).
For example, in solution there is proect Proj1 and Proj2, Proj1 has reference to Proj2. On CCNET Proj1 is built before Proj2 and throws error "CSC : error CS0006: Metadata file 'D:\xxx\Proj2\bin\Debug\Proj2.dll' could not be found".
I know this could happen when devenv is used to build solutions, but I use MSBuild.
The following code is responsible for building:
<exec>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<baseDirectory>code\src</baseDirectory>
<buildArgs>/p:Configuration=Debug /t:Rebuild PM.sln</buildArgs>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</exec>
What am I doing wrong?
The error Metadata file could not be found:
When it happened to me, it was because there was a file called proj1.exe at that location that should not have been there. So when it used proj1.exe as the reference (instead of a proj1.dll), proj1.exe's reference to a local System.EnterpriseServices.dll failed. This was happening to me with proj1.exe referencing System.EnterpriseServices.dll which referenced System.EnterpriseServices.Wrapper.dll. Where proj1.exe was not supposed to be included in the build but someone had named a unit test app project against our team conventions.
So I recommend checking the references in the project files(unload project and edit project in vs2010 or open each project file with a text or xml editor) to make sure they are ProjectReference not Reference. Also try doing the build with /v:d in the buildArgs list so you get a more detailed build log that will show you where files were resolved to and in what order. Aa different reference that is 'successfully' resolved could be attempting to load x.dll that directly locally references your D:\xxx\Proj2\bin\Debug\Proj2.dll but fails.