|
Hi Mike,
It did work for me on VS 2008. Here is my program -
using System;
using System.ServiceProcess;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
ServiceController service = new ServiceController("<<Your Service Name>>");
service.Stop();
TimeSpan timeout = TimeSpan.FromMilliseconds(10000);
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
if (service.Status == ServiceControllerStatus.Stopped)
{
service.Start();
}
}
catch
{
// ...
}
}
}
}
Are you getting any specific error ?
|
|
|
|
|
First of all I would like to thank every one who has tried to help me thus far, it great! As I said im a noob at c# getting this type of help will bring me to the next level (even if its a still a low one )
I'm am using vista....
when using Shukla's great piece of code I get this:
The problem might be missing a reference?
Error 1 The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\mike\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 2 14 ConsoleApplication1
The problem might be missing a reference?
Also the ebook (Microsoft.Press.Microsoft.Visual.C.Sharp.2008.Step.by.Step)I use to teach myself is not telling me how to link in a external .dll so if you have any good references on this subject I would love to know!
Anyway thank you for you time!
|
|
|
|
|
Hey,
I am programing a program that uses a Web Service to connect between the Server and WinAPP forms.
I made the web service and active my IIS 7 (Using vista ultimate), then i enterd into my localost(using IP) and all go ok (check my defined methods and they returned void XML data)
But when i combine that web service to WinAPP and them bind data to datagrid i got error:
System.Net.WebException: הבקשה נכשלה עם הודעת השגיאה:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fUniversityWebServices%2fService.asmx%3fAspxAutoDetectCookieSupport%3d1">here</a>.</h2>
</body></html>
--.
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
ב- System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
ב- WindowsUniversityClient.UniversityWebReference.Service.GetGradesByStudentId(Int32 id) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Web References\UniversityWebReference\Reference.cs:שורה 83
ב- WindowsUniversityClient.Form1.searchgrades_btn_Click(Object sender, EventArgs e) ב- C:\Users\יהב\Desktop\UniversityTestOrgnizer\UniversityTestOrgnizer\WindowsUniversityClient\Form1.cs:שורה 24 the code i userd
UniversityWebReference.Service service = new WindowsUniversityClient.UniversityWebReference.Service();
try
{
this.grades_dataview.DataSource = service.GetGradesByStudentId(int.Parse(this.studentid_txtbox.Text));
}
catch (FormatException format_e)
{
MessageBox.Show(format_e.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch(Exception ee)
{
MessageBox.Show(ee.Message, "נוצרה שגיאה במהלך הצגת הנתונים", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Gindi Bar Yahav - Web & Software defeloper.
modified on Saturday, June 20, 2009 10:43 AM
|
|
|
|
|
Hmm, my Hebrew is no so good, but you might try using: int.TryParse() instead of int.Parse(). Also, it is good to use some debug methods for inspecting the SOAP message before and after it is processed. You can do this in debug mode in Visual Studio. Make sure your IO is working correctly. This is the half split, method for finding bugs in SOAP based web services. Then depending on where the problem is manifesting you will know what end point is responsible for the problem.
|
|
|
|
|
Sorry about the hebrew... :$
Isolved the problem
i enterd in the windows form into app.config
and them edit
<setting name="WindowsUniversityClient_UniversityWebReference_Service"
serializeAs="String">
<value>http:
</setting>
To:
<setting name="WindowsUniversityClient_UniversityWebReference_Service"
serializeAs="String">
<value>http:
</setting>
Now, when he hav AspxAutoDectateCoolieSupport it gives me the results
Thanks for your help!, Yahav.
Gindi Bar Yahav - Web & Software developer.
|
|
|
|
|
I need to shut down the entire application when the user clicks this button, but I don't know how to check if the window was closed via the "X" button or some other button.
|
|
|
|
|
Hi,
you should have a look at the Form.FormClosing event, its event arg has a CloseReason property.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Subscribe to the Form.FormClosing event and look at e.CloseReason. If the user closes the Form via Alt-F4 or the 'X' button, then e.CloseReason will be CloseReason.UserClosing. For the rest of the possible values, look in the documentation[^]
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I forgot to mention that I'm actually using a WPF form, and there doesn't seem to be a CloseReason. I posted it here and not in the WPF forums because I thought that this was more of a general issue
|
|
|
|
|
Hi,
I have lot of records in dataset, it is something above "150,000/=".
kindly let me know, is there any quick method to insert these records into new table using MS-Access?
Thank you in advance
(Riaz)
|
|
|
|
|
This [^]might help you
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hello everybody
I have a Form and I use the GDI+ to have a User Interface
I have a Button(just an image) that should be repainted when it is clicked
and I use a flag at the mouse event handler to know when the button is clicked
and in the OnPaint method I check it FIRST, and if the flag was True I don't paint
the BackGroundImage, because it is painted before (at the startup of the Form)
but I don't know why that BackGroundImage is gone when the event occures
and only my button and the BackColor of the Form is shown
=>>note: I don't want to use BackGroundImage because I think it will paint it all the times that the Form is repainted, and it is process intensive
Thank you
P.S: If you want to read this code better you can copy/paste it in VS.NET and
select all the code and use CTRL + (K) then CTRL + (F) to format the code
in a good format to be more readable
here is the OnPaint method:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
if (LanguageTraining)<br />
{<br />
dc.DrawImage(ButtonSelectedBlue, LanguageButtonBounds);<br />
LanguageTraining = false;<br />
base.OnPaint(e);<br />
return;<br />
}<br />
base.OnPaint(e);<br />
Graphics dc = e.Graphics;<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
<br />
<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
dc.DrawImage(piccy, piccyBounds);<br />
dc.DrawString("Language Training", ButtonFont, TextBrush, new Point(755, 625));<br />
<br />
<br />
}<br />
Here is all the code
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace paintImage<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private bool LanguageTraining = false;<br />
private Point MouseClickPosition;<br />
private readonly Brush TextBrush = Brushes.White;<br />
private readonly Font ButtonFont = new Font("alefba", 18,FontStyle.Bold);<br />
<br />
readonly Image piccy;<br />
readonly Image ButtonSelectedBlue;<br />
readonly Image ButtonSelectedGreen;<br />
private readonly Point[] piccyBounds;<br />
private readonly Point[] LanguageButtonBounds;<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
piccy = Image.FromFile(@"C:\pics\page1.png");<br />
<br />
ButtonSelectedBlue = Image.FromFile(@"C:\pics\Button Selected Blue.png");<br />
ButtonSelectedGreen = Image.FromFile(@"C:\pics\Button Selected Green.png");<br />
AutoScrollMinSize = piccy.Size;<br />
piccyBounds = new Point[3];<br />
LanguageButtonBounds = new Point[3];<br />
<br />
const int resolutionX = 1024;
const int resolutionY = 768;
<br />
<br />
piccyBounds[0] = new Point(0, 0);<br />
piccyBounds[1] = new Point(resolutionX, 0);<br />
piccyBounds[2] = new Point(0, resolutionY);<br />
<br />
LanguageButtonBounds[0] = new Point(744, 617);<br />
LanguageButtonBounds[1] = new Point(992, 617);<br />
LanguageButtonBounds[2] = new Point(744, 659);<br />
<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
if (LanguageTraining)<br />
{<br />
dc.DrawImage(ButtonSelectedBlue, LanguageButtonBounds);<br />
LanguageTraining = false;<br />
base.OnPaint(e);<br />
return;<br />
}<br />
base.OnPaint(e);<br />
Graphics dc = e.Graphics;<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
<br />
<br />
dc.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y);<br />
dc.DrawImage(piccy, piccyBounds);<br />
dc.DrawString("Language Training", ButtonFont, TextBrush, new Point(755, 625));<br />
<br />
<br />
}<br />
protected override void OnKeyUp(KeyEventArgs e)<br />
{<br />
base.OnKeyUp(e);<br />
if (e.KeyCode == Keys.Escape)<br />
this.Close();<br />
}<br />
protected override void OnMouseDown(MouseEventArgs e)<br />
{<br />
base.OnMouseDown(e);<br />
MouseClickPosition = new Point(e.X, e.Y); <br />
}<br />
protected override void OnMouseClick(MouseEventArgs e)<br />
{<br />
base.OnMouseClick(e);<br />
if (MouseClickPosition.X > 755 && MouseClickPosition.X < 1024 && MouseClickPosition.Y > 625 && MouseClickPosition.Y < 768)<br />
{<br />
Invalidate();<br />
LanguageTraining = true;
}<br />
}<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
<br />
<br />
modified on Saturday, June 20, 2009 7:56 AM
|
|
|
|
|
Hi,
1.
you can show formatted code by using PRE tags instead of CODE tags
2.
There must be several ways to prevent a background repaint.
for one I would try without the base.OnPaint() statement;
alternatively you can have a look at the ControlStyles Enumeration, and the Control.SetStyle method.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Hi,
and thank you for your answer but unfortunately I eliminated the "e.base();"
from the code but the problem wasn't solved
I am trying the other option you mentioned
modified on Saturday, June 20, 2009 8:29 AM
|
|
|
|
|
hi,
i have a Ip address and i want to change it into Variant VT_I4 and then change type to VT_BSTR in .net. Let me know how to do it
|
|
|
|
|
There is no variant in .NET. You could try to use an object instead. I googled for you and couldn't find any better advice.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
I am developing an application in which i use to select data from one grid remove that & display it to the second grid.
I store those data in a local mdb file . when i am selecting rows in bulk(around 50-70 at a time)and then wanted to cut and display in the second grid i am getting this error .
Please help.
|
|
|
|
|
The error means what it says. Your code is locking the MDB. Not sure what sort of help you're hoping for, when you don't post any code.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
hi there,
I have a simple WPF window with a button in it.
now during runtime, i pass this button control to another function, and there, i want to know the parent of this control. ie the window, with the full namespace.
any way for this thru C#
The name is Sandeep
|
|
|
|
|
We have a WPF forum. The control has a parent property, to know the type, you can use the GetType method, you can also use reflection. Any method that gets passed a control, sounds a little ugly to me.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
hi,
thnx for the reply..
The name is Sandeep
|
|
|
|
|
Hi
Because of various graphics that i use in my app, I want my app to run under Windows Classic Theme regardless of the theme the user has selected before they run my app.
Where can I find info about the API calls I need to swtich tmeme at start up and to restore to users' chosen theme on exit?
Thanks.
|
|
|
|
|
Swapping the whole system theme is a little user hostile. It would be better to skin your app to make it look the way you want.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
That's basically what I want to do, but using Windows Classic Theme for the skin instead of a custom skin, but didn't think of it that way.
Now all I have to do is find out how to do it - there are a lot of articles about skinning, so it is difficult to find the best article to look at.
|
|
|
|
|
Hi All
I'm working on a little web browser that supports tabs and all is good but everytime I click a link that is supposed to open in a new tab or window, instead of opening a new window/tab in my own web browser that i am making, it chooses to open a new instance of the system's default web browser (Internet Explorer) and I have tried to find some articles/samples on the web but have been unsuccessful.
Does anybody know how I would go about allowing links to be opened in a new tab in the browser i am making?
Any suggestions would be greatly appreciated
thanks
jason
|
|
|
|