Winform application doesn't run properly - c#

In my home and work pc's and in one friend of mine's it runs just ok, but when i sent it to someone else it 'loads' for 10 seconds responseless, then there is an error:
alt text http://dl.dropbox.com/u/3045472/Sem%20t%C3%ADtulo-1.png
Since it works on at least four computers, i assume the program itself is just ok (same exact EXE).
What could be happening ?
info:
C#
.net 3.5
worked on Windows 7 32/64 bits,
windows XP and vista.
does some threading simple stuff, but
it doesn't even open the form, and it
doesn't open up running either, so
the functionality is irrelevant.

There are infinitely many possible answers. So I will give you the way to figure it out instead.
Add a handler for the event: AppDomain.CurrentDomain.UnhandledException of type UnhandledExceptionEventHandler.
You will be able to see the reason for the crash. It's probably best to write it out to a file somewhere anyway.

The first check is to make sure the .NET framework is already installed on the target machine, then make use of Brian's suggestion (which will not even work if the framework is not installed!).

Related

Is there an alternative for the SendKeys class that will work with Windows 10

I cannot find any definitive information anywhere but the System.Windows.Forms.SendKeys class appears to have been blocked / disabled / depreciated in Windows 10.
I wrote a demo program that monitors the users keystrokes and if a user enters a known code it will pop up a form and then go off to a document database and return various strings (company names / addresses / contact lists etc) and replace the typed code with the retrieved string. SendWait is used to send the retrieved strings to whatever program typed the code.
I built the program on the companies Windows 7 desktops but when I ran it on my personal Windows 10 system it didn't work. A lot of reading later and I feel like a complete idiot but I cant let them take this project any further knowing that they wont be on Win7 forever.
So my question is has this sort of functionality definitely been disabled in Windows 10 or is there another way or method I would be able to use to achieve this behavior of inserting text into running programs.
Any help appreciated.
I found this Forum-Thread:
https://www.tenforums.com/software-apps/49635-sendkeys-not-working-windows-10-a.html
SendKeys is Blocked in W10. In W8.1 it still works.
There are other anoying things, like not allowing App to Read or Wright to Drive C. The "file" is there but W10 "hides" it or simply not allowing to access it.
There are Netwok problems also, not allowing App to work on LAN environement.
Well, my opinion is that W10 behaves like Malware to user PC. Useless.
They had no solution.
It looks as if Sendkeys works with some apps and not others. I can automate an older app by sending it keystrokes but newer apps like Chrome don't respond. The inconsistent behavior has seriously messed up scripts that worked fine under Win 7.
I have not found any official documentation that says that Sendkeys has been deprecated so the inconsistency looks to be a Windows 10 bug.

Use of WMPLib on Windows N editions

I have a problem and I don't know how to work around it: I used the WMPLib in my C# application (located in C:\Windows\System32\WMP.dll). I referenced it and dded it in the header of the main form's code file:
using WMPLib;
But if I try to run my app on a Windows N edition (I think also the KN edition counts here), it stops working and Windows shows the following message: "App-name has stopped working. You can check for a solution...". So now, I'm trying to find a way to work around this, for example, by not importing that DLL at run time when user is running a Windows N edition.
I'm afraid that I wouldn't have a way to redistribute my app to Windows N users.
Thanks for any advice,
Vali
The N editions do not come with Windows Media Player installed by default, which explains why the DLL is missing. Windows Media Player can, however, be installed after the fact.
This leaves you with two choices:
Dyamically load the DLL at runtime
Check for, and require that Windows Media Player is installed as a prerequisite (i.e., during setup)
You may actually want to do both. If your application requires this assembly to get its job done, on app startup, you probably want to check if the DLL is available. If it isn't, displaying a meaningful error message would be preferable to an outright crash.

c# application working on development machine, fails on non-development machine

this problem has me baffled.
I'm writing an application which is supposed to take information from a form, pass it to a background worker which then a) writes the information to a local xml file and b) inserts the information into a remote MySQL database.
On my development machine, it seems to work flawlessly. The remote database is updated, the xml file is created if necessary and updated if it already exists. It's working.
Even if I exit out of the development environment and run the release build independantly of the IDE sandbox, the code works.
But, if I put it on another machine, the code fails and I dont understand why.
I'm currently using Visual Studio 2010 Professional on a 32 bit Windows 7 Ultimate machine.
At the moment, I'm finding that the application is stopping at a fairly specific point, which seems to be precisely where the background worker starts doing things like accessing the file system or accessing the remote database.
The project consists of a single exe file and a dll, which has a custom control I designed in it. The custom control is working fine, in that it shows what I want it to and returns the values I'm asking it to when I want it to, so it would seem that isn't to blame.
I initially thought I could be looking at a permissions problem, but running the application as administrator gets me the same response.
I've been writing using version 4 of the .NET framework, however I've just downgraded that to version 3.5 in the hopes that that may help. Both the non-development machines I've tried have been up to date - or have been brought up to date by me - prior to attempting to run the application.
I'm honestly baffled here. Any suggestions would be most welcome.
Alan
If your code fails, it most likely means there is some uncaught exception. What you should do is to log all uncaught exceptions (and probably some of the caught too) to a file, possibly using something like log4net.
I don't think we can help you beyond that.
I have written a live logging utility called Donsole for diagnosing the application in such conditions. On the developer workstation, it is very easy to diagnose using the feature-rich debugger of VS. The utility app. helps the developers exactly in this kind of scenarios where they don't have any idea what's happening inside. I recommend you download the latest build and try it for yourself. Explaining how to use this utility and how it works is beyond the scope of this answer, so I'd forward you to the codeplex page of the project.
http://donsole.codeplex.com/
This is how it looks.
Take a look at the event viewer of your operating system. Administrative Tools>Event Viewer>Windows Log>Application.

Programmatically check whether Windows 7 is activated

Background:
I am creating system images that will be loaded onto several workstations. Windows activation will occur after the images are loaded onto the workstation. These computers will not be connected to the Internet and will be activated over the phone.
Question:
I would like to check programmatically if Windows 7 is activated or not, so that our software will not run if Windows 7 is not activated. Our software is written in C#.
The Software Licensing API - SLIAPI, take at look at SLIsGenuineLocal(). (Replaces LegitCheck)
You can run "Slmgr.vbs" on the machine and then redirect the output to check.
System.Diagnostics.Process.Start(#"cscript Slmgr.vbs > D:\\log.txt");
This will return all the information you need. Not the cleanest way to do it though.
You may check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Activation Technologies\AdminObject\Store\TotalValidations and see if it is 1. This may not be the definative way to verify activation, but you should at least be abel to see if it was validated.
You can use this reference: https://github.com/Marko97IT/CWA
In the README.md you can find the download link.
Not sure if it applies to Win7, but I found a post that checks XP for activation using a Win32_WindowsProductActivation class.
I'll build a test one on my machine (x64 Win7) and see if it returns activated or not, but at least gives you something to try out in the mean time.
EDIT (wish I kept reading the docs) A comment on that class page mentions that this class, on Win 7 and other versions) appears to be replaced with the Software Licensing Classes. I'll see if I can get a working result.

ClickOnce & XNA issues

I essentially have a blank XNA project built using the XNA 3.1 wizard, i'm testing whether a game i make can be "installed" on another computer without having to make them install everything manually to make it work.
The only additional code in the game is:
Components.Add(new GamerServicesComponent(this));
After going through the ClickOnce publishing stage i copied it to a USB drive and attempted to run the "setup.exe" on a Windows Vista computer with no Visual C#/Studio or XNA installed.
According to the MSDN entry the ClickOnce will actually include everything necessary to make the game work on the computer, yet after the installation i get the dreaded "... has stopped working" when i try to run it.
Does anyone know how to get around this? I assumed the reason it says it can be done is because it works.
Thanks
http://msdn.microsoft.com/en-us/library/bb464156.aspx
Edit:
Just noticed that the article states that the Games for Windows - LIVE is not included in the distributable, would this mean if it was included as a component in the XNA game it would cause the crash when i attempt to run it?
When an application says "has stopped working" for no immediately apparent reason, that's usually a sign that an unhandled exception has occured. Since MSDN states that the GamerServicesComponent class is not available without the XNA Game Studio installed, that seems like the most plausible explanation.
Why is it available, then? Well, you need something to program up against; you wouldn't be able to use auto-completion and such if you didn't have the class, because VS wouldn't know what it looked like
Getting it to compile for, say, XBox 360, where I would guess that the class CAN be used, probably wouldn't work either if it didn't know anything about the class.
To address the general problem of a ClickOnce application which "has stopped working" immediately, you can get more information on your particular problem by looking in the Windows Event Viewer:
http://windows.microsoft.com/en-US/windows-vista/Open-Event-Viewer
Like Michael mentioned, this is often an unhandled exception, but this way you can see WHAT the unhandled exception was.

Categories