|
no they don't have a data that can relate with the other. Darn and i thought i could get away with that. hehe oh well. thanx again Chris! I'l do the 2 grid process
thanx
|
|
|
|
|
Hi,
I am using the following code for Asynchronous webservice but it is getting hang in WebResponse result = req.GetResponse(); Please let me know what mistake i'm doing.
public XmlNode AForwardRequest(string webRequest, string userName, string password)
{
XmlNode resultNode = null;
try
{
XmlDocument webdoc = new XmlDocument();
string url = "";
string payload = "";
if (webRequest.IndexOf('?') != -1)
{
url = webRequest.Substring(0, webRequest.IndexOf('?'));
payload = webRequest.Substring(webRequest.IndexOf('?') + 1);
}
else
url = webRequest;
WebRequest req = WebRequest.Create(url);
req.Credentials = new NetworkCredential(userName, password);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] SomeBytes = null;
if (payload != null)
{
SomeBytes = Encoding.UTF8.GetBytes(payload);
req.ContentLength = SomeBytes.Length;
IAsyncResult r = (IAsyncResult)req.BeginGetRequestStream(new AsyncCallback(MyClientCallback), req);
}
else
{
req.ContentLength = 0;
}
req.Timeout = Timeout.Infinite;
WebResponse result = req.GetResponse();// In this line it gets hang
Stream ReceiveStream = result.GetResponseStream();
webdoc.Load(ReceiveStream);
result.Close();
resultNode = webdoc.DocumentElement;
}
catch (Exception e)
{
}
return resultNode;
}
public void MyClientCallback(IAsyncResult asyncResult)
{
WebRequest req = (WebRequest)asyncResult.AsyncState;
req.EndGetRequestStream(asyncResult);
}
bye,
Vinoth
|
|
|
|
|
Im creating an application that would be used for a WaveOn wireless device. The application is created using C# and the device runs with CE OS. I was trying to update the system date/time information programmatically depending on the time zone offset that the system pickups from an xml config file. I have done several ways (using APIs and all)... for some time, I have succeeded in my ordeal. Unfortunately as I was modifying the application to make it more flexible, the result seems to be varying ever so often & i couldn't get the correct results I was once able to get. Is WIndows CE really that unstable? Any help would do. Thanks.
|
|
|
|
|
hi, i want to now c# code for delete from the database 'Access'
|
|
|
|
|
Short question, short answer.
OleDbCommand[^]
The SQL Syntax you want goes along the lines of:
DELETE FROM tableName WHERE condition
Where tableName is obvious and condition is something like myField=123
|
|
|
|
|
I am experiencing a very strange and annoying problem . It's gonna take a while to describe it, so be ready to read a long post...
I have a Windows service written in C# that works as a scheduler - it loads objects implementing certain interface from other assemblies, and executes some of their methods when the time comes to do that. Nothing too complex... Let's say this interface looks like this:
public interface IPlugin<br />
{<br />
void Execute();<br />
}
There's a core class - say SvcManager - which has Start(), Stop(), Pause() and Resume() methods that are called from the service' OnStart, OnStop, OnPause and OnContinue methods correspondingly. SvcManager.Start() creates one monitoring thread that is responsible for starting and aborting worker threads according to the schedule.
Worker thread creates an instance of an object implementing IPlugin interface, runs its Execute() method, and exits. The execution could take a while (several hours), so monitoring thread might need to stop the worker thread by calling Abort() method. SvcManager.Stop() aborts the monitoring thread and all worker threads (I keep all the plugin objects loaded, and running threads in the ArrayList), and waits for them to finish. Pause() and Resume() just pauses/resumes all these threads. It doesn't matter what the plugin objects do - they are all loaded from separate assemblies, and supposedly could do anything. Well, everything works perfect, unless any of the plugins implements SOAP client. After each SOAP call memory usage is increasing significantly, making it neccesserily to restart the service every 2 days or so, otherwise it eats all the memory on the machine at the rate of 100-150 Mb/day. It doesn't matter if I create a new instance of soap client proxy (inherited from SoapHttpClientProtocol ) for each call and then explicitly call its Dispose() method in the finally block, or if I create just a single instance of a proxy which is called multiple times in a loop - in both cases memory leaks. I used .NET Memory Profiler from SciTech, and found that after each SOAP call a new set of objects appears in memory and never goes away - these are instances of AsyncCallback, HttpAbortDelegate, GCHandle[], Overlapped, OverlappedAsyncCallback , byte arrays and some other internal classes used by WebClientProtocol implementation - all referring to each other, and somehow keepeng themselfs in memory. When the thread executing SOAP calls exits normally - all these objects stay in memory. I tried to call GC.Collect() - it did not help. And if after Collect() I call GC.WaitForPendingFinalizers() method - it locks my app for several minutes, and still does not release the memory! But - and here comes interesting part - if I terminate the thread by calling Abort() method - the GC immediately destroys all these objects, and from now on the service starts working properly - all new threads executing SOAP calls do not fill up the memory anymore, and the counters for existing instances of all these classes stay below 10 all the time (although before aborting the thread they increase by 1000s/min), and memory does not grow. The tricky part is that thread must be aborted after at least one SOAP call has been made, and before it exits normally. Well, that's a very weird and unclean workaround for the problem ..
Also, as you may notice, the implementation of SvcManager class makes it very easy to execute exactly the same process in a standalone Win32 app (not a service). Actually, it is even the same application - if there is certain parameter in a command line, it starts as a normal WinForms application. And if I set it up to call SvcManager.Start() on start, and SvcManager.Stop() on exit - it makes it to do exactly what the service does. And in the case of standalone app memory does not leak!!! No tricks needed with aborting threads - it just works perfectly fine from the beginning and not accumulating any of these internal objects after SOAP calls...
So I am absolutely lost now. I used to work with unmanaged code, and never had any memory leak problems in the last 6 (or more) years, just making sure to always call the destructor/release the resources in a finally block... Now, when managed environment is supposed to take care of everything, I ran into this issue which drives me crazy
Anyone from Microsoft, or just a guru who knows well the internals of .NET framework - please help! Even though without looking at the code it's really hard to figure out what's going on (believe me - it's not easy when you're staring at the code either!), maybe based on my description you can just give me some hints and lead me to a nicier workaround then the one with aborting the threads... And it's actually not a small app - with complex scheduling etc, so rewriting it from scratch is really not an option right now. I could not track down the reason for GC for not collecting these objects, I do not know what ThreadAbortException exactly does does to the threads so it magically makes GC to start working properly, and I do not see why it could happen only if app is running as a service. If somebody could shed light upon these questions, it might help a lot.
Thanks!
|
|
|
|
|
hi...
i'm trying to create a crystal report, which will load data from my application and display the data. my application no database... just wanna display the data generate by class,.....
totally no idea how to do that.... pls help, if anyone knows that....
thanks a lot....
|
|
|
|
|
You can put your data in a dataset at runtime and then set the datasource of crystal report to that DataSet dynamically !
[ _ Always there is another way _ ]
|
|
|
|
|
How do you recieve input from a user on a console?
|
|
|
|
|
try following
string myValue;
myValue = Console.ReadLine();
- ashish
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
|
hi,
I am making Windows Service(User defined)
I have written code inside OnStart within Windows Service
Inside the onstart i want that suppose a.exe is already running
I want to close that a.exe and start a.exe from windows Service
When i run the windows Service two exe runs cocuurently.
On Start i have written
Process.Start(@"c:\a.exe");
I want to identify in beginning of any process of a.exe if exist
how can i check in windows service OnStart()
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
Process[] aProcesses1;
if (aProcesses1.Length > 0)
{
if(rd1==true)
{
// The last excel process is the orphaned process which is killed
aProcesses1[aProcesses1.Length-1].Kill();
rd1=false;
}
}
int intExcelPID;
aProcesses1=Process.GetProcessesByName("a");
string strProc="These are the processes running \n";
for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
{
intExcelPID = aProcesses1[i].Id;
strProc+=intExcelPID.ToString()+ " ";
}
//Retrive from registry the value of Path
RegistryKey hklm =Registry.LocalMachine;
hklm=hklm.OpenSubKey("SOFTWARE\\man");
Object obp=hklm.GetValue("Path");
string file=obp.ToString() + "\\man.exe";
Process.Start(@file);
}
Thanks
sanjeev
|
|
|
|
|
Going back to your original post, I already pointed out HUGE problems with your code, that by looking at this post, you haven't fixed at all.
But, to find all the "a" processes and kill them, then restart a new one:
Process[] foundProcs = Process.GetProcessesByName(@"a");
foreach (Process proc in foundProcs)
{
proc.Kill();
}
Process.Start(@"notepad");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
having problems with the following:
treeView1.Nodes.Clear();
treeView1.Nodes.Add(dbName);
treeView1.TopNode.ImageIndex = 0;
treeView1.TopNode.SelectedImageIndex = 0;
and then later:
while (dataReader.Read())
{
TreeNode dbNodes = new TreeNode();
dbNodes.Tag = dataReader.GetValue(0).ToString();
dbNodes.Text = dataReader.GetString(0);
treeView1.TopNode.Nodes.Add(dbNodes);
treeView1.ExpandAll();
}
i'm getting the following error:
object refrence not set to an instance of an object
and it fails on the bold lines, if I comment out the first spot it errors then I fail on the second bold.
any ideas? what am i doing wrong?
|
|
|
|
|
Topnode is the first 'fully visible' node in the tree, not necessarily the first or root node. If no node is visible (the only one is scrolled out of sight) then topnode will return null. Try using FirstNode instead. That is the first child node in the nodes collection regardless of visibility...
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not.
Eric Hoffer
|
|
|
|
|
i must not have something right, as i'm recieveing the same error on the following:
treeView1.TopNode.FirstNode.ImageIndex = 0; treeView1.TopNode.FirstNode.SelectedImageIndex = 0;
and if i comment those out i still error out on this one
treeView1.TopNode.FirstNode.Nodes.Add(node);
|
|
|
|
|
Come on, finding out which element is null isn't that hard.
A NullReferenceException always tells you that something is null , but you want to access a property or method anyway.
In your code there are only 3 possibilities: treeView1 , treeView1.TopNode or treeView1.TopNode.FirstNode .
Use the debugger to find out which one is null and you're done.
Probably you've created TreeNodes but didn't add them to the TreeView...
Regards,
mav
|
|
|
|
|
Believe it or not there was something wrong with the way I had it typed up, because i began changing things around and ended up swapping out dbnode and dbnode1 and it works (well, sorta) and if i swap them back out meaning make dbnode1, dbnode then it doesn't work...not sure why, but it works so i'm not worried about it any more....
|
|
|
|
|
Can i just create a class or struct just for hold a set of static datas, let say objMonth contain two properties Month_Desc(String) and Month_ID (number). So Later when i just need to issue the command : cboMonth.DataSource = "objMonth".
The combobox will be able to display Jan till Dec. Thanks.
|
|
|
|
|
The comboBox has a property called 'DisplayMember' which tells it which property on the object it binds to is the one to display. It needs to be a property from memory ( not a public variable ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think my poor english make u misundestand.
I've code below in my form ...
<br />
private struct MonthList<br />
{<br />
public MonthList(string desc,string monthNo, string shortdesc)<br />
{<br />
this._desc = desc;<br />
this._number = monthNo;<br />
this._shortdesc = shortdesc;<br />
}<br />
<br />
private string _desc;<br />
private string _number;<br />
private string _shortdesc;<br />
<br />
public string monthDesc<br />
{<br />
get {return _desc;}<br />
}<br />
<br />
public string monthNo<br />
{<br />
get {return _desc;}<br />
}<br />
<br />
public string shortDesc<br />
{<br />
get {return _shortdesc; }<br />
}<br />
}<br />
<br />
private void init_cboMonth()<br />
{<br />
ArrayList month = new ArrayList ();<br />
<br />
month.Add( new MonthList ("January","1","Jan"));<br />
month.Add( new MonthList ("Feburay","2","Feb"));<br />
month.Add( new MonthList ("March","3","Mar"));<br />
month.Add( new MonthList ("April","4","Apl"));<br />
month.Add( new MonthList ("May","5","May"));<br />
month.Add( new MonthList ("June","6","Jun"));<br />
month.Add( new MonthList ("July","7","Jly"));<br />
month.Add( new MonthList ("August","8","Aug"));<br />
month.Add( new MonthList ("September","9","Sep"));<br />
month.Add( new MonthList ("Otocber","10","Oct"));<br />
month.Add( new MonthList ("November","11","Nov"));<br />
month.Add( new MonthList ("December","12","Dec"));<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";<br />
<br />
}<br />
It work fine in the form..
by when i try to seperate code above it to another file like below
<br />
public class stdData<br />
{<br />
public static ArrayList getMonthList()<br />
{<br />
ArrayList month = new ArrayList ();<br />
month.Add( new MonthList ("January","1","Jan"));<br />
month.Add( new MonthList ("Feburay","2","Feb"));<br />
month.Add( new MonthList ("March","3","Mar"));<br />
month.Add( new MonthList ("April","4","Apl"));<br />
month.Add( new MonthList ("May","5","May"));<br />
month.Add( new MonthList ("June","6","Jun"));<br />
month.Add( new MonthList ("July","7","Jly"));<br />
month.Add( new MonthList ("August","8","Aug"));<br />
month.Add( new MonthList ("September","9","Sep"));<br />
month.Add( new MonthList ("Otocber","10","Oct"));<br />
month.Add( new MonthList ("November","11","Nov"));<br />
month.Add( new MonthList ("December","12","Dec"));<br />
return month;<br />
}<br />
}<br />
<br />
private struct MonthList<br />
{<br />
public MonthList(string desc,string monthNo, string shortdesc)<br />
{<br />
this._desc = desc;<br />
this._number = monthNo;<br />
this._shortdesc = shortdesc;<br />
}<br />
<br />
private string _desc;<br />
private string _number;<br />
private string _shortdesc;<br />
<br />
public string monthDesc ...<br />
public string monthNo ...<br />
public string shortDesc ...<br />
}<br />
in the form ..
<br />
private void init_cboMonth()<br />
{<br />
stdData stdData = new stdData();<br />
ArrayList month = stdData.getMonthList();<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
}<br />
So what is goinf wrong ? thanks.
|
|
|
|
|
kakarato wrote:
So what is goinf wrong
Simple, you defined getMonthList() as static, but then tried to call it on an instance
stdData stdData = new stdData();<br />
ArrayList month = stdData.getMonthList();<br />
<br />
this.comboMonth.DataSource = month;<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
try this instead
this.comboMonth.DataSource = stdData.getMonthList();<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
this.comboMonth.ValueMember = "monthNo";
|
|
|
|
|
Thanks for help but an Error Message come out at the same line. The error message is :
"Could not bind to the new display member."
If i take out the line "this.comboMonth.ValueMember="monthNo"
something strange is display in the combo box ..
In the combox box it will display "XYZ.Model.Monthlist",
where the XYZ.Model is the namespace.
<br />
this.comboMonth.DataSource = stdData.getMonthList();<br />
this.comboMonth.DisplayMember = "monthDesc";<br />
|
|
|
|
|
Hi, how can I access, windows forms properites by other thread than the form.
I have this exception when try to read or modify an lisview property:
InvalidOperationException.
Cross-thread operation not valid: Control 'MyListView' accessed from a thread other than the thread it was created on.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|