I've got a very bizarre situation. It appears that, when I load a webpage to my browser,
multiple threads (at least 2) are starting up. The app loads and runs fine on a
Windows XP box, but when I try to run it on my Windows 8 laptop it would seem that
more than one startup event is taking place and causing all kinds of collisions. This
is happening with both Firefox and IE.
To verify this behaviour, I placed a static int within a class, checked it to see if its
value is greater than zero, throw an exception if it is, then increment the int.
Of course, the exception is thrown.
What's very weird about this is that there is no multi-threading/multi-tasking involved
within my app.
When I "touch" the DLL for the webpage (rebuild it), it renders the webpage properly,
but the source for the webpage ("right click" > "View Page Source") has the source
for the unhandled exception webpage, with the message for the exception that my code
throws when the thread count is greater than zero.
I've tried creating a new project, then linking the code to it (Add Item ... Ad As Link),
then building it. It didn't do any good.
The Win XP system has IIS 6 with .NET 4.0, and the Win 8 laptop has IIS 7 with .NET 4.0.
Language is C#.
The truth is that I'm pretty much clueless about IIS.
I hope someone smarter than I am (which isn't saying much) has an idea as to what
is going on.
It appears that, when I load a webpage to my browser, multiple threads (at least 2) are starting up
Maybe onetime initializations. I doubt that every request causes an additional two threads to stay around.
it would seem that more than one startup event is taking place
That's normal This event fires for each instance of HttpApplication being created. This is basically a design error in ASP.NET. They thought that pooling HttpApplication instances and assigning one of them for each request was a good idea. It would have been better to have a singleton per AppDomain. Write this yourself. Like that:
class MyGlobalAppState { ... }
static Lazy<MyGlobalAppState> state = new Lazy<...>(StateFactory);
Be aware, that Lazy<T> stores any exception and just rethrows it. This causes your app to be permanently broken in case StateFactory throws. It will never recover without pool restart. This is a design error in Lazy<T>. Find a way to deal with that.
but the source for the webpage ("right click" > "View Page Source") has the source for the unhandled exception webpage
Some browsers re-GET the page to view the source. This can be annoying or handy.
It is hard to tell what is causing this behavior but as others suggested try to use Fiddler or any other http tracing tool to see what requests are sent.
Also, Win XP should be running IIS5.x while Win8 should be running IIS8.
By default IIS8 AppPool should be running with the integrated pipeline, which may behave differently. I would try changing the AppPool to use the Classic pipeline to see if it makes a difference.
Related
I was in the middle of developing an update to my Xamarin Forms app, but when I debugged it on my iPhone, it crashed immediately on startup with the following message:
Assertion failure in -[UIApplication_runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com/apple.xbs/Source/UIKit/UIKit-3600.5.2/UIApplication.m:3679
It was previously working fine, but now I can't run the app on my phone anymore without this crash. I have rebuilt several times and deployed from different computers, but nothing helps. How do I fix this issue?
Edit:
Before this started occurring, I had made some additions to the code. Unfortunately, after removing all of my changes, this issue is still plaguing further development. Any help or resource that might lead me to a solution will be greatly appreciated.
After some deep searching, it turns out that I mistakenly removed a part of my Application's constructor that initialized the MainPage. As a result, MainPage remained null. The framework probably tried to call a method or access a property without checking if the reference was null, causing the error. I'm not sure how long that mistake has been there.
This can also happen if you are not quick to launch a view. Avoid calling APIs or other lengthy processes before a page is displayed for the first time. You may do that in parallel but not in the same thread that launches the page.
If I pass a website into the browser constructor like:
ChromiumWebBrowser MyBrowser = new ChromiumWebBrowser("www.google.com");
Google will load. However, after initializing the browser, calling
MyBrowser.Load("Example.com");
Gives a blank screen. I have events tied to FrameLoadEnd, which fire when google finishes loading, but don't fire at all after the call to Load, which means that the webpages are not even being loaded offscreen.
I've spent a long time working on the issue but I can't find a solution. I've downloaded the packages through NuGet, installed VC 2012 Redistributable, initialized CefSettings, switched to x86, etc. I'm not sure what I'm doing wrong other than possibly misunderstanding the way this method is meant to be used. It's also possible that I'm not copying the right files to my output directory, but I do have CopyLocal = True on all of my references.
It might be important to note that my browsers are implemented programatticaly, as opposed to being dragged and dropped into the WinForms Designer. This is pretty necessary for my code, as I have a large number of browsers sort of crawling the web and showing pages to the user, hence the need for a reliable load method.
Here is a sample of my debug.log from my release folder, edited to remove too many duplicates:
[0826/130205:WARNING:resource_bundle.cc(304)] locale_file_path.empty()
...
[0826/131439:WARNING:resource_bundle.cc(304)] locale_file_path.empty()
[0826/134434:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/135650:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/135658:ERROR:ipc_channel_win.cc(136)] pipe error: 109
[0826/135921:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/135921:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/135933:ERROR:ipc_channel_win.cc(378)] pipe error: 109
[0826/135933:ERROR:ipc_channel_win.cc(412)] pipe error: 232
[0826/140141:ERROR:renderer_main.cc(212)] Running without renderer sandbox
...
[0826/140141:ERROR:renderer_main.cc(212)] Running without renderer sandbox
[0826/140148:ERROR:ipc_channel_win.cc(412)] pipe error: 232
Unfortunately Load fails silently if the browser isn't initialized. The next version is a major rewrite, which will throw an exception, so you'll know immediately what's going on. If you hook the IsBrowserInitializedChanged event you should be able to safely call Load after it fires.
https://github.com/cefsharp/CefSharp/blob/cefsharp/41/CefSharp.WinForms/ChromiumWebBrowser.cs#L233
The current version as at writing is 41.0.1.
Next version will be 43.0.0 (There is already a -pre release on nuget.org, though it's not quite ready for prime time yet)
I'm now working on some pretty big application with really nasty code. The problem is that from time to time the whole GUI of the app is freezing and stops responding (and after some time Windows wants to take the app down). I have a really big problem to even look where to debug the app, mostly because when this thing happens and I pause it in the VS debugger, it highlight the line:
CardWindow.ShowDialog();
It's not helpfull at all. Also when this thing happens it tends to grow the app size in the memory, ocasionally throwing OutOfMemoryException.
I also checked whether it might be some kind of an infinite loop in one of created threads, but VS shows me that only the main thread is active, and the rest are either ended or not running at all (the thread implememtation is also really poorly written).
The application uses remote objects within local networks, and some threads are used to transfer photos and other data from clients to server, but I don't know how to check if this is what it's causing it. But when the server app hangs, the clients are still fully capable to connect with it.
Short info of how it's made: the app uses Firebird engine to store its data. The DB is on the server machine, and the clients are connected via local LAN to it using standard Firebird C# library, and the app instances communicates with each other using remote object (the server is also a client).
It's the second week of debugging and I'm getting pretty desperate as I'm getting out of ideas of even how to check what's wrong. The fact that the bug appears randomly also doesn't help.
Can anyone give me some ideas of how to find a trace of this bug?
Using C# .NET 4.5 and WPF with Visual Studio Ultimate 2013 and Firebird 2.5
I'd suggest using a profiling tool to assist in finding the problem
What Are Some Good .NET Profilers?
In addition to #DerekTomes. The System.Windows.ShowDialog method, Described in: Window.ShowDialog Method, all other windows are disabled and return only when the window is closed. Check to make sure the window is eventually closed(this.Close() in the CardWindow.xaml.cs or whatever .cs file) or use CardWindow.Show() instead of CardWindow.ShowDialog() so other windows remain running while the CardWindow is running.
I finally figured it out.
When the function that usually hanged the app after 30th run launched, I could see that some of it ran (the window's title changed as it was supposed to). I've found this function and after every single line put:
this.Title = "1";
SomeFunction();
this.Title = "2";
AnotherFunction();
this.Title = "3";
// and so on
I localized what was causing the problem; there was a function that changed the GUI significantly (lots of foo.Visibility and foo.Opacity) and ran in some weird loop. It was fine for the first 20 times to run it, but after 30th it slowed down the app, and after 40th - caused crash.
It now runs only once when it needs to and the problem does not appear. I suppose it caused GUI memory overflow of some kind.
Anyway, thank you for your answers - I ran memory profiling, but it slowed my app down to that point it was impossible to use it.
We are currently trying to incorporate Lync communication (Lync SDK 2010) into our application and we have run into an issue with the VideoWindows (CaptureVideoWindow, RenderVideoWindow) of the AVModality's VideoChannel: They are always null, even after successfully calling BeginStart. The connection is definitely established. We can talk. Our own video is shown in a remote Lync client. AVModalityState is Connected. VideoChannelState goes from Connecting to Receive to Send.
It does not matter when and how we try to access them: Directly after BeginStart, in the AsyncCallback of BeginStart, in response to various state changes or in response to an external trigger (user click event); in the main/UI thread or in an event/callback thread. The two video windows are always null.
In the example application "%PROGRAMFILES%\Microsoft Lync\SDK\Samples\AudioVideoConversation", everything works as intended: As soon as BeginStart has finished, we can access the non-null video windows. In our little stand-alone prototype project, it works, too. But in our real application, it does not.
We have double checked everything and we have really run out of ideas of what might cause this problem.
Any ideas, any hints? Anything that we should be aware of?
(Link to corresponding MSDN forum thread)
Update (4th July 2012, 15:46 CET):
When we take a look at the members of the VideoChannel we find that internally a COMException occured in "Microsoft.Office.Uc": Error loading DLL, HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY). More details in the attached screenshot.
We did some research on this error, but found nothing that worked for us. Any ideas what causes the Exception?
Update (9th July 2012, 16:43 CET):
We did some further testing...
Our software consists of one main application and many plugin-like "apps" loaded via MEF. We created a minimal test app that makes a video call: The video windows did not work (as expected). But when we took the identical code and created a separate solution outside of our architecture, then it did work. So, it was an issue with the environment, not the code.
At first, we suspected MEF might be the problem. So, we hacked the lync code into our main application - circumventing the whole app architecture. Still not working.
Then we sliced off our whole system, bit by bit, until we finally reached a point where it did work. After following wrong tracks several times, we finally found the culprit... Quartz.NET!
For some strange reason the mere presence of an assembly reference to the Quartz.dll v.1.0.3.3, even without a single line of Quartz code, causes the video windows to not work. Unbelievable, but it's 100% reproducible: If we take the previously mentioned test solution and do nothing but add the reference, it stops working.
Any idea how such a thing is possible?
We solved it! Kind of. A reference to a Quartz.NET DLL somehow caused the issue. More details in the updated question.
For now, we have removed the component that used Quartz. We currently do not need it.
But I'm still interested in further input how a mere reference can cause such an issue.
I've been writing an app using the awesome new Razor view engine and for the most part, things have been great.
One issue I keep running into, however, is that if I should happen to write invalid code, such as referencing a null property or even a non existent property, rather than throwing an error, something happens in the background that causes the browser to wait and wait and wait and if I do not cancel the browser's request quick enough, IIS will simply hang.
It seems as if it enters some sort of loop. CPU usage goes up (though not terribly high) and restarting IIS via either GUI or iisreset command seems to take abnormally long (presumably while it waits for the process to safely shutdown).
This also happens for other invalid code scenarios such as failing to close a code block with a closing brace.
I notice this behavior on more than one machine.
Any ideas if this is a known issue or have I mis configured something?
Thanks!
I found the problem. I had installed a package via NuGet called "Razor Debugger" and apparently this plugin was intercepting Razor errors somehow, and was consequently not showing them.
Removing that package now allows Razor to work properly. What a relief.
Steer clear of this library.