|
Hi everyone! With one sentence: How can I define startup parameters for a windows service while installing it?
Here is the detailed story which I think that it would be helpful for help
I wrote and installed my custom windows service. I didn’t use the right mouse click to create a service installer instead I derived it from the “Installer” class and wrote it myself. Now I need to use my service sometimes as a windows application. In the main Main() method of my application I made a check for parameters. If there is a parameter called “-ui” it works as a Windows application. If there is not a parameter it checks if it’s already installed into the windows services or not. If not installed then it installs itself and runs. The service/windows application runs well. Now I just want it to run it without a parameter as a Windows application and with a parameter as a service (the total opposite as I am using it right now). So I changed my Main() method for the parameters. With a double click on the exe it runs as windows application. For starting the service now the application is expecting a parameter called “-service” from the command line. The service must also be notified that it can take parameters. By double clicking in the “services” window we can see “Path to executable" (which is the “ImagePath” key in the registry). I modified the value of the “ImagePath” key by hand and the service worked well. Now I want to skip the editing the registry by hand part and automate it. First I tried add the parameter into the assembly location.
this.Context.Parameters["assemblypath"]= Assembly.GetEntryAssembly().Location + " -service";
this modification truly changed the see “Path to executable" of my service in the services window and and “ImagePath” in the registry like this:
“myPath\MyService.exe –service”
but the funny thing was that my service stoped working after the modification. The reason that it was working when I modified the registry by hand was that the ”-service” parameter wasn’t in the double quotes. Instead it was like this.
“myPath\MyService.exe’ –service
I checked several web sites to figure out how to define startup parameters into a windows service and I always came to a code which modified the registry key “ImagePath”.
using (RegistryKey system = Registry.LocalMachine.OpenSubKey("System"))
{
if (system == null)
return;
using (RegistryKey currentControlSet = system.OpenSubKey("CurrentControlSet"))
{
if (currentControlSet == null)
return;
using (RegistryKey services = currentControlSet.OpenSubKey("Services"))
{
if (services == null)
return;
using (RegistryKey service = services.OpenSubKey(KmsService.SERVICE_NAME))
{
string imagePath = service.GetValue("ImagePath") as string;
service.SetValue("ImagePath", imagePath + " -service");
Registry.LocalMachine.Flush();
service.Close();
}
services.Close();
}
currentControlSet.Close();
}
system.Close();
}
But now I got permission issues to write to the registry. How can I solve this problem. Because I can normally write to the registry otherwise it would not write to it in the first place.
In the end thank you in advance…
Sincerely
Mehmet Rasim Inceoglu
|
|
|
|
|
Hi to all.
I created a MSI Setup which contains three Projects
1.Windows Application
2.Windows Service
3.Custom Action Data
The SetUp is Installing and Uninstalling Successfully.Some times if Due to some error while Uninstallation First the Service is Removed and then due to some Problem in Uninstallation it is Stopped at Client System.Then The Setup is Neither Uninstalled nor Installed. As we are Updating the Setup Continuously it is not possible to client to detect the MSI Setup of Version installed in his System and repair. So I removed the Service installation and Uninstallation in Setup and I Handled manually through Custom Action Data.But now another problem started.The Program is Shown as Two Programs in Add/Remove programs.That means it is Not Updating the old version.It is taken as new Program to System.can any one tell me what might be the reason.
I will be very thankful to u as it is Burning issue to me.
Thanks&Regards,
narayana
|
|
|
|
|
Hi to All
I got the solution.By mistake I changed the Upgrade code of SetUp.That is the Problem.
|
|
|
|
|
How can i split a bitmap image imnto 4 equal parts using c#.net
|
|
|
|
|
Bitmap.Clone(Rectangle, PixelFormat)
http://msdn.microsoft.com/en-us/library/ms141944(VS.80).aspx[^]
Regards,
Thomas Stockwell
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.
Visit my Blog
|
|
|
|
|
coversion of image into pixel matrix using vb.net
|
|
|
|
|
Decide what you want and stop reposting the same question
|
|
|
|
|
huu... I answared this question last time you asked it...
|
|
|
|
|
Hi,
I am wanted to convert/store a string, which has XML elements, into a dataset or data table. The string that I am reading from a service is the result of my query. I have written the following code,
{
DataSet ds = new DataSet();
StringReader stream = new StringReader(xmlString);
ds.ReadXml(stream);
DataTable dt = ds.Tables[0];
dg.DataSource = dt;
return dt;
}
I am receiving two different type of strings, they are
xmlString1:
<?xml version="1.0" encoding="UTF-8"?>
<nh:rows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nh="http://nhdb">
<nh:urnumber>0123456</nh:urnumber>
<nh:surname>xxxxx</nh:surname>
<nh:forename>yyy</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1958-10-05</nh:dob>
<nh:address>Mxaxixlx</nh:address>
<nh:suburb>Prxxxx</nh:suburb>
<nh:state>Vxxx</nh:state>
<nh:postcode>3072</nh:postcode>
<nh:patientphone>phone</nh:patientphone>
<nh:gender>Female</nh:gender>
<nh:unit>Sxxxxx Oxxxx</nh:unit>
<nh:ward>Bxxx DPxx</nh:ward>
</nh:rows>
xmlString2:
<?xml version="1.0" encoding="UTF-8"?>
<nh:rows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nh="http://nhdb">
<nh:urnumber>0123450</nh:urnumber>
<nh:surname>Cxxxxxx</nh:surname>
<nh:forename>RxxxxxT</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1954-07-19</nh:dob>
<nh:address>'ANNANDALE'</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Male</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
<nh:urnumber>0123451</nh:urnumber>
<nh:surname>KROL</nh:surname>
<nh:forename>ANILLA</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1958-12-10</nh:dob>
<nh:address>68A CLARENCE</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Female</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
<nh:urnumber>0123452</nh:urnumber>
<nh:surname>GEYER</nh:surname>
<nh:forename>MAUREEN</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1948-06-02</nh:dob>
<nh:address>19 JAYSON</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Female</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
</nh:rows>
The above code works perfectly for the xmlString1 and it is converting a data table with single row of data for the cloumns urnumber, surname, forename, middlename, dob, address, suburb,state, postcode,patientPhone, gender, unit, ward.
When I am receiving the xmlString2, the data table is populated with only one column urnumber_Text(for all ur numbers in the xml string).
What am I missing here? Is there any other genuine way of doing it?
Thanks a Lot for your valuable time and invaluable advice.
Looking for advice,
Renu
|
|
|
|
|
Hi,
You need to inject each record fields as child nodes of a parent node i.e. you should generate XML as below:
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<nh:rows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nh="http://nhdb">
<nh:urnumber>0123450</nh:urnumber>
<nh:surname>Cxxxxxx</nh:surname>
<nh:forename>RxxxxxT</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1954-07-19</nh:dob>
<nh:address>'ANNANDALE'</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Male</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
</nh:rows>
<nh:rows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nh="http://nhdb">
<nh:urnumber>0123451</nh:urnumber>
<nh:surname>KROL</nh:surname>
<nh:forename>ANILLA</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1958-12-10</nh:dob>
<nh:address>68A CLARENCE</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Female</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
</nh:rows>
<nh:rows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nh="http://nhdb">
<nh:urnumber>0123452</nh:urnumber>
<nh:surname>GEYER</nh:surname>
<nh:forename>MAUREEN</nh:forename>
<nh:middlename></nh:middlename>
<nh:dob>1948-06-02</nh:dob>
<nh:address>19 JAYSON</nh:address>
<nh:suburb></nh:suburb>
<nh:state></nh:state>
<nh:postcode></nh:postcode>
<nh:patientphone></nh:patientphone>
<nh:gender>Female</nh:gender>
<nh:unit></nh:unit>
<nh:ward></nh:ward>
</nh:rows>
</Data>
Regards,
Chandu
|
|
|
|
|
Howdy All,
I'm kicking around the idea of using the CodeDom namespace in an application to allow end users some limited access to scripting (for example to functions in System.Math).
Is anyone aware of any restrictions on the CodeDom in a distributed application? I realize it's already part of the framework, but...I had heard a story about licensing restriction in the old VBScript and was wondering if anyone had heard anything similar with regards to .Net.
A little googling didn't really reveal anything other than some GPL discussion around MONO, but none of it seemed relevant. Maybe I just wasn't using the right search terms...
Anyway, has anyone heard or tried anything along these lines?
|
|
|
|
|
I am have an MDI application where I have several child forms that open under the parent MDI form.
When the child form is opened in the MDI parent form it flickers.
The child form has many controls on it which gets filled by querying from the database when the form loads.
Also the child form has a grid displaying all the records from database.
I am using dataset to fetch more than 2000 records from database and bind it to grid.
I am having problem during loading of this form.
I have tried using following to avoid form flickering:
> DoubleBuffering technique
> Using Datareader instead of Dataset for fetching records
> Fetching records from database after form is loaded using Form_Shown() event
and used BackgroundWorker to Asynchronously fetch records from database.
Can anyone please help me out to avoid the form flickering issue.
Thanks in advance !!!!!!!!
|
|
|
|
|
Hi,
I have got a problem.
In a web project in 3.5, I have :
- a Entity Framework model, linked to a SQL Server 2005 database
- two services :
1) a ADO.Net Data Service (ex-Astoria)
2) a WCF Service
These two services are both linked to the Entity model.
In the client project (it's Silverlight), I added two references, for each of the services. VS2008 creates for me two Reference.cs files, one for each service.
The problem is that the two files are containing the same definitions of entities, but VS2008 consider that they are different, because they belongs to two different namespaces. Therefore, if I want to use the two services in the same class, I get an error of ambiguous reference between the two definitions. So I can only use one service in the same class :/ The problem would be resolved if the entities would be defined once.
Would it be possible to have only one definition of the entities for the two services reference ?
|
|
|
|
|
Hi,
I need to get data from SQL and write it on an application using the application's web services.
I need this to be scheduled.
What's best to do?
Write a Windows Service and schedule it or write a console application and schedule it in the Task Scheduler?
Thanks in advance
|
|
|
|
|
I'd go for the console-application, read the records in a DataTable and pump them one by one to the WebService of the application that you're going to export to. That's easily scheduled through the Windows Task Scheduler, and easy to understand (therefore, easy to maintain)
You can run a console-application as a service and effectively delay this decision. There are some freeware-tools out and about that can help in this regard.
--edit--
Question was about a Windows-service, not webservice..
I are troll
modified on Wednesday, March 4, 2009 3:39 AM
|
|
|
|
|
Depending on the frequency you need to run this you would do either.
If you have to run this query many times a day, then a service might be in order. If it's just one or two times a day, then a console app launched through the Task Scheduler would be a better choice.
|
|
|
|
|
Has anyone has run into this problem and found a solution. I spent 1/2 day googling with no success.
File -> Open -> Web Site, navigate to my XSLT file, assign an XML input file, set a breakpoint at <xsl:template match="/" > (actually I set one at every line) and click XML -> Debug Xslt.
It shows the output but does not stop at any breakpoint. If I move the files to a different Web Site that uses VS2005, everything works correctly.
Any help would be appreciated.
|
|
|
|
|
How can i convert a color image into pixel matrix using c#.net
modified on Wednesday, March 4, 2009 1:44 AM
|
|
|
|
|
rohan4040 wrote: How can i convert a color image into pixel matrix
By writing code - in the language of your choice.
|
|
|
|
|
If you had magnified between the lines of his post like times 100 you would have seen:
"Send me the codes pleezzzzz, it's urgent"
|
|
|
|
|
I urgently ignored the subtext.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
a slow but easy way to do this is to use the Bitmap class' GetPixel method.
I am writing this code as I go and will probably contains error:
class ByteColor
{
public byte R;
public byte G;
public byte B;
}
Bitmap myBMP=new Bitmap("myimage.jpg");
int iW=myBMP.Width;
int iH=myBMP.Height;
ByteColor[,] myPixelMatrix=new ByteColor[iW,iH];
for(int w=0; w<iw;w++)>
{
for(int h=0; h<ih;h++)>
{
Color tmpColor=myBMP.GetPixel(w,h);
byte cR=Convert.toByte(tmpColor.R);
byte cG=Convert.toByte(tmpColor.G);
byte cB=Convert.toByte(tmpColor.B);
myPixelMatrix[w,h].R=cR;
myPixelMatrix[w,h].G=cR;
myPixelMatrix[w,h].B=cR;
}
}
As I said this is a easy but slow way to do it. for some more speed you can use the LockBits and UnlockBits methodes and copy the byte array right from memory like this:
Rectangle rect = new Rectangle(0, 0, myBMP.Width, myBMP.Height);
BitmapData ImageColorData = myBMP.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
unsafe
{
IntPtr pointer = ImageColorData .Scan0;
int Bytesnmpr = ImageColorData .Stride * myBMP.Height;
byte[] ColorValues = new byte[Bytesnmpr];
Marshal.Copy(pointer, ColorValues , 0, Bytesnmpr);
for (int i= 0; i< ColorValues .Length; i++)
{
}
Marshal.Copy(ColorValues , 0, pointer , Bytesnmpr);
}
myBMP.UnlockBits(ImageColorData);
this one is much faster but uses unsafe code.
also remember, I worte the code on the fly, so there is most likely errors in this code
|
|
|
|
|
is this coding related to c#.net or any other form of coding?
|
|
|
|
|
How can i convert a numeric value to binary value
|
|
|
|
|
Well, you can use the Calculator that comes with Windows, or you can read up[^] here.
You can find the conversion-routines (like this[^] one) on Google
I are troll
|
|
|
|