|
You are absolutely right about your new property Client hiding the base class' Client identifier. Either change your property name, or place the new keyword in the property definition.
public new TcpClient Client{... Here[^] is some more info on the subject.
Jim Stewartα:geek Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
monrobot13 wrote:
public TcpClient Client {
get { return Client; }
set { Client = value; }
}
You are going to have another problem here.
The property Client, is calling itself for the get/set methods, so you will wind up getting a StackOverflow from all of the recursion that takes place.
If you want your new Client property to return the value from the base class, then you need to specify, base.Client otherwise you need to rename the variable Client so you don't get this infinite recursion.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Thanks for the response James.
James T. Johnson wrote:
The property Client, is calling itself for the get/set methods, so you will wind up getting a StackOverflow from all of the recursion that takes place.
I took your adivce and renamed the property to something else, but I'm still getting a StackOverflow. Any ideas as to why?
If I step through the code it keeps executing the set method, but I have no idea why, would it be possible for you to explain.
Thanks again.
- monrobot13
|
|
|
|
|
Is CSharp similar to C like in variables, conditions, pointers, etc.
Can you tell me what is diferent that way i can learn more faster.
Thanks.
|
|
|
|
|
Here[^] is the "Getting Started" section in MSDN. It has several links to the introductory material for C#.
Jim Stewartα:geek Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
I can't find it
|
|
|
|
|
I want to build a C# app that wraps other executables. Any suggestions?
|
|
|
|
|
If you are trying to run an external process you need to look at the System.Diagnostics.Process class and use the Process.Start() method.
quorum pars magna fui
|
|
|
|
|
Thanks, Chris,
This is what I was hoping for. I want to build a service that monitors an application, detects problems, shuts it down, cleans things up, and then re-starts the application. At first I was wondering why this capability was under System.Diagnostics - but in the context of what I want to use it for, it makes perfect sense.
Sean Onion
|
|
|
|
|
Glad to help. There may be a similar app here on CP. Try searching the site using the google advanced search pointed here.
quorum pars magna fui
|
|
|
|
|
Hey i was wondering if anyone could give me a link or book name that has C#/DirectX 9.0 tutorials.
Yes, Shock I know you are doing them here but I have already done them and figured out DirectInput and was hoping for a more fast paced tutorial. I can help wiht DInput if you like.
|
|
|
|
|
I have a TextBox that is part of a control (toolbar) that is part of another
control (an Explorer band object); no forms involved. This TextBox is
defined thus:
this.searchTextBox.Location = new System.Drawing.Point(48, 24);
this.searchTextBox.Name = "searchTextBox";
this.searchTextBox.Size = new System.Drawing.Size(168, 20);
this.searchTextBox.TabIndex = 4;
this.searchTextBox.Text = "";
does not process the Backspace key. Another TextBox that is part of a
dialog box does function correctly, defined thus:
this.urlTextBox.Location = new System.Drawing.Point(8, 8);
this.urlTextBox.Name = "urlTextBox";
this.urlTextBox.Size = new System.Drawing.Size(232, 20);
this.urlTextBox.TabIndex = 0;
this.urlTextBox.Text = "";
Both were defined by the Designer, nothing fancy.
Why is the Backspace key not handled automatically in the first case? What
do I have to do to make it work? Interestingly, the Delete key does work
fine.Also interestingly, when I press the Backspace key, only the KeyUp
event is fired, not also the KeyDown and KeyPress events like most other
keys. Even if I wanted to manually handle the Backspace key within a KeyUp
event hander, I have no idea how to locate the position of the caret within
the TextBox's string. Of course, it'd be far preferable to have the TextBox
behaving normally.
Thanks,
Arun
|
|
|
|
|
So I came up with a mediocre workaround, using the OnKeyUp event handler:
private void searchTextBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Back)
{
if (searchTextBox.SelectionLength > 0)
searchTextBox.SelectedText = "";
else if (searchTextBox.SelectionStart > 0)
{
int caret = searchTextBox.SelectionStart;
searchTextBox.Text = searchTextBox.Text.Substring(0, caret - 1) +
searchTextBox.Text.Substring(caret);
searchTextBox.SelectionStart = caret - 1;
}
e.Handled = true;
}
}
I don't think it's a great workaround because it seems to be handled in a sluggish way. Plus, I can't hold down the Backspace key and have it delete a whole bunch of characters in a row like I can with the Backspace key.
Strangely, for this instance of the TextBox control, the Backspace key is not handled by the KeyDown or KeyPress events, unless modified by another key (e.g., Control, Shift, Alt).
Any tips would be great.
|
|
|
|
|
Hi
This one has me completely confused. What is the correct way of doing this? I have some "rules" I want to stick with.
- Designer support
- Object must be a singleton
Now these 2 are conflicting
Here's my possible solution:
public class Singleton : Component
{
private static SingletonInternal instance = null;
private static int instancecount = 0;
private class SingletonInternal : IDisposable
{
public void SomeMethod()
{
}
public void Dispose()
{
}
}
public Singleton()
{
if (instance == null)
instance = new SingletonInternal();
instancecount++;
}
public void SomeMethod()
{
instance.SomeMethod();
}
protected override void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
}
instancecount--;
if (instancecount == 0)
instance.Dispose();
this.disposed = true;
}
}
}
Is this the way to go? All comments welcome
Cheers
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
I think you want something along these lines...
public class Singleton : Component
{
private Singleton m_instance = null;
private Singleton(){} // constructor is private so it can't be created externally
public static Instance()
{
if(!m_instance)
m_instance = new Singleton;
return m_instance;
}
}
Your instance counting and dispose logic should still work. To use it, you dont create a new Singleton, but rather use Singleton s = Singleton.Instance();.
-pete
|
|
|
|
|
pete mcquain wrote:
private Singleton(){} // constructor is private so it can't be created externally
That is where it wont work in a designer...
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Hello,
I'm using the webbrowser control in an application where the crawling is totally automated.
The problem is that sometimes the browser try to crawl an archive file or whatever. In that case a security alert dialog box pops up and my webbrowser control waits for this dialog to close.
I already succeded removing all Javascript dialogs by implementing the IDocHostShowUI interface and by putting the control into the "silent" mode (put_silent()).
I also implemented the IDocHostUIHandler to return S_OK or S_FALSE wherever possible to get rid of a maximum of MSHTML UI unwanted behaviours.
But I still get this security alert dialogs and I have no ideas of how to avoid them.
The only solution I found for the moment is to filter the links the webbrowser control can crawl in a page by removing files containing 'zip','rar','mp3','jpg','gif'... And so on.
But this solution is not perfect because of the number of possible file types and because sometimes you can't even guess what it is from the URL.
If only the webbrowser control could allow me to access the HTTP file headers before display, to guess what it is from the content-type !
But even if I can filter the URL I crawl, I would really like a solution to remove the security alert dialogs.
I also tried to tweak the Internet Explorer options to avoid prompts and dialogs but I didn't solve this problem.
Any idea ?
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
GriffonRL wrote:
But even if I can filter the URL I crawl, I would really like a solution to remove the security alert dialogs.
I also tried to tweak the Internet Explorer options to avoid prompts and dialogs but I didn't solve this problem.
If you have an automatic crawler, why should you have anything displayed while you are crawling ? If you have anything displayed, Internet Explorer runs in "interactive" mode, and I believe ActiveX security boxes are hardwired in this mode.
It is possible to use Internet Explorer like a COM dll : see a MSDN sample called "WalkAll".
|
|
|
|
|
Hello Stephane,
If I am right WalkAll use MSHTML only not the WebBrowser control.
The problem if that I lack a lot of features if I use MSHTML instead of the WebBrowser control. I would need to implement all the navigation stuff and more.
Moreover, even if this is an antomatic crawler, I sometimes switch to some manual control.
Nevertheless thanks for the answer.
Any other idea ?
Regards,
R. LOPES
Just programmer.
|
|
|
|
|
GriffonRL wrote:
If I am right WalkAll use MSHTML only not the WebBrowser control
Yes, I would use monikers to get the content pointed by the URL, retrieve the data then throw it at an actual web browser instance (where I would simply do a IPersistFile->Load(...) or something like that).
The fact that you see the data makes you have the opportunity to strip off all messing tags, if required. (you need an html parser).
GriffonRL wrote:
Any other idea ?
Become a hacker . You have to find the way to make the Internet Explorer temporarily switch to low-security mode, where ActiveX and stuff are all ok.
|
|
|
|
|
I hope you will not laugh but I have some problems regarding a very simple applications...
I have an application which requiers the user to logon supplying a username and a password.
That is done by the first Form (frmLogin).
If the user supplies the correct logon information I have to:
- open a new Form with the Application itself (frmApp)
- close the logon form (frmLogin)
The problem is that after I make the Application Form visible (frmApp) and eventualy want to close it, it dissapears from the screen but the application is still running on the background (a processes is still active in the task manager).
Can you help me?
Thanks in advance,
Vlad Mihai
|
|
|
|
|
when you want to quit the program, do this.
Application.Exit();
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Vlad,
How are you closing the Application? Are you just using frmApp.Close()? This may be the source of your issue. Try using Application.Exit() instead. This will tell all message sources in your app to terminate and will close all open windows of your app.
Good luck.
quorum pars magna fui
|
|
|
|
|
Thanks guys...
There is a problem though. I am a newbye and used only to Java
In java there was an event called Window.Closing associated to the closing of the Window (that X in the top-right corner )
Is there something like this in C# ?
My application was supposed to close when i clicked on that X of the Form.
How can I associate then this X with Application.Exit?
Thanks again
|
|
|
|
|
Yes.
In C# you use delegates to register your event handlers. It looks and works a lot like java.
this.Closing += new System.EventHandler(yourClosingMehtod);
where yourClosingMehtod should have a signature like
yourClosingMehtod(object sender, EventArgs e)
quorum pars magna fui
|
|
|
|