Visual Studio ASP.NET crashes after Stop Debug in Chrome - visual-studio-2013

I'm working on a website which can stream audio files to the browser. It's a asp.net application which im developing in Visual Studio 2013. To stream the audio to the client im using partial content response using the range request headers. The code looks like this:
[HttpGet, ActionName("GetFile")]
public HttpResponseMessage GetFile(string fileName)
{
var rootPath = AppDomain.CurrentDomain.BaseDirectory;
var fullPath = Path.Combine(rootPath, "SoundFiles", fileName);
byte[] file = File.ReadAllBytes(fullPath);
var mediaType = MediaTypeHeaderValue.Parse("audio/mpeg");
var memStream = new MemoryStream(file);
if (Request.Headers.Range != null)
{
try
{
var partialResponse = Request.CreateResponse(HttpStatusCode.PartialContent);
partialResponse.Content = new ByteRangeStreamContent(memStream, Request.Headers.Range, mediaType);
return partialResponse;
}
catch (InvalidByteRangeException invalidByteRangeException)
{
return Request.CreateErrorResponse(invalidByteRangeException);
}
}
else
{
var fullResponse = Request.CreateResponse(HttpStatusCode.OK);
fullResponse.Content = new StreamContent(memStream);
fullResponse.Content.Headers.ContentType = mediaType;
return fullResponse;
}
}
Every time a song is played this method is called to get the file from the server and to stream it partially to the client. The whole application is built with signalr.
This worked perfectly for me there is nothing wrong with that code. Until i bought a new pc. I installed my Visual Studio 2013 normally on it including IIS Express 8.0 etc. But something strange happened to this.
If I start debugging with Google Chrome, and then if I do normal things to the website but not playing a song (not calling the method), and then stop debugging it again I have no problems. But if I start it in Chrome and play the song (call the method) and then try to stop debugging, visual studio freezes but there is no information that it is hanging. Its just hanging and I cannot close it. I cant even close it with the task manager. No error is showed. If I try to shut down my pc, then the pc won't shut down until I press the power button a long time. Now the strange thing: If I try the exact same thing but in Internet Explorer, Visual Studio works normally and is not hanging at all. This only happens if I use Chrome for debug and only on the same host as Visual studio is running. If I connect a Chrome on a other Device in my network, it does not have any effect.
I figured out, that I can run the application without debugging. If I do that it works good, but if I play a song and then try to close Visual Studio, it shortly hangs for about 30 seconds and then quits.
I am unable to find out what the problem is.
What I already tried to do:
Reinstall Visual Studio 2013
Try with Visual Studio 2015, same effect
Reinstall Windows 8.1
Reset Import/Export Settings in Visual Studio
Run Visual Studio as Administrator
Move SoundFiles to an other directory
Try with Google Chrome Canary, same effect
And the really strange thing is, that it only happens on Chrome on the same machine, and only on my new pc. The same scenario works perfectly on my surface or on the old laptop.
What I could imagin, for the chrome reason is, that chrome uses range requests and ie does not. It takes the full Response of audio as 200 and chrome takes the range as partial content. This could be the problem, but I'm not sure and I don't know how to solve or workaround this problem.
Have you guys an idea, what could causing this problem?

Ok, I didn't manage to find the problem, but I found the solution. Because it was a new PC, there was little bit of bloatware on it. I've uninstalled the things I don't needed, and then it magically worked. No crashes anymore. I have a ASUS ROG G20AJ. I don't know exactly which of the bloatware was causing the problem, but it was some of them. So if you have a similar problem on a ASUS Machine, try uninstalling some of the not used software.
It wasn't Visual Studio crashing, it was the IIS Service. I really think that this is a really strange behaviour, because the crashes did only happen, if I executed the code snippet above... Anyways, it works now!

Related

Problem opening Office URI Scheme urls in Office.js on Mac/Safari

I'm developing a JavaScript addin for Office applications, e.g. Word, Excel and PowerPoint. At some point it should open a file that resides somewhere in SharePoint.
I want the url to open the correct Office application right away and for this purpose I'm using Office URI Schemes (see https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes?redirectedfrom=MSDN).
Depending on the logic in the app, I'm using two different techniques, which work perfectly when the addin is running in Word, Excel or PowerPoint on Windows.
Technique 1 (normal link)
Open Me!
Technique 2 (programmatic)
// Js pseudo code
button.onclick = () => {
window.location = 'ms-word:ofe|u|https://foo.sharepoint.com/path/to/file.docx'
}
As I mentioned, both these techniques works flawlessly on Windows. But when running the addin on e.g. Word Desktop on Mac, absolutely nothing happens. I've debugged the addin, by using "Inspect Element" to open up the console, but there's no errors or anything. It seems to me that the internal browser on Mac silently refuses to open the link.
However, if you paste the link into e.g. a word document, it will open the document if clicked.
Some thoughts:
is this related to the manifest.xml for the addin? (still works on windows without modifying the manifest)
do I need to enable something on Mac for this to work? (the Office URI Scheme page states these links should work on Office for Mac 2011)
Any input is greatly appreciated.
I found a workaround that works on Mac as well by using window.open(url).

Browser Console for AOL Desktop?

I participate in development of a site that has a significant number of users who view our site through the AOL Desktop v9.7 for Windows - which spawns browser windows inside itself. When debugging, I don't have the tooling I would normally be able to invoke (for example Chrome's Developer Console; Firebug; MSIE's F12 developer tools).
When inside AOL Desktop, I don't appear to have any of these, or anything similar. Is there a developer mode or console I can invoke, unearth?
What I meant in my comments, you could just use a very decent JavaScript debugger with manual DOM inspecting features, which comes with Visual Studio ([EDITED] including the free edition). With some tricks, it does work for AOL Desktop, too (what an amusing piece of software that is, BTW :) Of course, this is not the same as IE's F12 Tools, it lacks the interactive features like visual DOM tree, CSS tracing etc. But it still allows to step through the code, watch locals and objects, evaluate expressions and access DOM elements. It's an invaluable tool and I use it a lot for projects where we host the WebBrowser control. After all, that's what AOL does, too. Anyway, if you're already familiar with this, just give this post a smile and disregard it. Otherwise, read on :)
I tested the following under Win7 SP1 VM with IE9, Visual Studio 2012 Pro (Update3) and the latest AOL Desktop 9.7. [EDITED] It also works with the free edition, Visual Studio 2012 Express for Desktop, Update3.
The only major obstacle was that in about 20 seconds upon entering the debugger, AOL Browser used to restart itself, thus disconnecting from the debugger. A workaround for this was to close AOL and delete the following files:
"C:\Program Files (x86)\AOL Desktop 9.7\"
shellmon.exe
shellmon.ini
shellrestart.exe
Then, I used the following basic HTML file for debugging purpose (as "debug.html" in the root of localhost):
<!doctype html>
<html>
<head>
<title>Debugger Test Page</title>
<script>
function debugPrompt()
{
if (confirm("debug?"))
{
debugger; // breakpoint
alert("after debugger");
}
}
document.onkeydown = function()
{
if (event.altKey && event.ctrlKey && event.keyCode === 'D'.charCodeAt(0))
{
event.cancelBubble = true;
debugPrompt();
return;
}
}
</script>
</head>
<body>
<button onclick="debugPrompt()">Debug</button>
</body>
</html>
Here's what I did exactly:
Made sure Script Debugging is enabled in IE settings for both Internet Explorer and Other:
Made sure [x] Script is checked in VS2012 Debugging Settings, Just-In-Time section ([EDITED] this feature is missing from VS2012 Express, but it isn't really important):
Ran AOL and navigated to localhost/debug.html.
Ran Visual Studio and attached to the aolbrowser.exe process (with Script as the target kind of code), via Debug/Attach to Process menu:
Went back to AOL and hit Ctrl-Alt-D (invokes the "debugger" prompt in my JavaScript listed above). The next thing, I'm in the VS Debugger right at the debugger; line of code. At this point, all usual debugging features are available. Note the Immediate Window panel and the Watch1 panel. Also, instead of hard-coding breakpoints with debugger keyword as I did, it's possible to use Visual Studio Solution panel (once the debugger has been attached) to select one of the JavaScript files loaded by the page and toggle breakpoints interactively.
Right now, I don't have Visual Studio Express 2012 to verify if the same is possible with it, although I assume it should be. I'll give it a try a bit later.
[UPDATE] Almost all of the above applies to the freely available Visual Studio 2012 Express for Desktop w/ Update3, with one exception: Just-In-Time Debugging option appears to be absent. This is not a show-stopper though, as it is still possible to attach to the running AOL process and debug the currently loaded page the same way.
PS. And thank you for your voluntary bounty offer on an unrelated question of mine, that is a really nice gesture.
Just in case anyone comes here looking for information: the newest 9.8 version of AOL Desktop now includes Chrome's developer tools, which open in a new window when you press F12.

adding/removing a file in VS2010 causes "WebDev.WebServer20.exe has stopped working" error

This is driving us crazy... In VS2010, MVC2 projects, not all projects.... both on a project that was upgraded from 2008/mvc1 and on a brand new project created within 2010/MVC2, we have the following behavior:
1) develop as normal..
2) hit F5 or CTRL-F5 to open up a browser
3) works great!
4) add a CSS file (or JS file or any file, or remove any file) in the project
5) immediately the dialog pops up "WebDev.WebServer20.exe has stopped working"
You have to close the program, and "F5" again - and all is right with the world...
Say we then modify an existing css file. No problem. But adding or removing one, immediate crash.
It seems like the development webserver is "locked on" to the project file and when it detects a change, it dies.
The Event Viewer is pretty unhelpful. The following is logged:
Faulting application WebDev.WebServer20.exe, version 10.0.30319.1, time stamp 0x4ba204ca, faulting module KERNEL32.dll, version 6.0.6001.18215, time stamp 0x49953395, exception code 0xe053534f, fault offset 0x000442eb, process id 0x%9, application start time 0x%10.
This is happening on all of our developer workstations, which include some with Windows Sever 2008, some with Windows XP, and some with Windows 7. All are running VS2010 Premium with ReSharper.
Also, the same thing happens on projects which target the 4.0 framework, only the error message referrs to WebDev.WebServer40.exe instead.
Google has revealed nothing. We've already tried "setting a static port" instead of a dynamic port - no help.
Please help if you can.
So, as it turns out, the problem was due to a certain use of MVCTurbine and StructureMap, but it seems likely that the problem would also occur with other IOC Containers, not just StructureMap.
The author of MVCTurbine has expressed that the fix will be in version 2.2 of that product.
In the meantime, one extra line of code in your Global.asax will solve this problem:
//VNEXT: after Turbine 2.2 we wont need this line anymore...
protected override void ShutdownContext() { CurrentContext = null; ServiceLocator = null; }
This article shows the particular use case we were addressing. The "normal plain vanilla" use of MVCTurbine and StructureMap would not have this problem.
Obviously, great thanks to Javier for being so responsive to help requests!

Visual Studio debugger problem

In Visual Studio 2008, after debugging about 1-2 minutes, when I press F10 (Step Over), the debugger hangs and Visual Studio freezes for 5-10 seconds and then go to the next line. Then whatever I do (F10, F5, F11, etc), the debugger continues the execution as if i pressed F5 and all my forms that I was debugging close. I always have to restart the application.
It is very hard to reproduce and it does not occurs every time I want to debug something. Does anyone has a solution ?
EDIT : I've managed to reproduce my problem with the following code :
static void Main(string[] args)
{
XElement e = new XElement("root");
Test(e, 0);
}
static void Test(XElement parentElement, int i)
{
if (i < 1000)
{
XElement element = new XElement("element");
parentElement.Add(element);
Test(element, ++i);
}
}
You need to put a conditional breakpoint on the line "XElement element = new XElement("element");" with the condition "i == 999". Then start the program, wait 2-3 seconds and put normal breakpoint on the line "parentElement.Add(element);". Now VisualStudio freezes and it is impossible to debug. In a WinForm application, it closes all the forms that are open after pressing F10.
But I found that if I disable the debug option "Call string conversion function on objects in variables windows" in "Tools -> Options -> Debugging", I can debug. It is slow but at least VisualStudio doesn't freeze. Does anyone know why it is doing this? Because I don't want to disable this option, it's really annoying to debug without it.
I also noticed that if I only put a breakpoint at the end of the main method, the code runs really fast compare to having a conditional breakpoint in the recursive method.
Try deleting the solution user options file (.suo) where the debug/breakpoint information is stored. You will lose all solution user settings, such as breakpoint locations. When you have "funny" debugging incidents, this is the first thing to try because this file can get corrupted.
If this does not solve the problem, then you have something else going on, such as threading issues, excessive memory fragmentation, garbage collection issues, dispose/finalize issues, and so on.
I found the answer to this question on another Stackoverflow thread. There's a MS hotfix for this issue.
I've found that I get slowdowns like this whenever I have added remote unc shares that don't exist to the list of symbol directories.
Try going to Tools -> Options -> Debugging -> Symbols and make sure that all of the directories in that list actually exist.
I have no idea how that would cause your program to continue after that point however.
Not sure I've ever run into this, but if I were you, if you haven't, delete your bin folder, and rebuild your project. Then run a clean solution to be safe. Sometimes, funky things can happen with your PDB's getting out of date -- so you need to clear them out.
Also, if your calling outside assemblies, remove them and reattach them to make sure you have the most up-to-date assemblies.
I have had this exact same problem just as you described. The MS Hotfix addressed the issue and now I install this hotfix whenever I do a fresh 2008 VS install.
Please download the fix from this link
http://support2.microsoft.com/hotfix/KBHotfix.aspx?kbnum=957912
I know this is an old thread but this occurred when debugging an Excel add-in in my case.
Problem was that my breakpoint was in a background thread and in my watch window I had an old check on the ActiveWorkbook in Excel. That call just like many others should only occur on Excel's main thread.
Once I removed that watch, it debugged just fine again.

Debug assertion does not prompt in IIS 7

since moving to Windows 7 (IIS 7.5), the debug assertions do not prompt a pop up dialog anymore.
I have tested this in a separate project, and noticed that they do work when using the integrated Visual Studio Developer server (Cassini) but they do not work when using IIS Web Server.
This is a big issue for us since we are counting on debug assertions to identify potential programming errors, so any help would be appreciated.
Thanks. Eyal.
That's because failed debug assertions are displayed in the Output window now instead, under the Debug section.
To view the Output window in Visual Studio 2008 go to the 'View' menu and click 'Output'.
I also find it inconvenient. Some more info...
You can work around by using
System.Diagnostics.Debugger.Launch();
You can make for example this function
[Conditional("DEBUG")]
public static void AssertEx(bool condition, string message)
{
if (condition) return;
System.Diagnostics.Debugger.Launch();
// Still write the message on output
Debug.Fail(message);
}
and get similar results.
That is the default behavior now and it cannot be changed.
What you can is generate a file with the assertions that failed in your app. That will still help you track your issues without halting the app when running inside the IIS.
Take a look at this good article about it.

Resources