|
In a WinForms project, the Application.Run method can receive a Form parameter which becomes the main form of the application. According to the documentation, an ApplicationContext is automatically created.
My question is, is it possible to get a reference to the MainForm of the application or the ApplicaitonContext that is automatically created?
Thanks,
Dan...
|
|
|
|
|
I'm not sure I understand exactly what you want to do, but the default Main() code looks like:
[STAThread]
static void Main()
{
Form1 form = new Form1();
Application.Run(form);
}
So the reference exists at that point. Obviously from within Form1, you have a reference with "this". The main questions would be - (1) where do you want to reference it? and (2) what specifically do you want to do with it?
|
|
|
|
|
Well, I am trying to access the MainForm of the application from another form. So, I just decided to pass the MainForm as a parameter in a method of the other form.
Thanks,
Dan...
|
|
|
|
|
Hi,
after some setup's i have assemblies registered in my gac which i cannot remove. If i try to remove them i get a error messsage. How to get rid of assemblies in the gac which are no longer on the system, only the gac entry exists?
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
What kind of error message do you get? How are you trying to remove them? Are you using the gacutil.exe tool?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hi,
Are you getting an error about an assembly in use when you run gacutil /u [assembly]?
I've had the same problem, and I found the answer on a forum somewhere. Every time I used gacutil /u I was told the assembly was in use, even if I had only just added it...
Sounds crazy, but apparently installing microsoft messenger 6 is what breaks this.
Check if you have a value in the default value in your registry under:
in HKLM\SOFTWARE\Classes\Installer\Assemblies\Global
Delete the data for the default value of this key, and you should be set.
|
|
|
|
|
Hi,
How can I add items in a ListBox ?
Regards,
Matthieu
|
|
|
|
|
|
The second method is set_DataSource but I have some problems with refreshing it's content during work (thread above)
Mickey
|
|
|
|
|
i have installed the 2002 version of vs.net. i recently installed the .net framework 1.1... will now my vs.net run with the framework 1.1? do i have to remove framework 1.0?
thanks
nhm
|
|
|
|
|
VS 2002 won't run with Framework 1.1.
Free your mind...
|
|
|
|
|
Aaargghh...don't even try that.
1) If you have both frameworks installed, 1.1 is useless, vs.net only runs with 1.0.
2) If you uninstall 1.0 and try running vs.net, it cannot open any project.
3) If you overwrite the SDK with the new SDK for 1.1, vs.net won't find a compiler.
In case 1, you can uninstall 1.1, because vs.net does not recognize it. In case 2 and 3 you have to re-install vs.net 2002.
If you want to use 1.1, you have to use a free IDE (or buy vs.net 2003).
|
|
|
|
|
I'm writing a Windows Service that needs to interact with websites, but of course, Windows Services don't like ActiveX controls or forms being used. The service needs to be able to go to a website, inject values in to fields, command buttons or links to be clicked, etc. I know how to do this using the AxWebBrowser control, but can it be done somehow with the System.Web.WebClient class? Any ideas?
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
I'm not exactly sure what you're trying to do, but if you're basically filling out a form on the web site and then submitting it, it's easier to just do the posting directly instead of hosting an AxWebBrowser.
For instance, if the web site has a <FORM> in it, figure out where (URL) the submit button sends the form data, and figure out the names of all the controls on the page (<INPUT>'s). Once you have all of that, use something like the System.Net.WebClient.UploadValues method to post that data to the server and read the response.
If the site requires you to login and it uses cookies for session information, make sure you set up a cookie collection in your original requests to store the cookies you get back.
I once wrote a program that parsed the Project Gutenburg copy of Moby Dick and proceeded to post it chapter by chapter to a "spam" forum that someone created for fun. If you're doing something similar to what I've described (not necessarily spamming, but filling out a form etc.) and have more questions, feel free to respond.
|
|
|
|
|
If the site does require you to login. How do you send the cookie back? The cookie file stored on disk is encrypted. How do you know what values are required to be sent in cookie? Or, is there a method to send back the cookie file stored on disk? Do you think it would work this way?
Thank you.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Take a look at the CookieContainer property on the HttpWebRequest class.
Basically, you start the process by creating a HttpWebRequest. When you get the response back (an HttpWebResponse), it will have a property called Cookies.
On every HttpWebRequest after that, make sure and add those cookies to the CookieContainer property.
In summary, you use HttpWebRequest to post your login credentials however the login form wants it. You get a HttpWebResponse back that has the cookies in it. From there on out, you send those cookies out in every request.
I hope that makes sense...
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I'm having a wierd issue where i run a query in a thread and the while(Connection.read()) duplicates my results. Anyone else have this issue? For isntance if I have TestTable with the following values:
TestID
1
2
3
It will console.writeline
1
1
2
2
3
3
Below is sample code:
private void button3_Click(object sender, System.EventArgs e)
{
ThreadStart DBThread = new ThreadStart(StartDBDelegate) ;
Thread DB = new Thread(DBThread) ;
DB.Start();
}
public void StartDBDelegate)()
{
Invoke(new UpdateLoadTableDelegate(RunUpdateNow));
}
public void RunUpdateNow()
{
string source =
"server=testserver;uid=testuid;pwd=testpassword;database=TestDB";
string selectconn1 = "SELECT TestID as dbTestID FROM TestTable"
SqlConnection conn1 = new SqlConnection(source);
conn1.Open();
SqlCommand executeconn1 = new SqlCommand(selectconn1,conn1);
SqlDataReader Connection1 = executeconn1.ExecuteReader();
while(Connection1.Read())
{
Console.WriteLine (Connection1[0].ToString())
}
}
I can reduce this menace by doing the following to the while loop, although I shouldnt have to do this...this is really bugging me. It doesnt do this outside of the thread.
string strTestID = "";
while(Connection1.Read())
{
if(strTestID != Connection1[0].ToString()))
{
Console.WriteLine (Connection1[0].ToString())
strTestID = Connection1[0].ToString());
}
}
|
|
|
|
|
hi..can some one tell me is there any case such that when i can write a class having a zero-argument, one-argument and two-argument constructors. Then create only one object of the class such that firstly the two-argument constructor, then one-argument constructor and lastly zero-argument constructor should get called.
if there is, how can i do that? in what scenario do i need to do that?
tks for any help...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
public class AClass
{
public AClass()
{
}
public AClass(int arg1) : this()
{
}
public AClass(int arg1, string arg2) : this(arg1)
{
}
}
Constructor 1 is called afte constructor 2 is called, and constructor 2 is called after constructor 3 is called.
|
|
|
|
|
You have it backwards, constructor 1 is called before constructor 2, and 2 before 2.
You want:
class Foo {
public Foo() : this("sensibledefaultvalue") {}
public Foo(string arg1) : this(arg1, "otherdefaultvalue") {}
public Foo(string arg1, string arg2) {
}
}
Typically no code is ever added to the first two constructors with this style, they exist only to provide polymophism and default values.
-Blake
|
|
|
|
|
can u pls help me to explain..in what scenario's do we need to do such things???
i mean...is there any case where this is the only way out??
is this kinda stuff common??
never seen anything such as this in my life...
can u pls take some time to explain any such SCENARIOS where above code is DEFINETLY REQUIRED please????
tks a lot...
really appreciate you guys help...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
It's never required, it is just the most convenient way to express a common idiom.
Often there are several possible optional values that you might accept to control the construction of your object. Equally often, you want to provide more convenient constructors that provide some reasonable default for some or all of those values.
You do this by writing the constructor once, taking all the arguments as parameters. Then you write empty constructors that take fewer arguments, provide the defaults, and pass the call off to the larger constructor.
-Blake
|
|
|
|
|
hi Mr.Blake...
your answer was a bit too technical for me and i didnt really get it....
would u kindly help me a bit more and gimme some links or explanation in simple words where can i use this kinda stuff and where do i need it??
tks a lot...
appreaciate your time and help
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Another example:
You have a class which describes a task:
public class task {
public task(string name, DateTime date, int priority) {
//DoSomething
}
}
No someone really often creates those objects with Priority 2 but doesnt want to always pass this in. So we declare another constructor
public task(string name, DateTime date) : base(name, date, 2)
{
}
To quickly add tasks we want another constructor to create tasks with Priotity 2 and 'Today' as the date. So we declare another constructor:
public task(string name) : base(name, DateTime.Now)
{
}
Now you have the choice to call the full constructor with all possible arguments, or you just call one of the other constructors to decrease the writing. Another plus is, that you can change the default priority in one place.
Greetings Robert
|
|
|
|
|
Is it possible, using XML/SOAP web services, to perform a 3-way communication, namely, REQUEST, RESPONSE, and ACK?
Client sends the REQUEST, receives the RESPONSE, and send an ACK to the server to acknowledge the receive of the response.
If not, that could be a good project and/or subject of article, do you think?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|