When trying to load a file from a target project directory using in C#
Directory.GetCurrentDirectory()
Visual Studio keeps looking for the file in
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\
The problem is that an annoying error about it keeps appearing, although the application builds, compiles and runs without issues, since the file exists in the project target directory.
Does anybody have any idea or previous experience?
Right click on the error -> Show error help, got me to this page, and by doing this, the error disappeared. I am yet to understand, how that had anything to do with the xaml designer.
I have a C# project opened in visual studio. We are using TFS to manage our projects. In one source code file of the project I have configured a warning in the following way:
#warning expand for all properties
When I compile my project the warning is shown in the error list twice. Once in the original file, and once in a file called vctmp2984_94722.cs. I can open the temporary file in visual studio and it has a previous state of the file.
Opening the file in explorer is not possible, cause the path of the temporary file points to a place that does not exist: C:\Users\developer\AppData\Local\Temp\TFSTemp\vctmp2984_94722.cs
Does anybody nows how to solve this?
Did you have a "compare" running (with the "Diff - xxx") window open when you kicked off your build? I noticed that I was getting this---a ton of vctmp errors in a project called "Miscellaneous Files", but when I closed the Diff window they all disappeared.
I have a WPF project that I am ready to deploy using Visual Studio 2012 but I'm running into a missing folder issue.
If I Start the project in VS it runs fine and my test button works as expected.
When I Publish the project, the publish succeeds, running setup.exe installs successfully and program starts to main window fine.
Clicking the test button crashes the application.
Line that causes crash:
string[] reportFileNames = System.IO.Directory.GetFiles("Reports");
"Could not find a part of the path 'C:\Users\dirt\AppData\Local\Apps\2.0\GEDD6PQW.N72\8M9ONPGG.TVB\prof..tion_40c30d08e677b188_0001.0000_9a5540d4bfbe5aff\ Reports'."
Confirmed Exists:
C:\MyProject\bin\MyMode\Reports\
C:\MyProject\bin\MyMode\Reports\MyReport.rdlc
Confirmed Does Not Exist: C:\Users\dirt\AppData\Local\Apps\2.0\GEDD6PQW.N72\8M9ONPGG.TVB\prof..tion_40c30d08e677b188_0001.0000_9a5540d4bfbe5aff\Reports\
The Reports\MyReport.rdlc files have a Build Action of Resource and Copy to Output Directory of Copy always.
What am I missing?
Ok, was able to figure this one out rather quickly after typing that last sentence in the question...
In my case the Reports\MyReport.rdlc file had a build action of Resource and all I had to do was change it to Content (and make sure Copy always is set).
Solution:
Right click File in Solution Explorer -> Properties -> Build Action -> Content
I have the following problem. There is a custom build process which is using the custom build activity. I've been opening this build some time ago, and everything was good. But, after some time, the custom build activity and build process has changed, got new arguments and some other changes. This activity has been updated on the server source control path, which is set in build controller settings. But, it seems that this activity doesn't want to be downloaded on my desktop, because when I open build definition, I'm getting error that my new custom type couldnot be resolved.
I've tried to build this activity by myself and place it to the folder, which contains devenv.exe, and this "solved" problem - my build process has been opened. But It is not normal.
What should I do to normally open my build definitions?
The contents of custom assembly folder defined for controller is downloaded to temp folder and loaded by studio once (im not sure if proper version increments for dlls would solve this - haven't tried) when opening the process tab on build definition. You either have dlls somewhere that overrides this (GAC, VS private assemblies) or your studio has been running for long time.
Remove the one you put along devenv, restart studio, check GAC and private assemblies, you can use Studio and attach debuger to other instance and review loaded modules this can help you pinpoint where the item is comming from.
To remove assembly run following from Visual Studio command line: gacutil /u "YourAssembly"
For studio assemblies i believe this is the folder: Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
I have a WebApplication which contains reference to WCF services.
While building using Visual Studio 2010, Build fails without any error or warning. However building the .csproj using MsBuild is successful.
Can't figure out what should I try in Visual Studio, to resolve / diagnose the issue. Can you please help out?
I find out that the build has been failing,
From text displayed in status Bar.
From output window:
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
The output tab includes configuration details.
------ Build started: Project: <projectName here> Configuration: Debug Any CPU
I noticed that if "Build + Intellisense" is selected in the Error List, it causes the error messages to be swallowed.
Change this option to "Build Only", and all error messages will be displayed:
I don't know if this is a bug in Visual Studio or what, but it certainly revealed hidden error messages that were the key to pinpointing the failure for me.
Some, like Richard J Foster, have suggested increasing the "MSBuild project build output verbosity" setting to "Diagnostic" (the highest possible option), but this didn't solve the problem for me, as Visual Studio appeared to be suppressing the error message(s) themselves.
As an alternative, you may try to use the raw output messages from the "Output" tab, which haven't been filtered by Visual Studio. Either do an in-place search for the strings "error" and/or "failed", or copy all of the output to your favorite text editor and do a search there.
To ensure that the Output window appears each time you do a build, you can go to Tools → Options → Projects and Solutions → General, and ensure that the option "Show Output Window when build starts" is checked.
As an additional troubleshooting step, it is also possible to build the project from the PowerShell command line by running dotnet build. This will show you the complete build output, including any errors that Visual Studio may be hiding.
I just ran into a similar situation. In my case, a custom action (from the MSBuildVersioning package available on Nuget.org - http://www.nuget.org/packages/MSBuildVersioning/) which appeared in the csproj file's BeforeBuild target was failing without triggering any error message in the normal place.
I was able to determine this by setting the "MSBuild project build output verbosity" (in the latest Visual Studio's Tools tab [Path: Tools > Options > Build and Run]) to "Diagnostic" as shown below. This then showed that the custom action (in my case HgVersionFile) was what had failed.
Here are some things that you can try:
If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
Ensure that all dependency projects are built to target the same platform as your main project.
Try restarting Visual Studio.
As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
Try restarting your computer.
Try "Rebuild All".
Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
Delete the hidden .vs folder & restart Visual Studio. That worked for me.
I want to expand on Sasse's answer. I had to target the correct version of .NET to resolve the problem.
One project was giving me an error:
"The type or namespace name 'SomeNamespace' does not exist in the namespace 'BeforeSomeNamespace' (are you missing an assembly reference?)".
There was no error in the Error List window but the assembly had a yellow warning sign under "References".
I then saw that the referencing project targeted 4.5.1 and the referenced project 4.6.1. Changing 4.6.1 to 4.5.1 allowed the overall build to succeed.
Nothing was working for me so I deleted the .suo file, restarted VS, cleaned the projected, and then the build would work.
I tried many things like restarting Visual Studio, cleaning and rebuilding the solution, restarting the PC, etc., but none of them worked for me. I was finally able to solve the problem by doing the following:
First of all, make sure all the projects in your solution (including tests) are targeting the same .NET version. Then:
Save pending changes in the project and close Visual Studio
Find the exact location from file explorer and find "obj" file and open it,
Then, delete all the included files (some files won't remove, it doesn't matter, just skip them).
Use run command (by pressing Windows Key + R) and type "%temp%" and press enter to find temporary files.
Finally, delete them all.
On other possibility is that Visual Studio needs to run as Administrator, this might be related to deploying to local IIS server or other deployment need.
Just for the sake of completion and maybe helping someone encountering the same error again in the future, I was using Mahapps metro interface and changed the XAML of one window, but forgot to change the partial class in the code-behind. In that case, the build failed without an error or warning, and I was able to find it out by increasing the verbosity of the output from the settings:
In my case (VS 2019 v16.11.20), disabling Text Editor->C#->Advanced->Enable 'pull' diagnostics in the options solved the issue.
Double check for _underscore.aspx pages in your project.
I had a page and code-behind:
`myPage.aspx` and `myPage.aspx.vb`
when building the project, I'd get errors on the .aspx.vb page stating that properties defined on the .aspx page didn't exist, even though the page itself would build fine and there were NO OTHER ERRORS showing in the output (even with diagnostic level build output).
I then came across a page in the project that was named the same thing but with an underscore: _myPage.aspx - not sure where it came from, I deleted it, and the solution built fine.