Emailing without letting the user know - c#

I have a program in C# for Windows Phone. It does some really CPU-heavy stuff with IsolatedStorage and cameras and images.
Occasionally, my app crashes. It happens about 1 in 50 times, and each time it does, I end up making some minor modification to the code. I mostly always prevent the app from exiting with try-catch.
But after ~3 months of working on the app, I think it's ready to be released to the public. However, I still want to be notified about crashes so I know how to fix them.
How could I send an email to myself without forcing the user to press Send?
As far as I can tell, users don't really want to report the errors, and as such are likely to press Cancel if they see such a dialog.
EDIT: This crash would only contain the words "Crash at line " and the line number(s) that caused the crash.
EDIT II: Oops, meant a crash every 500-1000 times. Thanks #Andrei.
EDIT III: Using all my data, it seems that this app has only crashed five times out of the 18000+ times I've debugged it. That gives my app a one-in-36000 chance of crashing if the user uses my app for 3 months on an average usage estimate of 20 launches per day, which, in my extremely biased opinion, quite good for an app that makes heavy use of sounds, images, and sensors.

Transmitting info without the user's knowledge is evil. Use reverse psychology:

Fixing crashes by using try-catch is not really fixing them. Treat the cause, not the symptom.
Sending emails without the user's consent in wrong and, since it may contain personal information, might be also illegal. Since it also might cost the user to send data it also makes it commercially less viable as it increases cost for the user without bringing him real benefits.
Sending the crash report to a website instead of an email address looks more professional.
If you don't want the user to have to click to send each crash report you might try to ask the user when he installs the application whether he wants to submit the crash info.
A google search for "silverlight upload file" provided this link. May it help you well.

Can you just upload the crash info with a POST request to a website? It's probably easier to do that and then let the website send an email than it is to send (random) emails in the user's name...

Unless Silverlight for WP7 supports the SmtpClient, there won't be a way to send mail outside of the email app.
There are a few work arounds however:
Create a web service to capture the data, that your wp7 can attempt to make a request to,
Just use the Email function and hope users hit send (you'd be surprised)
Use a service like Flurry that has OnError event logging, and put that in your unhandled exception handler.
Use an email web service proxy to send the email to you.

Well, there is the WPAppManifest.xml in this file you can specify what the user needs to accept.
Here is the EMail thing: http://www.ginktage.com/2011/04/how-to-send-email-in-windows-phone-7-using-c/
I think this would solve your problem.
This is i think the right thing for you: http://www.preemptive.com/products/runtime-intelligence/compare-editions
For WP7 Developer its free.
You can track the application usage from the users. You'll see how many people how long your application are using, and i think also if it crashs...

As others have said, you luckily can't send emails as the user without him knowing - but you can just use a web service.
To improve this, I create the MD5 hash of the stacktrace and first check if the crash happened before and only if it hasn't happened before, I send the crash report.
But I stopped asking the users as well. They just won't do it then. I simply remove all personal data first.

Related

A service that would track and catch whenever someone is trying to take a screenshot

Is it possible to write a service program that would catch an event of someone trying to take a screen capture? Not that of pressing a printscreen button or any other key combination, though, but of the event itself, even if it is done by some external tool?
You can't realistically, because anyone could write a simple application that can take a screenshot.
The command being, GetDC(NULL) (msdn GetDC).
Hooking this function also wouldn't work since apps can make use of this for legitimate reasons so you'd have to try and filter out false positives.
Also, you've only prevented one class of problem, what if the user emails the file to someone? What if the user copies the text rather than uses a screen shot? What if the user takes a photo using their mobile phone?
If you have sensitive information that must be protected the only real option is to educate users and/or restrict their access. E.g. machines with sensitive information are not connected to a public network, USB drives are disabled and user's are not allowed to bring anything with a camera or data storage near the machines.
If it's just to avoid silly mistakes, then you could hook the keyboard and look for the print screen key. This however will not detect applications (such as Snipping Tool).
This could be done via a clentscript and using AJAX to send a message back to your servers, however you cannot guarantee the user wont have javascript turned off, or the user gets around this by running through a proxy or vm environment.
In short you could do this but there is no way to 100% guarantee its effectiveness.

Why does my new .Net 4.0 EF application randomly lock up?

I have recently rolled out a new ASP .Net application. This application uses .Net 4.0 and the Entity Framework 4. It is a "basic" CRUD application. I almost exclusively used the EntityDataSource for Data Access.
The users have reported "ocassional freezing" of the application (they all use IE 8). If the user closes his browser and starts back up, the app is fine. It happens maybe once or twice per day total, usually to the heavy users. (So, I have been leaning toward memory leack or some other kind of resource limitation.)
Until just a little while ago, I have never seen this happen. It dosn't leave anything in the Event Log on the client PC nor Server. Also, there is nothing in the IIS error logs or the SQL logs.
A little while ago, I finally got it to happen. I was switching all of my EntityDataSources to use a single Object Context per page. I downloaded the EF Profiler (which seems to be a great product) and it pointed out that I am using multiple object contexts on many of my pages, due to the fact that many of them have more than one EntityDataSource. So, I was cleaning all this up and testing each page, when lo and behold....IE stopped loading pages!
At first, the page started loading slowly (and this was a page that I had already modified to use a single Object Context, so although I still believe I need to implement this "singleton" pattern throughout all my pages, I guess it isn't the culprit! Anyway..), then at some point I received:
Message: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.
Still, nothing in the Event Log. I also checked the IIS web logs and I don't see anything, but they are pretty tough to read with the naked eye, I may have to download a parser to make sure there is nothing in there.
Anyway, I decided to start up another window and navigate to my app, and sure enough that window worked fine, no problems. I went back to the windows that stopped responding, refreshed it, waited... went to the home page of my app (which is basically just some static html.. and nothing.. ). Next, I opened a new tab in the window that is currently frozen and that tab works fine. So, I go back to the window that can no longer load pages from my app and try some other web sites.... espn.com loads fine, msn.com loads fine, I then enter the URL for my app home page (and tried some other pages in my app) and NOTHING. IIS doesn't even log the attempts in its Log Files (its like IE has just decided not to do anymore "gets" for my localhost!). Finally, after waiting for a while (while I was typing this post) I now have this error message in that window:
Internet Explorer cannot display the webpage. What you can try: The problem can be caused by a variety of issues, including: BLAH BLAH BLAH...
So, I jump back to that window and it can still browse Internet sites just fine. But, once again when I try to go to any of the pages in my app, I get NOTHING (spinning blue circle in the tab). So, once again I start a new tab in that same browser and I can browse around my application just fine.
What has my app done to this browser instance that will no longer let it load any of its pages (in fact, it seems like it isn't even doing a GET on any of the apps pages, since there is nothing new in the IIS logs...except for when I load the pages in these other tabs and/or browser windows that work fine, so the logging is still working...)? I will be forever indebted to the person that can help me figure this out. I am not sure it will do much good, but I am going to leave this browser window up on the chance that someone can tell me some things to try to diagnose this problem. It feel like I am THIS close to figuring it out. I finally have a window up that is misbehaving. I am afraid to close the window or do a new build on the app until I get some good input on things to try....
I should add that when this happened to me, I was running on my local PC, so I was the only user and only had one window open to the app..
Although, I am completely stumped!
We had the same issue and seemed to fix it by adding the following JavaScript to all pages with ajax:
window.onunload = abortRequest;
function abortRequest() {
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}
I hope this helps!
sounds like a request just takes too long to execute. A web-browser is only allowed to keep two concurrent connections to a single webserver unless you utilize http pipelining (which isn't well supported anyway). However, My experience is that this is per browser, not per tab.
This is why nothing shows up in your logs, because your browser never initiate a request because it is waiting for the page to finish loading before it can fetch another page. I would start looking into the last request initiated before the lockup, it is probably that page that locks for some reason and never finishes.
ASP.NET utilizes only one thread as long as all request are sequential. As soon as you fire up two request simultaneously, a new thread is initiated (Init() on HttpApplication is invoked), and that can cause intermittent errors if you do funky stuff on Init().
If you think this is related to EF, you might read up on how to avoid locking in multi-threaded environment (because a web application is very much multi-threaded however this usually kicks in a production environment).
Ugh, I feel your pain - I hate these types of issues. Here's my divide-n-conquer process when something like this is happening (adapted somewhat to your case):
Step 1 - Environment Visibility
Get yourself set up so you can roughly see inside your systems. Set up Performance Monitor, and add a couple of important counters (IIS Current Requests, ASP.NET Current Requests, SQL Server - Active Transactions). The idea here with the "active requests/transactions" counters is you want to find out which part of the system is holding on to the request.
Additionally, add counters for total request time in IIS and the DB (so you can see it climbing as something is hanging on).
On your client PC, set up Fiddler.
Step 2 - Reproduce Issue
Usually at this point, the application realizes you can see it and starts behaving perfectly. ;) Stop and make sure you can still reproduce the issue.
Step 3 - Take the DB out of the equation
Create 4 pages in your application:
Static HTML file (.htm) that will NOT go through the ASP.NET runtime engine. This is your baseline for raw IIS.
ASPX page with no tricks (no database access, no processing, just a simple page that ASP.NET can spit out)
ASPX page with one simple database call (of some size, maybe do a single big query or something)
ASPX page with some complex transactions (multiple queries, etc)
Step 4 - Reproduce and measure
Since this issue will probably be pretty obvious once you can see it, find the bottleneck with your performance counters and Fiddler. Your issue sounds like you could have an intermittent connectivity issue (either between client and web server or web server/SQL), especially if IE is giving you the "page cannot be displayed" error, but you should see that in Fiddler. On the server side, you should see one of those performance counters hanging.
well, sounds like the app is waiting for a database operation to complete but is locked, probably because of another operation.
Try using the SQL profiler to trace the activity, and isolate what processes are running for a long time.
You can differentiate the requests using the SPID column in the trace view, it contains a unique ID number for each session from your App.
I have new information regarding this issue.
The application uses Integrated Authentication. This causes every reqest to come back (twice) with access denied, before IE send the credentials.
I can't help but wonder if this is what could be causing the "time outs".
I implemented an Ajax "Loading" animation on every page that prevents the user from clicking a button until the previous request is completed and that has GREATLY diminished the amount of "freezes" the users are experiencing.
Although, it still happens somewhat often.

control a browser on another computer

hmmm,
typing the title made me feel like i am a hacker asking for some illegal stuf....
but the truth is different i think. My client wants to control 3 webapplications at different computers at the same time.
I can't say exactly what the porpose of this is, but he wants, when he clicks on computer A at button 1 in the browser, that on computer B in the browser also is clicked on button 1, and also on computer C.
When i devided this process in 3 steps, i realized that none of them are things i've done before:
first thing is to get the click event out of the browser
second is to inform computer number B and C of the click event
third is to click a button in the browser of computer B and C
Three things i don't know how to accomplish (i have done some remoting in the past, maybe that can work for the communication between the three computers, but all i remember is that remoting did NOT become my friend)
So if you can give me any clue on how to catch browser events outside the browser, talk between two pc's and raise events in the browser from outside the browser, your help would be greatly appreciated.
EDIT:
i don't control the application. My client will use it to send multiple stock orders. so i think you can compare it with up-vote on a voting website
I know this is not an answer directly to your question, but it is a valid answer from a business and developer standpoint.
Unless your client is willing to pay through the nose for development time, it would be better to find out WHY the client wants this and offer possible alternatives. What they're asking can't be done without a LOT of work. I'm not sure where I'd even start - probably writing my own browser using the BrowserControl in a WinForms app, and using Remoting to control the WinForms app.
Really, you're better off researching the requirement better and proposing an alternative that is doable. Part of being a good devloper/analyst/project manager, etc is to be able to correctly divine what the customer actually needs from what the customer SAYS they want.
It could be that they just need you to track the status of something and your separate browsers need to auto-refresh. Or it could be that WinForms is not the right tool for the job. Or it could be something completely different. Heck, it could be as simple as only having one browser, and people can "watch" that browser from another PC using VNC or a similar tool.
There are usually multiple ways to meet a business need without focusing on difficult technical requirements. It's the business need that matters. and if you can find another way to meet it, you won't need to spin your wheels on this type of question.
As an added note, it makes me cringe to hear that you're even looking for "how to do this" without understanding why. Getting the requirements right is SO important in development. Most projects fail because the communication of requirements was not adequate.
What you want to do looks like 'shared browsing' or 'follow-me browsing'.
There are some questions that need to be asked :
do you want to do this with or without installing some sort of browser plugin or application ?
is the 'shared browsing' done only on a web application that you develop or do you need to browse to remote websites where you cannot add code.
If the web application can be modified, you could have all clients:
Send all actions they do a server ( #id1, click )
Poll the server for a list of actions that need to be triggered ( jQuery('#id1').click() )
If only one of the client is "master" and all the others are slave, it should be easy enough to synchronise everyone.
In a multi-master setup, synchronisation will be a little more complicated, and then maybe you will be re-developing Google Wave ;-)
Now if you need to be able to do shared browing over any website, thats a lot more complicated. Even more complicated if your solution needs to work cross-browser. You will need to develop extensions for each supported browser or native applications for all supported OSes. I advise you to look for existing solutions that already do have the shared browsing feature. You can also take a look at the VNC family of solutions (full desktop control).
I hope this will help you,
Jerome Wagner

"Click" button of a program from an application I'm building

Boring background:
I have been working with UltraVNC to control some PC's at work and it does the job great but in order to simplify things I created a program that interfaces with it in C#. Basically I take advantage of the commands the viewer offers to connect, control, watch or transmit to each PC.
Problem is anyone can access the PC's since it has one main account (no domain controller). I need everyone to sign for the PC before they can use it, so to make my job easier I open each PC and block the inputs + blank the screen that way there obligated to sign before use.
Opening each pc and press the block button can be hassle especial when you’re helping someone and a user leaves, others come (btw I work at an electronic library). UltraVNC doesn’t have a command for this; it’s been requested but I don’t think it’s much of a priority for them and the code seems very intimidating for a novice like me so I thought I could try a hack to get what I want.
Problem: I want to “click” a button in a program I use, from an application that I am building in c#. I can currently use the process class to get the handle and identify the specific window I want to use but I have no way to find the button handle which I read is what I need. I found stuff about using findwindow and sendkeys for this but I don’t see how that’ll work unless the button had a keystroke assigned to it which it doesn’t.
So can anyone point me in the right direction?
Why not use something like Eficium Cybercafe SurfShop to achieve what you want? After teh user finished you log the session out, and before someone can log in, they have to sign in.

Receive a message FROM another process

I've been teaching myself how to use messages with Window's APIs, and have actually been doing very well learning them. Problem is, I can't figure out how to receive a message from another application to start code within mine.
Essentially, what I want to do is allow others using a commercial application to click the save button (on the commercial application), and have my application stop the save message, prompt the user, and from that either cancel the save to allow them to continue, or allow the save (which I know how to do now through messages).
I just need to know how to catch a message, and stop it. If anyone can point me to an API call, or function, or just documentation that may help, please do.
Check out Detours by Microsoft Research. It's possible, but not simple. Also, look into how client-side game cheats are performed. I will not link any of them here, but they are out there. That's essentially what you want to do.
I think you'll need to attach your own application to the running process the same way a debugger would... Unless the commercial application has a custom method of plugging into their architecture to do this.
The next question is... do you want to proceed down this path.

Categories