I was working on a WPF application in Visual Studio 2015 and all went well until unexpectedly the build dropped me the CS2012 error inform me that it cannot access/update the executable in the /Debug directory.
I tried the following and it didn't work:
Restart
Close VS and open the application again
Build->Clean
I couldn't find any solution in the web so I tried:
1. to move the whole project directory to another location.
2. creating a new WPF project and assembling it file by file with copy/pastes.
The weird thing was that in both cases the application worked in the new location. I continued the experimentation (in the original directory) and i tried to build a "Hello World" Console application in the same directory. The result was that the trivial console application didn't work and produced the same problem as the WPF application (CS2012 error).
Since I haven't noticed any activity of another program (i.e., antivirus) trying to quarantine (or changing the file/folder permissions of) this folder, I assume that this has been done by VS somehow but I don't know why. Perhaps it is a bug.
Is anyone has a logical explanation about this problem? And a way to fix it?
I found that my other running solution was referencing the same < executable path>.
Just make sure that no other process is using the referenced folder/file/dll
Try to close all processes, move the project to a different folder (on a different disk) b restart the computer and everything will work as it should. It worked for me without any problems. Hope this helps someone
I wanted to quickly test something in a .NET Core Console Application Solution and ran into this issue due to BitDefender blocking the resulting binaries.
I've named the app client which actually was the culprit. Renaming my solution fixed this.
Sometimes antivirus softwares can block copying an exe file from a folder to any path. You can manage by settings or the easiest way is to shut down live protection while you are coding and debugging.
:)
Deactivate your anti-virus for a while and try again.
This works for me.
Let -moi explain, I have a web service that can send me the translations I want to XML. I can create an .xml file exactly the same as the string.xml located in the resources of my project. My question is, is it possible to use my xml file instead of it while the program is running?
PS: I use Xamarin Studio.
you cannot add anything while an app is being debugged. Actually, to correct myself; you can but your changes won't be reflected in the app you are debugging. You would need to stop the debugger on the emulator (or close the app if you are using an actual device to test), and rebuild the project to debug it again.
This needs to be done for both code and xml files.
When I run my command-line application from within Visual Studio, one command always fails with below error:
The program '[7316] MyProgram.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
When I debug the code, this happens after the last execute line. Meaning the application performs it's function correctly but then crashes. When I build the project and run the exe file in the command-line I get no error and it works fine.
The project uses a 3rd party dll which in turn AFAIK calls a C or C++ dll, eg. something not coded in .Net.
My questions: Can I ignore this error since the app works fine when built? If not, what could be the potential issue and how can I solve it?
Can I ignore this error since the app works fine when built?
I wouldn't ignore the issue. If your application fails during closing, there is possibly something wrong in destructing the objects and returning the handles to Windows (most likely the latter). This might get you in a production scenario eventually.
If not, what could be the potential issue and how can I solve it?
As said, I think releasing handles is the issue. If you use some third party DLL which is written in C++, possibly there is the issue. Try to set up some logging and see what the stack trace of the exception is. This might give you an idea where the problem is caused. Maybe this is even an issue you can report back to the vendor of the DLL.
I have a c# Azure project that is just a web api, and wanted to remove some of the non-API default components (welcome page, help, etc). After doing so, when launching the application, I get an error message "Object reference not set to an instance of an object." I've seen this before when doing things in Azure, and somehow got around them each time. My question really is: how can I debug this error on my own? This error description is woefully lacking in detail (there's no call stack or anything, as if the app hasn't yet launched, and the dialog is modal so I can't click on anything within VS)
Extra notes:
it's an ASP .NET project.
it works once I publish to Azure.
after copying the project entirely and rebuilding, it seemed to work. then when mucking with NuGet dependencies, we're back to it not working (i've tried deleting my packages folder and having NuGet recreate - no luck; no idea if related to NuGet at all)
I re-copied the project, so just 'MySolutionFolder' -> 'MySolutionFolder - Copy', reopened with same version of VS, runs fine. This is an amazingly sloppy solution obviously, so looking for something better.
As described in a comment, the issue presumably dealt with access rights to various files, most likely NuGet related but possibly Azure as well, which explains why copying to a new solution directory 'fixed' the issue. I would love to see better error info, such as "Error: Visual Studio couldn't write to 'packages.config'", so I know actually where to fix this sort of issue. As it stands now, it's like a compilation error that says "Syntax error in code. Somewhere. Good luck finding it".
Unfortunately, I never did discover a way to debug issues of this sort in a more general way. I eventually worked around the problem, and then saw it pop up again; following advice someone else tried on another forum, I deleted my packages folder, and had NuGet recreate it, which for whatever reason corrected the issue.
Another time, a solution from this question worked (remove and re-add all roles); sometimes this seemed to require an Azure SDK reinstall and computer restart as well.
EDIT
Finally, the best solution I could find was here: delete SUO files and restart VS.
Hopefully this solution will help someone with a similar problem in the future!
tick Debug > Exceptions > Common Language Runtime Exceptions > System > NullReferenceException and run your app
You can enable Intellitrace and remote debug your azure services:
http://blogs.msdn.com/b/webdev/archive/2013/11/05/remote-debugging-a-window-azure-web-site-with-visual-studio-2013.aspx
I've seen similar symptoms when something goes wrong very early in the asp.net app start-up cycle (before the debugger has attached).
One workaround I have used before:
Make sure you are debugging with a local IIS instance and not IIS Express (right click project properties -> Web -> Servers dropdown -> Local IIS
Hit F5 and get your error dialog. (Just to make sure the IIS process has started). Close the error dialog.
Debug -> Attach to Process -> attach to w3wp.exe (iis process). If it's not there make sure 'show processes from all users/sessions' are both checked.
Force a restart of your app by changing the web.config file.
The restart will now occur with the debugger attached to the process from the very start. If that doesn't give any more useful info, then look at turning off 'Just My Code' debugging exception/breakpoint handling and repeating.
For Visual Studio 2019, click on menu "Debug > Windows > Exception Settings".
Under Common Language Runtime Exceptions, tick on System.NullReferenceException. Debugger will break at the point where this exception is caught.
You can setup a local Azure emulator, this is how I've always debugged my cloud apps.
http://msdn.microsoft.com/en-us/library/windowsazure/hh403990.aspx
And maybe do some reading!
http://msdn.microsoft.com/en-us/library/windowsazure/ff683670.aspx
http://msdn.microsoft.com/en-us/library/windowsazure/hh694035.aspx
Inside global.asax:
protected void Application_Error(object sender, EventArgs e)
{
var error = Server.GetLastError();
string message = error.Message;
string callStack = error.StackTrace();
//Write message and callStack to file
...
}
I don't think debugging will help in this case.
However, unloading/reloading your Azure project by right-clicking on it might fix. I'd tried a LOT of things before discovering this one.
As mentioned here.
I also had the "Object reference not set" issue starting Compute Emulator. I found running VS as administrator resolved this.
Changing project target to 4.6.1. seems to have worked for me.
You can debug through logs. Like you can check through diagnostic logs. Enable them through code. There are some configuration for it. I also faced this type of issue and that was very difficult for me to trace. So i enabled the diagnostic logs and write on logs on my custom check point.
I am developing UWP application for remote device using VS17. I suddenly got this message
Error The "WireUpCoreRuntime" task failed unexpectedly.
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at Microsoft.Build.Net.CoreRuntimeTask.WireUpCoreRuntime.InternalExecute()
at Microsoft.Build.Net.CoreRuntimeTask.WireUpCoreRuntime.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() DataManagementApp
And I am stuck at this error for about week. I dont know what cause it. Last thing that I made was that I move GPIO routines to external library. After that, each build ends with this message.
What I tried:
Turn off antivirus
Redo last update (library is working on other similar solutions)
Redo several last changes in build
update VS, repair VS and repair SDKs
update versions of libraries
reboot target device
build project on other PC (with fresh VS), copy code on brand new project and
run it on my or other PC
get rid of anything that using Linq library in code.
Run VS as administrator
With no success at all. I will be very happy if anyone will help me with solving this problem.
I messed up with appxmanifest file. I use AppServices for background work. In this example they have got some changes in appxmanifest file, but they suddenly throws error.
<Application Id="AppServicesProvider.App"
Executable="$targetnametoken$.exe"
EntryPoint="AppServicesProvider.App">
Have to be simplified into
<Application Id="App">
And it throws no error anymore.
I experienced the same error renaming the Assembly name for a UWP application.
I discovered you also need to open Package.appxmanifest and change the Entry point to the same value you used in Assembly name.