Dilbert C# WebService

  • Thread starter Thread starter deciacco
  • Start date Start date
D

deciacco

What's wrong with this code?
It runs, but nothing happends.
Thanks!

***************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace DilbertADay
{
class Program
{
static void Main(string[] args)
{
DailyDilbert.DailyDilbert wsDd = new DilbertADay.DailyDilbert.DailyDilbert();
wsDd.DailyDilbertImageCompleted += new DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventHandler(DailyDilbertImageCompleted_Handler);
wsDd.DailyDilbertImagePathAsync();
}

static void DailyDilbertImageCompleted_Handler(object sender, DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventArgs args)
{
Console.Write(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}
***************************************************
 
What's wrong with this code?
It runs, but nothing happends.
Thanks!

***************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace DilbertADay
{
class Program
{
static void Main(string[] args)
{
DailyDilbert.DailyDilbert wsDd = new
DilbertADay.DailyDilbert.DailyDilbert();
wsDd.DailyDilbertImageCompleted += new
DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventHandler(DailyDilbertImageCompleted_Handler);
wsDd.DailyDilbertImagePathAsync();
}

static void DailyDilbertImageCompleted_Handler(object sender,
DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventArgs args)
{
Console.Write(System.Environment.GetFolderPath(Environment..SpecialFolder.DesktopDirectory));
}
}
}
***************************************************

What is DailyDilbert?

This code should give you an error since there is no class called
DailyDilbert defined here... or maybe it is defined beneath this code?

If such is the case, can you paste that code too?
 
My apologies...
DailyDilbert is a Web Reference to
http://www.esynaps.com/WebServices/DailyDiblert.asmx?WSDL
Thanks..

What's wrong with this code?
It runs, but nothing happends.
Thanks!

***************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace DilbertADay
{
class Program
{
static void Main(string[] args)
{
DailyDilbert.DailyDilbert wsDd = new
DilbertADay.DailyDilbert.DailyDilbert();
wsDd.DailyDilbertImageCompleted += new
DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventHandler(DailyDilbertImageCompleted_Handler);
wsDd.DailyDilbertImagePathAsync();
}

static void DailyDilbertImageCompleted_Handler(object sender,
DilbertADay.DailyDilbert.DailyDilbertImageCompletedEventArgs args)
{

Console.Write(System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
}
}
}
***************************************************

What is DailyDilbert?

This code should give you an error since there is no class called
DailyDilbert defined here... or maybe it is defined beneath this code?

If such is the case, can you paste that code too?
 
That is the entire program.cs file...
The reference shows up under the Solution Explorer under "Web References".
The solution builds without any errors and runs, but nothing happends.
In debugging it looks like the "DailyDilbertImageCompleted_Handler" never
gets called.
Thanks
 
That is the entire program.cs file...
The reference shows up under the Solution Explorer under "Web
References".
The solution builds without any errors and runs, but nothing happends.
In debugging it looks like the "DailyDilbertImageCompleted_Handler" never
gets called.
Thanks

Stefan Z Camilleri said:
Excuse my previous email, just found out what DailyDlbert is. Do you
have
a reference to it though? Am not seeing one

Hi, the file was not attached, yet in the meantime I came across this that
might help you

http://www.dotnetpowered.com/dailydilbert.aspx
 
Hi,
That is the entire program.cs file...
The reference shows up under the Solution Explorer under "Web References".
The solution builds without any errors and runs, but nothing happends.
In debugging it looks like the "DailyDilbertImageCompleted_Handler" never
gets called.
Thanks

First, the URL you give for the web service has a typo inside. Make sure
that it's not the case in the actual web reference.

http://www.esynaps.com/WebServices/DailyDiblert.asmx?WSDL
instead of
http://www.esynaps.com/WebServices/DailyDilbert.asmx?WSDL

(BTW, if you're in touch with the web service creator, you should tell
him that using tempuri.org as a namespace is not recommended).

Then, you call an asynchronous web service in the "main" method of the
Console application. However, after the request is sent, the application
terminates (when main is finished, the application ends). When the web
service comes back, the application is finished already.

To solve this, you can either call the service synchronously (in which
case, the application waits for the response before ending), or you have
to wait for the response yourself. If you want my advice, since this
seems to be a test application only, use a WinForms application instead
of a Console app.

HTH,
Laurent
 
If however you want to keep your application a console application, you could define a global boolean variable (isFinished), and use this to keep the main thread alive (while(!isFinished) until the asynchronous operation has completed (inFinished = true).

Best regards
Thomas

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
On its own, that would be a bad thing (even if you remembered to make
it volatile); a far better option would be something like a
ManualResetEvent, or you can actually do the same thing with just
Monitor if you want.

An even better option... if you aren't going to do anything else, then
don't make it async... unless of course that is completely out of your
control.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top