1

I have written a very simple Windows form application (my first) in C# using Visual Studio. The application simply shows a dialog with information about the local machine (Local IPs, user name, PC name, domain, among others) and that's it. It finishes when the users clicks the 'OK' button.

I'd like to deploy the application as an executable that runs directly on double click. I have extracted the executable generated by Visual Studio in the project folder and I've succesfully run it in a number of different computers. However, on some computers with XP I get an error message saying that it is not a valid WIN32 application.

I'm pressuming the problem is the .NET framework not being present or an older version than the targeted version is installed.

My question is, is it possible to ensure that the application runs on (at least) Windows XP but still have it as a simple executable that runs on double click?

Thanks in advance.

Adrian Flores
  • 325
  • 4
  • 10

1 Answers1

0

You could try one of the following approaches:

  • Use an installer (e.g. Inno Setup) to deploy your application and install the .NET framework if required (Sample for .NET 4.5 and Inno Setup)
  • Just check if the required .NET framework version is installed during the setup and notify the user if it isn't (Sample with Inno Setup)
  • Compile with .NET Native (I didn't use it yet, therefore I don't know much about it, but maybe this Intro may help you)
  • Use C++ and WMI instead

EDIT1: .NET Native requires Windows 10, crossed it out from above

EDIT2: Added C++ with WMI as an alternative approach

wobuntu
  • 422
  • 5
  • 12
  • Thank you, @wobuntu. This little application is supposed to be dropped on customer's (of my borther's company) computers so that when support is needed, the information showed in the dialog can be easily provided. Forcing the user to go through an installation just to show a dialog seems too much. I had made a VBScript before that runs fine everywhere, but I'm very limited in what I can do to the dialog (no custom image, for example). Is it possible to check for the required .NET at runtime and have the app launch the VBScript instead of its own dialog if the framework is not detected? – Adrian Flores Jul 27 '17 at 20:03
  • If you want a simple standalone application which runs even on XP, I'd recommend you to use C++ in combination with WMI instead. There's a great intro into WMI here: http://win32easy.blogspot.co.at/2011/03/wmi-in-c-query-everyting-from-your-os.html?m=1 Compared to other solutions, it might be the easiest one for your problem and is quite simple to use. In addition, you'll find a lot of How-Tos here on Stack Overflow too. – wobuntu Aug 05 '17 at 09:06