|
Hi.
I've created a service and installed it with following code :
public static void InstallService(string ExeFilename)
{
System.Configuration.Install.AssemblyInstaller Installer = new System.Configuration.Install.AssemblyInstaller(ExeFilename, new string[] { });
Installer.UseNewContext = true;
Installer.Install(null);
Installer.Commit(null);
}
I wanna start it after install, could you please guide me how I can do it ?
Thanks.
|
|
|
|
|
|
|
I am creating a custom control derived from ComboBox. I add some items to custom control in constructor of control.
// this code is sample
public MyCustomControl
{
this.Items.Add("test1");
this.Items.Add("test2");
}
When I drag this custom control to my form, designer auto-generate the code:
// this code in Form1.Designer.cs
this.mycustomControls.Items.AddRange(new object[] {
"test1",
"test2"});
When this custom control display on Form1, will have 4 items:
test1
test2
test1
test2
This problem cause duplication.
Please help me how to solve this problem, I don't want designer auto-generate these codes. Thanks.
|
|
|
|
|
can anyone explain me that how to show a form from windows service. i search google but found no solution. please explain anyone.
Thanks in advance
tbhattacharjee
|
|
|
|
|
The Question is how do you Display a Form ?
Form1 frm1 = new Form1();
frm1.Show();
i have not been doing win apps for a while now , but that is how its done.
My point is that need to create that form first and show it later.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Tridip Bhattacharjee wrote: How to show a form from windows service?
Windows services don't interact with the user using UI.In fact they are "background" processes and it's not not safe to control the UI outside of the default drawing pool.If you need to control the service programatically
define your own custom commands and send them to the service using ServiceController.ExecuteCommand method.See this sample.And if you need to report for some errors use the event log.
Life is a stage and we are all actors!
|
|
|
|
|
In service properties at Log On tab "Allow Service to interact with desktop" should be checked.
|
|
|
|
|
Hello Friends
I have a TreeView which has many nodes which are are being created dynamically.
I have set a check box against each node of that TreeView. Now My Problem is I need to work with it's Click event. But how can I hold it.?
Here's The code where I do this.
private void BuildTree(List<ParentChild> liParentChild)
{
List<ParentChild> liParent = liParentChild.FindAll(delegate(ParentChild oParentChild) { return oParentChild.ParentID == 0; });
foreach (ParentChild currentParent in liParent)
{
TreeViewItem currentParentNode = new TreeViewItem();
currentParentNode.Tag = currentParent.ID;
string folderImagePath=@"C:\Documents and Settings\Sharif\My Documents\Visual Studio 2008\Projects\TreeView\TreeView\Images\FolderOne.jpg";
// string lowerLevelImagePath=@"C:\Documents and Settings\Sharif\My Documents\Visual Studio 2008\Projects\TreeView\TreeView\Images\FoldeTow.jpg";
string fileImagePath = @"C:\Documents and Settings\Sharif\My Documents\Visual Studio 2008\Projects\TreeView\TreeView\Images\File.jpg";
#region image and font style
StackPanel oStackPanel = new StackPanel();
oStackPanel.Orientation = Orientation.Horizontal;
CheckBox oCheckBox = new CheckBox();
oCheckBox.Name = "cb_" + currentParent.ID;
//oCheckBox.IsEnabled = false;
oStackPanel.Children.Add(oCheckBox);
oStackPanel.Children.Add(CreateIcon(folderImagePath));
TextBlock tb = new TextBlock();
tb.Text = currentParent.Name;
oStackPanel.Children.Add(tb);
currentParentNode.Header = oStackPanel;
#endregion
AddTreeChild(currentParentNode, liParentChild, currentParent,1,folderImagePath,fileImagePath);
tvParentChild.Items.Add(currentParentNode);
//ExpandAll(tvParentChild);
//CollapseAll(tvParentChild);
}
}
private void AddTreeChild(TreeViewItem currentParentNode,List<ParentChild> liPC,ParentChild currParent,int level,string folderImagePath,string fileImagePath)
{
int currntLevel = level + 1;
List<ParentChild> liChild = liPC.FindAll(delegate(ParentChild oParentChild) { return oParentChild.ParentID == currParent.ID; });
foreach (ParentChild currentChild in liChild)
{
TreeViewItem currentChildNode = new TreeViewItem();
StackPanel oStackPanel = new StackPanel();
oStackPanel.Orientation = Orientation.Horizontal;
currentChildNode.Tag = currentChild.ID;
#region font style and image
string sourcePath;
if(IsLeaf(currentChild.ID,liPC))
sourcePath = fileImagePath;
else
sourcePath = folderImagePath;
if (currntLevel % 2 == 0)
{
//currentChildNode.FontStyle = System.Windows.FontStyles.Italic;
currentChildNode.Foreground = Brushes.Brown;
//currentChildNode.Background = Brushes.White;
}
else
{
//currentChildNode.FontStyle = System.Windows.FontStyles.Normal;
currentChildNode.Foreground = Brushes.Black;
//currentChildNode.Background = Brushes.White;
}
CheckBox oCheckBox = new CheckBox();
oCheckBox.Name = "cb_" + currentChild.ID;
// oCheckBox.IsEnabled = false;
oStackPanel.Children.Add(oCheckBox);
oStackPanel.Children.Add(CreateIcon(sourcePath));
TextBlock tb = new TextBlock();
tb.Text = currentChild.Name;
oStackPanel.Children.Add(tb);
currentChildNode.Header = oStackPanel;
#endregion
AddTreeChild(currentChildNode, liPC, currentChild,currntLevel,folderImagePath,fileImagePath);
currentParentNode.Items.Add(currentChildNode);
}
}
|
|
|
|
|
1. Use pre tags when posting code. It looks more readable.
2. If you set the CheckBoxes property of the treeview to true, it will show checkboxes before each node. Then you can handle the NodeMouseClick event and capture the click.
3. If you still go will the current apprach, handle the CheckChanged event for each checkbox you add.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hello All,
Is there anyway in which i can create a word document programmatically without using Office Interop or third-party libraries.
|
|
|
|
|
Yes - you can rewrite word, or if you want to only support the new version of Word, you can learn it's XML format and write something that uses that.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I dont want to re-write into a word document..i want to create a new word document..So is there any way??
|
|
|
|
|
|
I am getting the below error
WCF - HTTP Post The remote server returned an error: (400) Bad Request
client & sever code below
--------------------------------------------
ServiceContract]
[WebInvoke(UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
Stream SavePerson(Stream input);
-----------------------------
public Stream SavePerson(Stream input)
{
StreamReader streamReader = new StreamReader(input);
string rawString = streamReader.ReadToEnd();
streamReader.Dispose();
// try to store it in xml file
// I want to store the input stream to xml file
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(rawString);
xmlDoc.Save("D:\\a.xml");
//
Encoding encoding = Encoding.GetEncoding("ISO-8859-1");
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
byte[] returnBytes = encoding.GetBytes(rawString);
return new MemoryStream(returnBytes);
}
-------------------------
Client Post
string postData = GetXmlString("d:\\test\\dirdownload.xml"); // user function
WebRequest request = WebRequest.Create("http://abc.xyv.com/mytest/myservice.svc");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Response.Write (((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Response.Write(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
---------------------------------------------------------
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(rawString);
xmlDoc.Save("D:\\a.xml");
how to save the request input stream to xml file ?
Please advise
|
|
|
|
|
You should post this in the WCF Section here http://www.codeproject.com/Forums/1004114/WPF-WCF-WF.aspx[^]
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
When I call the webservice method from my class synchronously or assynchronously i am receiving the following error:
(System.NullReferenceException: Object reference not set to an instance)
I am being able to call the loadWindow webservice method without any problem but when i pass the dataset as parameter in the saveWindow im receiving the error above. Any solution will be appreciated.
private void SaveData()
{
try
{
SYS_WS sysws = new SYS_WS();
sysws.SaveWindowCompleted +=new SaveWindowCompletedEventHandler(sysws_SaveWindowCompleted);
sysws.SaveWindowAsync((SYSDataset)dsSystem.GetChanges());
}
catch (Exception ex)
{
throw (ex);
}
}
private void sysws_SaveWindowCompleted(object sender,
SaveWindowCompletedEventArgs e)
{
try
{
if (e.Error != null)
{
return;
}
this.dsSystem.AcceptChanges();
}
catch (Exception ex)
{
throw ex;
}
}
[WebMethod(EnableSession = true)]
public bool SaveWindow(SYSDataset ds)
{
try
{
WindowController cont = new WindowController();
cont.SaveWindows(ds);
return true;
}
catch (Exception ex)
{
throw (ex);
}
}
[WebMethod(EnableSession = true)]
public SYSDataset LoadWindow(string WindowID)
{
WindowController cont = new WindowController();
return cont.LoadWindow(WindowID);
}
---- Stack Trace ----
RTR.SYS_V.Setup.frmWindow.SaveData()
frmWindow.cs: line 0091, col 17, IL 0079
RTR.SYS_V.Setup.frmWindow.btnSave_Click(sender As Object, e As EventArgs)
frmWindow.cs: line 0202, col 13, IL 0001
System.Windows.Forms.Control.OnClick(e As EventArgs)
MAIN.EXE: N 00111
System.Windows.Forms.Button.OnClick(e As EventArgs)
MAIN.EXE: N 00073
System.Windows.Forms.Button.OnMouseUp(mevent As MouseEventArgs)
MAIN.EXE: N 00171
System.Windows.Forms.Control.WmMouseUp(m As Message&, button As MouseButtons, clicks As Int32)
MAIN.EXE: N 00654
System.Windows.Forms.Control.WndProc(m As Message&)
MAIN.EXE: N 8788613
System.Windows.Forms.ButtonBase.WndProc(m As Message&)
MAIN.EXE: N 8807204
System.Windows.Forms.Button.WndProc(m As Message&)
MAIN.EXE: N 00031
System.Windows.Forms.ControlNativeWindow.OnMessage(m As Message&)
MAIN.EXE: N 00015
System.Windows.Forms.ControlNativeWindow.WndProc(m As Message&)
MAIN.EXE: N 00048
System.Windows.Forms.NativeWindow.Callback(hWnd As IntPtr, msg As Int32, wparam As IntPtr, lparam As IntPtr)
MAIN.EXE: N 00089
modified on Tuesday, September 1, 2009 2:18 AM
|
|
|
|
|
There are a number of errors in your post (please read the guidelines).
Your title is not acceptable - it is not urgent to anyone but yourself
Your posted code is not inside pre tag and is difficult to read.
You have not indicated where you get the error (what line)
You did describe the error so I can tell you there is an object that is declared but not initialised. Try debugging through the code to identify the line, look for an object that is 'null' where you expect it to have a value.
|
|
|
|
|
hi sir,
i remodified the document..concerning to the code i debugged i am loading the record and then modify data and save.
i checked the rows.count its 1 dataset is not null.
The line that im receiving the error is before calling the save webservice method.
SYS_WS sysws = new SYS_WS();
-->sysws.SaveWindowCompleted +=new SaveWindowCompletedEventHandler(sysws_SaveWindowCompleted);
<br />
Soap exception is thrown :<br />
soap System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
thanks for your help
|
|
|
|
|
|
You can't. How do you expect to get progress notification from Word ?
If you're taking steps in your own code, you show a progress bar, as explained in a ton of articles.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i am opening the word document from my code.so there must be some way to show progress bar
|
|
|
|
|
Swetha Srinivasan wrote: there must be some way to show progress bar
Sure there is, there are many articles here on progress bars. However what CG was referring to is how are you going to define the progress of the open function. This is why there is a little circular animation used, you have no idea how long it will take.
|
|
|
|
|
|