|
Hi Russ,
Bothe applications are running on the same machine. As I don't know the channel informations, I cannot use remoting as well as I cannot modify the application. I would like to know is there any method similar to "GetActiveObject" available for this?
Thanks
Diana.
|
|
|
|
|
When an exception is thrown in my application I use a PropertyGrid to dynamically show the exception to the user, allowing him to inspect all details.
I also log the exception to a log file (through LOG4NET).
Now I would like to be able to not only log the standard properties of the catched base Exception object but also any (nested) properties of derived exceptions (e.g. the Response property of a WebException and therein the ResponseUri property of that Response property).
Question: How can I do this in a "generic" way?
I already started doing some simple reflection but didn't manage to detect the type of the property and to decide whether to dig deeper or simple to call and output the ToString() method.
Any hints, please?
|
|
|
|
|
Hello,
I'm not sure if I complettly understand the complexity of your question.
I'm using Reflection in combination with Cloning of UserControls, where I whant to get the public properties values.
Works like this:
using System.ComponentModel;
PropertyDescriptorCollection pdcMyControl = TypeDescriptor.GetProperties(MyControl);
foreach(PropertyDescriptor pdMyControl in pdcMyControl)
{
System.Type pd_typ = pdMyControl.PropertyType.GetInterface("ICollection");
if (pd_typ != null)
{
ICollection ItemsMyControl = pdMyControl.GetValue(MyControl) as ICollection;
foreach (object obj in ItemsMyControl)
{
}
}
else
{
}
}
Maybe it helps!
All the best,
Martin
|
|
|
|
|
- To get all the properties of a type, use the
Type.GetProperties() method. Pass in the following binding flags: Instance , Public , FlattenHierarchy . This makes sure that only public members that are instance rather than static are returned, and that inherited properties are included.
- To get the data type of a property use the
PropertyInfo.PropertyType method. - A simple way to see if a property's type is one of the basic types is to check if
Convert.GetTypeCode!=TypeCode.Object . - Watch out for circular reference paths! Check each time before you output an object's properties to make sure that the object isn't already currently being output.
- A property value may be part of a large object graph, and outputting the whole graph as text could bring the app to its knees. Consider limiting the recursion depth.
I've got some fairly nifty code for outputting object hierarchies, but I haven't tested it thoroughly. If you reply by email and give your email address, I can send it to you.
|
|
|
|
|
Hello All:
I'm using C#.Net.
I have three TextBox forms A,B,C waiting for the input from the user. I would like to
call the external application which will include these inputs parameter from user's Input from TextBox
A,B and C. Here is part of my code:
System.Diagnostics.Process proc; //Declare New Process
System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo();
procInfo.WorkingDirectory = "C:\\PushCase";
procInfo.FileName = "PushCase.exe";
procInfo.Arguments = tb_params.Text; // since I have three separates TextBox A,B,C. How do I make it into
// single parameter??
proc = System.Diagnostics.Process.Start(procInfo);
Thanks in advance!
|
|
|
|
|
You can use Process.Start, and put the parameters on the command line, comma seperated. Of course, the app you're calling needs to expect them, in that order.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
For ex., if you use internet explorer with a parameter
System.Diagnostics.Process.Start("IExplore.exe","http://10.109.25.15/TouchScreen/Test/index.htm");
|
|
|
|
|
Hello,
You just have to set a " " (space) between the Text properties.
Like this:
procInfo.Arguments = tbA.Text + " " + tbB.Text + " " + tbC.Text;
Your Arguments would be:
[STAThread]
public static void Main(string [] Args)
{
if(Args.Length == 3)
{
}
for(int x=0;x<=Args.Length;x++)
{
}
}
All the best,
Martin
|
|
|
|
|
Thank you guys for your help!
|
|
|
|
|
Thanks again Martin!
I have the following code:
System.Diagnostics.Process proc; //Declare New Process
System.Diagnostics.ProcessStartInfo procInfo = new System.Diagnostics.ProcessStartInfo();
procInfo.WorkingDirectory = "C:\\dc\\bin"; //
procInfo.FileName = "scu.exe";
procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " ";
proc = System.Diagnostics.Process.Start(procInfo);
I have a Browse button which is the user will select its parameter for "tb_params2.Text".
Question - If I wanted to have more than one parameter display on "tb_params.Text" TextBox when the user select multiple parameters from the Browse Button. What Common Control Box do I need to display a multiple selection??
Thanks again for ur help.
|
|
|
|
|
Hello,
Just for info:
Eyungwah wrote: procInfo.Arguments = tb_params.Text + " " + tb_params1.Text + " " + tb_params2.Text + " ";
I think that you don't need '+ " ";' this.
But now to your question:
The TextBox would be able to show multiline text if you take care of properties like "Multiline"(true) and "AutoSize"(false). You would have to add a new line between your selected texts.
Like:
tb_params.Text = stringselection1 + System.Enviroment.NewLine + stringselection2;
Instead I would recommend the ListBox.
The "Items" property is what you need there.
Like:
lb_params.Items.Add(stringselection1);
So if you have a collection of selected parameters you would do:
for(int x=0;x<selectedparams.Length;x++)
{
lb_params.Items.Add(selectedparams[x]);
}
All the best,
Martin
|
|
|
|
|
Thanks again Mark for your replied.
I have a Browse button. If I created Four TextBox form. Everytime I Browse and select the file
it always show the same file on all of those four TextBox. Here's my code:
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
tb_params2.Text = dlg.FileName;
tb_params3.Text = dlg.FileName;
tb_params4.Text = dlg.FileName;
tb_params5.Text = dlg.FileName;
}
My goal is to have a Browse button that would navigate by a user and selected any file, then it displays that file on "tb_params2.Text" TextBox individually.
I have created four TextBox and I wanted the file that was selected throught the Browse displayed on the TextBox accordingingly.. Could you please help me how to do that?
Thanks
|
|
|
|
|
Hello,
Is it a question of multi selection?
In this case you should make your code dynamic and hold the references of your TextBoxes in a Hashtable.
private Hashtable AllTextBoxes = new Hashtable();
AllTextBoxes.Add(0, textBox1);
AllTextBoxes.Add(1, textBox2);
}
private void button2_Click(object sender, System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiline = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
for(int x=0;x<AllTextBoxes.Count;x++)
{
TextBox actTB = AllTextBoxes[x] as TextBox;
if(x<dlg.FileNames.Length)
{
actTB.Text = dlg.FileNames[x];
}
else
{
actTB.Text = "";
}
}
}
}
If I didn't understand you right, please let me know.
All the best,
Martin
-- modified at 5:39 Thursday 1st February, 2007
|
|
|
|
|
I have windows application
when i log out from the application and login again
all values are pre filled in textboxes ans list boxes
i want that they get cleared when i logout
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
do i have to reset all the textboxes or is there also some other way to do it
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
I am doing like
txtbox1.clear();
textbox2.clear();
can i do it in one go with a single function for whole form
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
You can iterate over the controls collection and when you find textboxes or listboxes, clear them.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
can u give me sample code how will i do that
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Hello,
Just use a foreach over your Controls Collection.
foreach(Control c in this.Controls)
{
Label actlabel = c as Label;
if(actlabel != null)
{
actlabel.Clear();
}
else
{
ListBox actlistbox = c as ListBox;
if(actlistbox != null)
actlistbox.Items.Clear();
}
}
All the best,
Martin
|
|
|
|
|
Hello,
I am getting a C# compiler warning for using Thread.Suspend() and Thread.Resume() methods:
Warning 6 'System.Threading.Thread.Suspend()' is obsolete:
'Thread.Suspend has been deprecated. Please use other classes in System.Threading,
such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect
resources. http://go.microsoft.com/fwlink/?linkid=14202'
I'm implementing these thread methods in a safe environment, when only a single worker thread accesses the resources. This worker thread is performing a lenghty calculation so I wanted to have an option to suspend/resume this CPU intensive and lenghty calculation.
Is there any other simple way to accomplish this task? Monitor, Mutex, Event nor Semaphore don't seem to be an effective replacement for Suspend() and Resume().
Thanks much,
Michal Kreslik
|
|
|
|
|
Thread.Sleep(Timeout.Infinite) should halt the thread. you can then interrupt it if you want it to start doing things again.
HTH
Russ
|
|
|
|
|
OK, thanks, but Sleep() is a static method, so it's not possible to call this method on any thread other than the current one, correct?
That means that it's not possible to put a thread to sleep externally this way. Is that true or am I missing something?
Thank you,
Michal Kreslik
|
|
|
|
|
i think the aim of the changes to the resume and suspend methods was that code that executes outside a thread doesn't know what resources the thread is using.
If for instance there was a database transaction open in the thread that you are putting to sleep you could create chaos for all users of the application not just the specific instance that the thread is running in.
I think the general plan is to check for the state of a variable somewhere in your code
while(_running)<br />
{DoStuff();}<br />
else<br />
{<br />
ReleaseExpensiveResources();<br />
Thread.Sleep(Timeout.Infinite);<br />
}
This way the thread won't suspend immedeately but it will suspend cleanly when it releases.
Russ
|
|
|
|
|
Hi
I m developing a web portal in c# asp.net web application .i want to built an email client.My email client will include the functionalty as
Making new account
sending e mail with attachments
receiving email with inbox maintaing facility. etc
but i have not any idea about it. Can any one guide us first of all about the email server that which server should b used 2ndly how it can be used n from where v can get help regading its builtin methods to b used in email client.
v want help in C# not in HTML codin
Thanx
|
|
|
|
|
Hi
I m developing a web portal in c# asp.net web application .i want to built an email client.My email client will include the functionalty as
Making new account
sending e mail with attachments
receiving email with inbox maintaing facility. etc
but i have not any idea about it. Can any one guide us first of all about the email server that which server should b used 2ndly how it can be used n from where v can get help regarding its builtin methods to b used in email client.
v want help in C# not in HTML coding
Thanx
Fakhraz
|
|
|
|