Namespace not found within the same project according to intellisense, yet project builds - visual-studio

I have a simple ASP.Net MVC project which for some reason has issues with intellisense. It is constantly giving me errors that namespaces local to the project can not be found, even though they do exist and the project will build fine. Here's an example:
It is very frustrating as this results in me having no intellisense available whatsoever. Has any one encountered a problem like this before, and do they know of a solution?
The project itself is an MVC4 website running in VS2013 in W8 under Paralells on a Macbook Air, should that have any effect on the problem.
As stated, I have no error messages to provide as the project builds and runs successfully, but please let me know if more details are required.

I had the same issue. Try removing your project from the solution and then add it again. It worked for me. Looks like a solution file quirk.
UPDATE: this is not a permanent fix as closing and reopening visual studio brings back the issue.
UPDATE 2: while looking to fix another issue where I couldn't change the default namespace of a project (I would get a System.Runtime.InteropServices.ExternalException), I found out that it was related to Xamarin tools for Visual Studio. I proceeded to completely uninstall Xamarin. It fixed my namespace renaming issue as well as the weird type or namespace not found / intellisense issue.

I had this same issue, seems to be something with the solution file and building the project as I could replicate the problem by simply creating a new project building then restarting visual studio.
Anyway I get around it at the moment by deleting the solution file and opening the project using the project file.

For anyone reading this in 2020, a fix that I've found that has worked for me is:
cleaning the solution and unloading the projects that have dependencies such as a web API depending on a data project and an application project (right click on the project in solution explorer and find "Unload Project"),
then reloading and building each project in the order of dependence such that they build successfully (right click on the unloaded project in solution explorer and find "Reload Project").
so in my case my data project does not depend on any other project so I reloaded and built that first, then the application project which depends on the data project and finally the web API project which depended on both data and application.

Related

Error publishing .NET MAUI project: the target "_GenerateAppxPackage" does not exist

I have a .NET MAUI project that was created with VS2022 Preview 2, and it builds without errors or warnings and works as expected in the debugger. Prior to updating Visual Studio to Version 17.4.0 Preview 4.0 I was able to publish the project as a sideloadable MSIX from within VS.
Since updating, I get the following error when I click Create in the Create App Packages wizard:
MSB4057 The target "_GenerateAppxPackage" does not exist in the project.
The error is listed against the MAUI project's .csproj file.
I've tried creating a separate new, default MAUI project in the new preview - this publishes ok and (as far as I can see) doesn't contain _GenerateAppxPackage anywhere within its files or project structure. So for now I'm assuming this isn't something new that was added with the preview.
I found some references to _GenerateAppxPackage on the web but they appear to refer to Azure integration. My project is a stand-alone data transformation app that doesn't even access the net.
I'm at a loss what to try next. I don't know what this target refers to, where it should "exist" within the project, or what it does. Can anyone help me understand the problem and/or point me to a solution?
Update: 2022-10-28:
I tried deleting the project structure and creating it from scratch with File -> New Project, then adding back only the .cs and .xaml files. Publishing the recreated project gives me the same error.
I also tried uninstalling the VS preview and re-downloading and installing it. Again, publishing the project gives me the same error.
I still have no idea what is causing this, or even where to start looking.
I faced with the same problem at Visual Studio 2022 17.4.0 (net6.0-windows10.0.19041.0).
The simplest solution for me was be using the command dotnet publish directly.
At root of project just write in terminal:
dotnet publish -f net6.0-windows10.0.19041.0 -c /p:RuntimeIdentifierOverride=win10-x64
I learned today that MAUI is now in the mainline Visual Studio 2022 edition, I've tried using that instead of the preview, and I can confirm that the problem goes away. I wish I'd known about this earlier...

Unable to load solution after upgrading to Xamarin Studio 6

I recently upgraded Xamarin Studio to the latest version, and now I am unable to load my solution!
Upon opening the solution, the below error is displayed:
I have looked into the logs, and I see the following:
System.InvalidOperationException: Already bound to project
Has anyone seen a similar error, or does anyone have a solution?
Thanks!
This error appear to be associated with the following Xamarin bug report:
https://bugzilla.xamarin.com/show_bug.cgi?id=41565
If you are able to try the following workaround, it should allow you to open the project.
Back up the solution
Open each .csproj file associated with an extension (such as WatchKit or Today)
Find the section "ProjectTypeGuids"
Remove the key "FEACFBD2-3405-455C-9665-78FE426C6842"
Save the file
Attempt to open solution
This should solve it for iOS
This also appears to impact Android projects which contain bindings. For example:
Given a test project (Test.csproj) with two ProjectTypesGUID: {EFBA0AD7-5A72-4C68-AF49-83D382785DCF} and {10368E6C-D01B-4462-8E8B-01FC667A7035} the project will fail to load. This is because the first ID corresponds to a regular Android project. The second one is for an Android Binding library project. The problem can be solved by removing the {EFBA0AD7-5A72-4C68-AF49-83D382785DCF} GUID from the .csproj
Fixing the issue for Android is similar to above. If the project contains both ProjectTypesGUID: {EFBA0AD7-5A72-4C68-AF49-83D382785DCF} and {10368E6C-D01B-4462-8E8B-01FC667A7035} then do the steps below
Back the solution up
Open the .csproj file
Find the section "ProjectTypeGuids"
Remove the key "EFBA0AD7-5A72-4C68-AF49-83D382785DCF"
Save the file
Attempt to open solution
Thanks!
Hope it helps :)
My xamarin project was made at windows, I copy to Mac. But Couldn't open same error. I solute with doing this. Open solution from windows visual studio. and right click solution then open xxmanager(i don't know english menu name, short cut maybe "o") and check build IOS. and copy to all solutions and project files to MAC. Then retry open solution. good luck
I have been experiencing this issue for hours. It started suddenly when Xamarin.iOS was giving issues due to lack of reference.
I tried the solutions here including removing the guid in Project Build but nothing worked.
To fix this, I realized that Visual Studio for Mac had downloaded an update which I installed and restarted immediately. I then noticed that Visual Studio Xamarin Form iOS component is missing at it states the presence of an update to 12.xxx.
I simply re-downloaded the iOS components (about 550Mb) and I am hoping everything would work fine.

Dotfuscator 4.10 project in VS 2012 bugs while trying to save .dotfuproj file

I recently installed Dotfuscator 4.10 on my computer and I already has VS 2012 working on it. Everything worked fine up to the point when I tried Dotfuscator embedded in VS (I mean the standalone GUI app works perfectly).
Just for the try, I created a small solution (no TFS/VSS) with a C++ /clr app, a C++/clr dll and a C# app.
I then added a Dotfuscator project. To this project I added the output from the three dll/exe other projects.
When I tried to rebuild the solution, I was asked to save the .dotfuproj file. Strange and abnormal behaviour, the file should be saved automatically and without prompting me. OK, I chose to overwrite the existing file (what should have been done automatically after all.) I got the error Object reference not set to an instance of an object. I had to cancel the operation and could not build the solution.
Note that I observed the same behaviour if I tried to save the dotfuproj file under an other name. Also, the file is not R/O.
My question: has someone experienced this problem? Any solution? Thanks for your help!
You can try deleting your Dotfuscator project and then creating a new project. If that does not work, try using direct input to the Dotfuscator project, rather than using the output of another project within your solution.

Can build solution in VS2010 but not in VS2012

I have a solution with four projects in it which was initially created in VS2010.
I have now opened the project in VS2012 and everythings works fine, except when I am publishing the project (Web application) (building and testing works fine!).
When publishing I get the error "Could not get dependencies for project reference 'ProjectName.Model'".
If I then open the project (same folder!) back in VS2010 I can build it from there without problems.
Of course I can use VS2012 for all development and go back to VS2010 everytime I need to publish, but I would rather find a permanent solution to how to solve this!
I have tried removing my ProjectName.Model from the project and re-inserting it in VS2012, but it still did not solve the problem.
EDIT: 2013-08-06 13:37: Have found the following error msg: Could not get dependencies for project reference 'ProjectName.Model'Warning: Unable to update auto-refresh reference 'ajaxcontroltoolkit.dll'. Cannot find assembly 'G:\Dev\2012\JournalBase\WebSite\Bin\AjaxControlToolkit.dll'.
Have taken over the project from a colleague, and I can see that I do not have the folder G:\Dev\2012.... So I searched for the term "AjaxControlToolkit", but couldn't find it anywhere as text in the solution! Anyone knows where I should be able to find the reference? Apparently not in the .sln file or the .csproj file for project ProjectName.Model.

The working directory does not exist in Visual Studio 2010

I am using Visual Studio 2010.
I wanted to study some code that dumps relevant data in a database, find out how it works and adapt it to my own version.
I only got as far as loading the solution in VS 2010, hitting the "Start Debugging" button, and then I got this error:
The working directory does not exist:
'D:\Dev\CodeProject\articles\smartcardfmwk\Smartcard_Framework
How can I fix this error?
The source code in question is Smart Card Framework, from Code Project
I downloaded the "Updated Project (VS2010)" and I can open it in VS2010, as well as build, but debugging just wouldn't work.
I did not try replicating the path yet, but as this is a working project, my company requires that it is placed on a very specific location accessible by others.
Nevermind, I got it. It was so simple, I'm sorry for wasting anyone's time.
The source Solution had a lot of Projects under them. I figured at least one of them was pointing to a directory that doesn't exist, so I waded through the Projects,
I right-clicked a Project and clicked the Properties
This will open up the ProjectName Property Tab
Under the Debug tab, there is a filed called "Working Directory"; I changed it to where the project is currently located.
This solved my problem, for now, unless there's a Project I missed. I am wondering, though, if I have to do this again if I move the Solution elsewhere.
This happened also in VS 2019 after importing / upgrading an old C# project. I was not able to see any project properties to change.
Finally it was fixed by manually editing the file <ProjName>.user.csproj as follows:
Replace
<StartWorkingDirectory>[wrong directory name]</StartWorkingDirectory>
with
<StartWorkingDirectory>.\</StartWorkingDirectory>
I also faced this problem that working directory does not exist, but I managed to solve it. There are certain steps to follow properly Whenever this error occurs.
In VS, open the "Project" at Toolbar.
Then go for Project properties.
Select Debug And check your working directory. If the path is wrong just browse it...

Resources