In a solution I am working on, in a sub project I have added a reference to another project. After adding the reference, I was able to successfully add the using statement and have the auto-complete pick up the right extension I was looking for. The code wrote as usual, but when I compiled, I get the error
The type of namespace name 'Name1' does not exist in the namespace 'Name2' (are you missing an assembly reference?)
So I have searched the forums, I have added several other system references and I have gotten nothing. I ran NuGet to update the solution packages, and that didn't make a difference either. For some reason, when I add the reference (using the add reference pop-up GUI) the reference to Name1 doesn't have a dll file in it. If I browse to the dll file directly, it still gives me the same issue when compiling.
Maybe you can copy the dll to [projectname] / Debug /
or [projectname] / Release /
Related
I have a web ASP.NET project with the bellow structure:
I copied this solution to my test computer and now I get
The type or namespace name 'BussinessLib' could not be found
HousingSurvey is the startup project .
Each project get built successfuly but when I try to build the solution I get
The type or namespace name 'BussinessLib' could not be found
As you see BussinessLib is a reference for Housingsurvey. The using BussinessLib statement is set correctly in the HousingSurvey .
So I rebuild BussinessLib and add the reference to Housingsurvey. Housing Survey as a project builds successfully. but again when I build the solution I get The type or namespace name 'BussinessLib' could not be found
To make things stranger when I check
C:\CSharpTest\HousingSurvey\HousingSurvey\BussinessLib\bin\Debug
BussinessLib.dll is deleted somehow(After I build the solution). I double checked BussinessLib.dll and saw it does get created there whenever I build the BussinessLib project.
I found the most promising answer here:
The type or namespace name could not be found
But above answer did not help me since all of 3 projects in my solution are targeted to the .NET Framework 4.5
Any feedback is greatly appreciated.
Update: please note that this whole solution builds "Successfully" in my UAT computer. Then I copy paste it to the test computer and it fails on build.
For some weird reason, whenever I build the whole solution, Business.dll gets deleted from the bin folder! and that's why code that references it can not find it.
From the HousingSurvey Project, delete the reference to BusinessLib and re-add it again. It is probably an issue with a file path for the original reference.
Also when you add the reference to the project again, be sure to set the 'Copy Local' property to True
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.
I create a new solution called "WordpressAutomation"
I create a new project, a class library, called "WordpressAutomation" in this solution
I create a new project, a unit test project, called WordpressTests in this solution
I add a reference to the project WordpressAutomation in the project WordpressTests"
This should be ok, shouldn't it?
However, as can be seen from the screenshot, when adding this using line in a class in the project WordpressTests,
the reference doesn't work. Even though it is there, as can plainly be seen.
When entering "using", the class library "WordpressAutomation" doesn't appear among the alternatives.
And I get this error message when trying to run:
"The type or namespace "WordpressAutomation" could not be found (are you missing a using directive or an assembly reference?)"
Why is this happening? The reference is clearly there?
http://i.stack.imgur.com/L0g5R.png
Your project isn't actually including the .cs files to compile; they are only shown for information (they should appear as solid files with the C# logo):
Right click on these files and include them in the project. Then check what namespace they declare inside them. At the moment, your WordpressAutomation project simply doesn't contain any types.
I am on .NET Framework 4.0, building a C# web application in VisualStudio 2012. I have Microsoft.VisualBasic added as a reference to the project. I am having trouble with the following line of code:
using Microsoft.VisualBasic.FileIO;
Building the solution returns the error: The type or namespace name 'FileIO' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
I have removed and re-added the reference to the assembly Microsoft.VisualBasic, but still get the error. Microsoft.VisualBasic is in the GAC, as well as Microsoft.VisualBasic.Compatibility, Microsoft.VisualBasic.Compatibility, Microsoft.VisualBasic.PowerPacks.Vs, and Microsoft.VisualBasic.Vsa.
Please let me know how to get VS2012 to recognize the FileIO namespace.
Right-click on your project and select Add Reference...
In the Reference Manager, expand Assemblies and select Framework. Then check the box for Microsoft.VisualBasic and click OK.
I had similar issue, fixed by change TargetFramework (in .csproj) from netstandard2.0 to netcoreapp3.0.
Application references are not available to uncompiled files in your application (aspx, ashx). There are two solutions to this issue as follows:
1) Move your code to a compiled part of the application (cs/vb file)
or
2) Add the reference to the web config
My reference was in an ashx file. I simply copied the code from the ashx file to the clipboard, deleted the file from the project, added a new Generic Handler (right click in Visual Studio > Add > Generic Handler), entered the same name as before, and pasted the code from the clipboard into the cs file editor that Visual Studio opened. I now have a cs file that will compile with the project and use the project reference. The file name is the same, so there is no need to update anything else -- just rebuild and deploy.
I have a c# project with a reference that cannot be found when checking in to TFS. The project runs fine when i debug.
It its in my services project the problem is located. I have a reference to lets say ProjectSec. And i have a wewbservice reference to Projectservice.
The webservice uses the ProjectSecurity.Security namespace that is located in the ProcectSec assembly.
When i check in my files i get the following error:
The type or namespace name 'ProjectSecurity' could not be found (are you missing a using directive or an assembly reference?)
Could not resolve this reference. Could not locate the assembly "ProjectSec". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
The ProjectSec.dll is located in the lib folder and its there. There is no error when i try to use it elsewhere in my project.
This may not be a perfect explanation but does anyone know what i could try?
I have removed the reference and added it over again, but no luck.
A common pitfall with TFS-build is to have in Source Control something, for example, like this:
$/Sources/Webservice
$/Libs/ProjectSecurity
And then, in the build definition that is validating your checkin, to have only
Active | $/Sources/Webservice | $(SourceDir)
as workspace mappings.(You can access this by right-clicking on the build definition in TeamExplorer, select "Edit Build Definition.." & go to Tab "Workspace")
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.