Unable to run Console Application from Visual Studio: System.AccessViolationException

3

Description

When launching any Console Application, the code stops running immediately on an AccessViolationException (Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt). More info included in the next section.

Technical Symptoms

The Call Stack only contains external code:

Exception:Thrown: "The message filter indicated that the application is busy. >(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" (System.Runtime.InteropServices.COMException) A System.Runtime.InteropServices.COMException was thrown: "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" Time: 12/10/2015 10:59:55 AM Thread:vshost.NotifyLoad[15344]

I created a new Console Application, containing only Console.WriteLine("Hello world!");

Running the new Hello world app results in the same exception and an identical call stack.

Background

I suspect this has nothing to do with the issue, as I will explain, but I feel it is important to answer the obvious question, "what were you doing when the issue happend?" The last change I made was adding an extension to my Selenium Driver to hotkey logout from an application:

    public static void logout(this IWebDriver Driver)
    {
        Driver.FindElement(By.TagName("body")).Click();
        new Actions(Driver)
            .SendKeys(Keys.Control + Keys.Shift + "x")
            .Perform();
    }

I also made a change in my App.Config file for one of my projects, but reverting this had no impact either.

Removing this code (the Driver extension and/or the App.Config change) does not resolve this issue. Retrieving a previous check-in does not resolve the issue. I am the only person currently working on this solution.

Discoveries

As mentioned, this is happening for an empty Console Application. Windows Form Applications launch fine. Unit Test Projects launch fine as well.

Research

I've spent hours looking into this. It seems like every similar issue I have looked into is pertinent to debugging only or a .NET version. For me, the issue occurs with a Release as well. Additionally, I have been using .NET 4.5 without any issues or changes on that front. I can't find any articles that seem worth posting, but I might be overlooking something.

Visual Studio Info

Microsoft Visual Studio Ultimate 2013 Version 12.0.30501.00 Update 2 .NET Version 4.6.00081 (just noticed it says 4.5 in my project properties, though) Running as Administrator

Feedback

When Running from devenv.exe /SafeMode, Visual Studio loaded with:

An exception was encountered while constructing the content of this frame. This information is also logged in "C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml".

Exception details: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context) at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage() at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()

Additionally, when trying to run, I get an error message of "Error while trying to run project: Invalid Pointer" (again, VS in devenv.exe /SafeMode - see how to run visual studio without plugin and all third party feature if unfamiliar)

Please let me know if I can provide any additional information.

c#
.net
console-application
asked on Stack Overflow Dec 10, 2015 by Steven Repka • edited May 23, 2017 by Community

2 Answers

0

It may be because when you name the project you can't put spaces, I put them and it gave me a AccessViolationException aswell, try using capitals to separate your words, but only use letters and no spaces to be sure.

answered on Stack Overflow Jan 26, 2016 by hansthedude
0

I also faced this issue with Visual Studio 2010. More interestingly I had several projects in my solution (Console application, WPF application, Windows Forms application) but it was failing only when, I was setting the project which was of type "Console Application" as start up project. Following change finally helped me nail down the issue: Go to project properties of the console application project -> Go to "Debug" tab -> Go to "Enable Debuggers" section in right pane -> Check the "Enable unmanaged code debugging" check box as shown in the snapshot below. Root cause of why it happened is still not known to me. Only thing which I observed as fishy was that there were lot of windows updates which had got installed on my machine the previous night which mostly constituted of office updates and OS updates (More than a dozen KB articles).

enter image description here

answered on Stack Overflow Jun 17, 2016 by RBT • edited Jun 17, 2016 by RBT

User contributions licensed under CC BY-SA 3.0