|
public static bool IsWindows
{
get
{
try
{
if (System.Web.HttpContext.Current == null)
{
return true;
}
}
catch
{
}
return false;
}
} // end IsWindows
Thanks it works better then anything else I tried; may not need to put it in a try; it seem to just be null in Windows; but I'm not sure about Mono so it's better than getting an error; but I still think there should be a function to do this; it seems like this is as basic as a function need to see what OS your running like IsMono.
|
|
|
|
|
Jeffrey Scott Flesher wrote: Is there a way to tell if the Code is running as a Windows App or Web?
Perhaps, but to give a good answer to that one should really need to know a bit more about why you are asking the question. If the code doesn't already know that, why would it care?
---
Year happy = new Year(2007);
|
|
|
|
|
I just posted answer seconds after you posted this (please read); in short in have a library of code (non-controls) that has logic that I use in both windows and web apps; the problem is that if I need to notify the user; or gather information; I need to know if I'm running in a Windows app or web app; pre-compilers (#if) are not a good solution since the main solution contains both Windows and Web app and I deploy them at the same time. It sounds odd that code should know what environment it is running; apps generally written for the web or windows; but when you have common libraries then the need is great and it seems that there should be a function to return that information without having to poke around with a hack like looking for folder names like "Program Files" or something even stupider; I have looked for this answer to no avail and my next step is to ask MS; which for a guy is like asking for directions when I'm lost; I have a map; just no clue as to what state I'm in.
|
|
|
|
|
I see. You need the library to know how to do things, as it's doing things that it shouldn't.
It's not the library that should do the interaction with the user. Create events in the library for actions that need user interaction, so that the code that is using the library can implement event handlers that take care of the interaction.
---
Year happy = new Year(2007);
|
|
|
|
|
This should return the host executable's location:
System.Reflection.Assembly.GetExecutingAssembly().Location;
-- modified at 9:36 Monday 22nd January, 2007
|
|
|
|
|
Hi Everyone,
I am writing a stand alone application in C# which uses some database( I have not yet decided which database to use)
Application will be installed on user's machine and each application will have it's own DB.
now, I want to protect the database, so that no one can view the database using any tool, like enterprise manager or query analyzer, etc.
please help in finding solution for this, as I am very confused and have got no ideas how will it work.
in VB6, we used access database, but access is not an option here.
either SQL or SQL Express.
Regards,
Prady
|
|
|
|
|
ahujap wrote: but access is not an option here.
Because of the specific project ? You can use Access in C#.
SQL Server is more secure, you just need to set the password on the SS instance, and keep it in your program.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
HI Christian,
thnx for the super quick reply.
what do u mean by SS Instance?
can u please provide some URL where I can get more information about this.
I am more interested in using SQL Express than MS Access.
my only fear is ppl being able to view the complete database if they install Enterprise manager on their machine.
Regards,
Prady
|
|
|
|
|
ahujap wrote: what do u mean by SS Instance?
I just mean SQL Server. You can have more than one instance of SQL Server installed on one machine, there's the default and then you can have named instances.
ahujap wrote: I am more interested in using SQL Express than MS Access.
That's a wise decision, so long as you're ready for the extra headaches of deploying SQL Server.
ahujap wrote: my only fear is ppl being able to view the complete database if they install Enterprise manager on their machine.
They are no more likely to do that, than they are to install Access ( which more people have ) and open your MDB.
The main questions are:
1 - is this a rational fear ( i.e. are you hiding stuff you don't want people to see ? )
2 - how desirable is this data ( that is, to what lengths would people go to get it ? )
You log on to SQL Server. If you make sure the sa password is not blank, and make sure that the user doesn't know the SQL Server password ( which means you'll need to install a named instance, otherwise, you want to change the SA password on an instance they may have ), then make sure that information is hidden in your code. But, if your code is C#, then it can be found through reflection, so, again, the question is, how secure does it need to be ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: That's a wise decision, so long as you're ready for the extra headaches of deploying SQL Server.
I think instalation of SQL Express can be bundled with application installer using VS2005, am I wrong?
Christian Graus wrote: 1 - is this a rational fear ( i.e. are you hiding stuff you don't want people to see ? )
Yes, application is about ppl attempting some coureware and then the results will be uploaded to server once they have internet connection on the machine.
So we dont want ppl to go to database and change results.
what do u suggest?
|
|
|
|
|
ahujap wrote: I think instalation of SQL Express can be bundled with application installer using VS2005, am I wrong?
I believe that ClickOnce may do that, does it also script the creation of your DB for you ?
ahujap wrote: Yes, application is about ppl attempting some coureware and then the results will be uploaded to server once they have internet connection on the machine.
So we dont want ppl to go to database and change results.
OK, so the database is on the server ? Or this is a client side app with a client side database ?
I'd write this as a web app, personally. Then, the database is hidden from them, and your server security will protect the database.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: OK, so the database is on the server ?
nopes, database is on the client machine.
actually, one MAIN database is on server.
but this aplpication will use local database whenever user is not online.
and as soon as user gets online, data from local database will be sent to MAIN database on server.
Regards,
Prady
|
|
|
|
|
any pointers??
any help will be highly appreciated.
thnx
|
|
|
|
|
IF you have a local database, you're screwed. People will have reason to break into it, your code will be C#, so it will be visible through reflection, I don't see how you can get away with it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
ohhh...
so, do u think password protected ms access database is my best bet?
|
|
|
|
|
No, I think a web app is your best bet. Password protected Access may well be second best. Or, if you could have just a central server, and store answers in an encrypted file, so they can't see what to change to change the result.
But, so long as it's C#, they can read your code.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I need to have this stand alone app.
'cos the requirement of the project is to allow users to be abel to take tests when they are not online.
any suggestions?
|
|
|
|
|
I thought I'd made them. Put your database on the server, store your answers locally in an encrypted file, so if they alter the file, the server won't accept it. Send the answers to a web service when the app can find a connection. Accept that people who reverse engineer your code and create new encrypted files probably deserve to get good marks anyhow.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
agreed.
but the problem is,
there are too many fields and too many things to take care of.
so using flat files will be a big head ache.
thats why we need database.
we have thaught about using files but concluded that we will need to use database.
whats ur view?
|
|
|
|
|
I think I've stated my views often enough. Anyone can read your code, a password is easily broken. In fact, almost anything you do, will be broken reasonably easily, but just a password, that will be trivial.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
can i develop an application in -for example- VS2005 and run it over Linux, well i know about the mono-develop project!! but it's different from my requirement, am talking about full portability like in Java??
thanks in advance
Never stop learning!!
|
|
|
|
|
No, Mono is your only option.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
well i have a related second question -maybe it's stupid one-, i understand that Sun made JVM -Java Virtual Machine- to support portability for all O/S, but what i don't understand why Microsoft used also a Virtual Machine while their .NET applications are going to run only over Windows
|
|
|
|
|
I have no idea, I suspect it has to do with MS regardig the other 3% of the market to not be their problem. MS have said people are free to develop versions for other OSs, but Mono is the only one that's come to light, so far.
Perhaps it also has to do with multi platform being why every Java GUI app is a nightmare. Perhaps MS just didn't want to go there. What .NET does is multi language to a common framework, not a common framework for many platforms ( although it CAN do that, too, if anyone wants to do it )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Well, he can code in VS2005 and just compile it with Mono - that's what I do. In many respects, Assemblies produced by MS's compiler are compatible with Mono too (you're asking for trouble if you execute them, missing dependencies, etc, etc, but you can probe them easily).
|
|
|
|