|
So I'm close to wrapping up a project, and a bug came up that only occurred to me now because I just started testing on Vista.
My application has a class autostart which writes a key to, as you probably guessed, start my application on start as requested.
Here is my class
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;
namespace ClientName.Sources
{
class Autostart
{
public string errorMsg;
public string ErrorMsg
{
get { return errorMsg; }
set { errorMsg = value; }
}
public string value;
public string Value
{
get { return value; }
set { this.value = value; }
}
const string filename = "MyCSharpApplication";
RegistryKey start;
public void WriteAutoStart()
{
try
{
string RUN_LOCATION = @"SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN";
start = Registry.LocalMachine.CreateSubKey(RUN_LOCATION, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
bool ifExist = ifExists();
while (ifExist == false)
{
start.SetValue(filename, Application.ExecutablePath.ToString());
start.Close();
ifExist = true;
}
}
catch (Exception ee)
{
ErrorMsg = ee.Message;
}
}
public bool ifExists()
{
if (start.GetValue(filename) == null)
return false;
else return true;
}
}
}
And In my main forms on load I have AutoStart Start = new AutoStart();
start.WriteAutoStart()
This works fine on XP, it check's if it is there, if not it will write the key. On vista I get a nice little error that says Attempted to perform an unauthorized operation, even though the user double clicked my application icon.
Some research showed me right clicking on the application and clicking "run as administrator" will do the trick, but this is annoying to have a user do this each time.
So is there a way with code to bypass this? I suggested to just have a proper install file take care of this but the client doesn't want an install file. So that leaves me a bit in the dark.
Suggestions?
|
|
|
|
|
Vista sucks. It's not a bug, it's deliberate. The main answer is, you need to be testing stuff on Vista early, b/c Vista breaks a lot of stuff that used to work just fine.
It is possible to create a manifest file which causes your app to run as admin every time. I've not done it, but I remember reading about it when I had my own Vista hell.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Do you remember where you read that, anything on CP I might have missed?
|
|
|
|
|
well the quick solution was to use currentuser instead of localmachine, if you wanted to know
|
|
|
|
|
EliottA wrote: the quick solution was to use currentuser instead of localmachine
This is different behaviour to what you had before. Remember that this will only work for the currently logged in user. If someone else logs in it won't start the application until they manually start your application for the first time, thereby initiating your AutoStart code.
|
|
|
|
|
In previous versions of Windows you will also need to be an Administrator to do this. The only difference is that in Vista it will automatically run you in a lower privilage account even although you are logged in as an Administrator unless you explicitly run the application as Administrator. This is for good reason - too many people run as Admin and that can compromise your system. In Vista if an application tries anything that may compromise your system (like the code you are running) it will prevent it.
How other applications deal with it, and that includes Microsoft applications, is to restart the application as Administrator if it can. If it can't it will prompt the user to provide the appropriate credentials. Unfortunately, I can't remember the code to do this.
Remember, your application will still fail under XP if you are not logged in as Administrator too. Only admin level accounts have the rights to write to HKEY_LOCAL_MACHINE in the registry in Windows NT, 2000, XP, 2003, Vista and 2008. In Windows 95, 98 and ME anyone can write the HKEY_LOCAL_MACHINE.
|
|
|
|
|
I am new to C# and I need a lot of help. I've created an inventory database with four tables using MS Visual Studio. I need to create a user friendly GUI that can access this database. I want to do simple searches and display what is available. I am so lost I do not know where to start.
The tables are:
InvData (contains MediaType, MediaName, Description, IsAvailable)
Users (Name of users that borrow Media)
Status (When media was borrowed/returned)
DisabledMedia (When media was disabled and reason)
|
|
|
|
|
Buy a book and work through it. No-one can possibly tell you how to do this in a forum reply. But, the forum reply version is, create new forms, drag controls out onto it, and write code to hook them up to the DB.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I understand I cannot get step by step instructions on how to complete this task on a forum but I was hoping that someone can help me get started since I am new to this. Can you suggest a book atleast. Right now I have a Head First Book for C#. I was able to create the database and connect it to my form but I do not know where to go from there. Thanks.
|
|
|
|
|
Any book will do, you're talking about stuff that, any book that doesn't cover it, is kind of useless. It's a long time since I learned C#, any recommendation I would make, would not be current.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I have successfully connected my desktop application to a web service. My web reference is in http://localhost/ however when I tried it on my application for my phone, I cannot seem to connect to it. Do you know how I can connect to the web service? Is it different when connecting to it via a device application from a desktop app? Or is it just because I'm using a localhost url?
I am simulating my phone by an emulator and just cradling it.
I get this web exception: Could not established connection to network
modified on Sunday, December 7, 2008 11:36 AM
|
|
|
|
|
harcaype,
accessing localhost on the emulator will most probably not work, as it is the emulator itself, not the development machine you are working on. As you've said you have to connect the emulator to the PC by cradling it, enable DMA on ActiveSync, and instead of localhost use the internal IP address of your PC (you can find out which IP you have under network settings or calling ipconfig /all on the command line.
Cheers,
Marcelo
|
|
|
|
|
Thanks for the reply. I did what you just said, however, it still did not connect. I am currently reinstalling my activesync since it is also encountering its own issues.
I took the IP address of my wireless network btw.
|
|
|
|
|
are you using the integrated web server from visual studio? That web server only accepts connections from localhost. Try to install IIS or any other web server on your PC and see if the emulator can connect to it.
Marcelo
|
|
|
|
|
How do you do that? Someone also told me that I should create a simple html first then try it to host in my IIS. How do you do that?
|
|
|
|
|
check this if you have Xp:
http://www.learnthat.com/courses/computer/windowsxp/iis/
or this if you have Vista:
http://www.howtogeek.com/howto/windows-vista/how-to-install-iis-on-windows-vista/
After you have installed IIS and created a default page, browse to http://localhost from the PC. If it works, try to navigate to http://[IP of PC] from the emulator (using mobile Internet Explorer) and see if it works. If that works too, you have to set up your IIS to work with visual studio instead of the built in web server.
Marcelo
|
|
|
|
|
I already have an IIS installed. And about the localhost . Mozilla Firefox issued me a username and password. I tried my computer login and everything I think possible, but still it did not allow me to access the page. Why is this? And how do I deal with it?
Someone also told me that I should create first an html file and make IIS host it. How do you host that? I'm sorry. I'm very new to this.
|
|
|
|
|
Hey All,
I've just been playing with these two and was wondering if there were any other frameworks I should look out for?
One of the things I'd like to do is be able to do is compare test runs, something that doesn't seem to be immediately obvious how to achieve with these frameworks.
Any links/info would be great.
Cheers,
|
|
|
|
|
Jammer wrote: wondering if there were any other frameworks I should look out for
AFAIK, no. All unit test frameworks that I know are based on the so-called xUnit architecture (meaning that you have fixtures, test methods, setup/teardown, attributes etc.). In my opinion, MbUnit is best because it gives a lot of flexibility regarding factories, parameters etc. There are some specialised unit test frameworks for DB (NDbUnit) and GUI (NUnitForms, Watin), they are all xUnit, so they are immediately familiar.
Jammer wrote: compare test runs
What exactly do you mean with that? Setting up a regression timeline? You can do so only by storing each test report. Generally it is recommended that at all time all tests have to pass. This way you will immediately see if something changes during the course of development.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Hi Thomas,
Thanks for this.
I've just been looking at MbUnit v3 and it actually provides the exact functionality I need in order to store and compare test run results. Interesting!
Now if I could only figure out how to use some XML data with it, i'll be fine! It seems that the whole data thing has changed in this version and they haven't written up any docs yet!! Ouch!
|
|
|
|
|
Hi,
I’m new in C#
I need to develop sequence diagram,
Sequence diagram contain arrows, text and column.
It should contain three columns that have arrows with text between them (for example message from module to module, each module is a column)
I would like to be able to stretched the Sequence diagram if the user stretched the form so arrow and text become bigger when the form is bigger.
What is the best way to create Sequence diagram?
Should I use image class and then set in on the form ?
Thanks
Ronen
|
|
|
|
|
I did not understand what you mean exactly, maybe Tablelayout container can help you somehow
|
|
|
|
|
UML Sequence diagram, see example below
column1 column2 column3
msg1 ----> msg2
msg2 ---->msg3
msg1<----------------msg3
Ronen
|
|
|
|
|
i dunno where will you implement it but here is the general solution :
make a custom control, add three panel
Firt panel : set Dock to Left
Second Panel : set Dock to Fill
Third Panel : Set Dock to Right
now, put 3 picture box in panel 2 *
First PB : Dock-Left, BackGroundImageLayout-Stretch
Second PB : Dock-Fill, BackGroundImageLayout-Tile
Third PB : Dock-Right, BackGroundImageLayout-Stretch
*Make sure Dock-Fill object must be full in middle, you can change it by Send Backward and Send Forward.
set arrows tops in First and Third PBs' BackGroundImage property and set a line in second PB's BGI property.
Now when you increase the width of that control, it will increase automatically and you have 2 empty panels where you can put anything you want.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
thank you
I will try it
Ronen
|
|
|
|