Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello Code Project,
i want to make one little thing that can make my program(Game Auto Updater & launcher) bit more better.
my program is coded on .Net Framework 3.5, and simply if i have .Net Framework 3.5 installed than i can use my program without any bug, but if i don't have framework 3.5 installed then my program will run but it will not work correctly as it should. so i just want to make a little thing that if its possible to make like, If .net framework 3.5 is installed then client can run perfectly if not then client will not start.
can anyone help me with this?
Thanks in Advance
This is program Link
Program(Launcher)
Posted
Updated 23-Aug-14 21:33pm
v6
Comments
[no name] 22-Aug-14 16:05pm    
Why do you need to do anything? If 3.5 or newer is not installed, your program won't run anyway. You need to do this check before your program is installed not afterwards.
Sergey Alexandrovich Kryukov 22-Aug-14 16:51pm    
Not exactly, I would say: it's perfectly ok if some application is used without installing; it and should even be preferred. Even Microsoft started to encourage this way. But, as you say, the application simply fails to run. More exactly, it will fail to load load. I provided a more detailed answer; please see.
—SA
[no name] 22-Aug-14 17:00pm    
That would be true if that was what he was asking.
Sergey Alexandrovich Kryukov 22-Aug-14 17:23pm    
Well, your own saying is based on understanding that what he is asking does not really make sense. So, this is just a reasonable practical advise: to ignore the "problem".
—SA
[no name] 22-Aug-14 18:43pm    
That's right. That's what I said. It does not make any sense what he is asking and that is exactly what I said in my original comment. What you are going on about, I have no idea.

The best answer was the comment by Wes Aday. Please see my comment as well.

There is no a point to check it up. If you program target some .NET version, you won't be able to run this checking code; it won't even load. So, why trying to write such thing?

It's perfectly OK for some application to be used without installing; it and should even be preferred. Even Microsoft started to encourage this way. The installation is only needed if you change something in the system: registry, file associations, put something in some shared directories configured per user account or "all users". In all other cases, the application without installation is the best.

In required .NET version is not installed, the application simply fails to run. More exactly, it will fail to load load. The OS will show appropriate error message. There is nothing to worry about.
Only mention about the requirements about a .NET framework in your prerequisites.

—SA
 
Share this answer
 
Create the installer with the Visual Studio publish option in the Project Settings, Visual Studio creates a installer that checks the requirements for the application. You can set .NET 3.5 as a requirement. :)
 
Share this answer
 
Comments
UttamRabadiya 22-Aug-14 14:57pm    
Well i try this one too. but as i said above it is one game auto updater, So i can not make it as setup or installer. so i think it will not work for me :/
Philippe Mori 23-Aug-14 9:01am    
It is only the updater that require 3.5 or the game too. If it is the updater, then you should fix the bug that prevent it from running under 2.0 if you want to continue to support the game on that Framework (which does not make much sense in my opinion now that XP is obsolete).
UttamRabadiya 23-Aug-14 9:45am    
well i know XP is obsolete now but still half of world uses Windows Xp :X and its bad truth. but i just want to provide the error like when the net framework 2.0 is missing it will show error so same it should work for net framework 3.5 too :)
Use an installer program: it will ensure that the required version is installed and download / install it if it isn't.
 
Share this answer
 
Comments
UttamRabadiya 22-Aug-14 14:49pm    
well that is nice solution but this C# program is one game launcher, and i will put this launcher in update. So i guess i can not make process of installing inside this launcher.
I just want to print an error that will show to user that his net framework is missing.
The only thing I can think of is to try to load a type that will be present only if the required version is running the updater.

Something like:
C#
public static void DetectType(String name) {
  try {
    Type t = Type.GetType(name, true);
    Console.WriteLine("Found {0}", t);
  } catch (Exception ex) {
    Console.WriteLine("{0} {1}", ex.GetType(), ex.Message);
  }
}


From the what's new in Framework xx pages on MSDN we can select a type to test
C#
// v3.5 or higher
DetectType("System.DateTimeOffset");


If this is a daft idea I'm sure someone will post a comment!

Alan.
 
Share this answer
 
If you need 3.5 for your program to run but it does run with 2.0, then I think that something is wrong in what you are doing. You'll have to verify you compile/build options and your configuration file.

You might also want to read bout redirecting assemblies particulary if you can fix problem that prevent your application to run under different versions:

http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx[^]

The choice really depend first on what you are using in your code, which OS you target and if you want your user to use a specific version or allows any compatible versions.

But given that we have no idea on what is your problem with 2.0 and we have no information on why it load, we are not sure what you should try first.

By the way, which version of Visual Studio are you using? We also have no idea if your application was generated with default settings on that version or if you have upgraded Visual Studio or change .NET target version or modify other settings or prerequisites.

So without informations, we cannot help you much that what other have already did.

Why not just get the version from the Framework itself. A simple Google search and you can find it in seconds: http://msdn.microsoft.com/en-us/library/system.environment.version(v=vs.110).aspx[^]
 
Share this answer
 
v2
Hello Code project,
i solve it with changing a target of my program.
it was running in .net framework 2.0 because of "run time" version.
Runtime version for .Net framework 2.0 and .Net framework 3.5 is just a same.
So it let the program to run but i notice when i target to .Net Framework 4.0 its works fine and no more problems.
and thank you all for your suggestions :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900