Skip to main content
Home Forums General Silverlight Getting Started can anyone solve this problem??
10 replies. Latest Post by viral0028 on November 13, 2009.
(0)
viral0028
Member
23 points
161 Posts
10-30-2009 7:07 AM |
Hi...
i made a silverlight mail application. In this when ever i make my web services as starts page it works successfully...
but when ever i call this web services in silverlight application.,& make my desgin page it 's give me en error...
Please see this error here...
http://www.MegaShare.com/1579577
& page codeing is
using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.ServiceModel; namespace SL2Mail { public partial class Page : UserControl { public Page() { InitializeComponent(); sendButton.Click += new RoutedEventHandler(sendButton_Click); } void sendButton_Click(object sender, RoutedEventArgs e) { BasicHttpBinding bind = new BasicHttpBinding(); EndpointAddress endpoint = new EndpointAddress("http://localhost:50976/SL2Mail_Web/MailService.asmx"); ServiceProxy.MailServiceSoapClient mailSrv = new SL2Mail.ServiceProxy.MailServiceSoapClient(bind, endpoint); mailSrv.SendMailAsync(fromEmailAddressTextblock.Text, toEmailAddressTextbox.Text, subjectTextbox.Text, bodyTextbox.Text); mailSrv.SendMailCompleted +=new EventHandler<SL2Mail.ServiceProxy.SendMailCompletedEventArgs>(mailSrv_SendMailCompleted); } void mailSrv_SendMailCompleted(object sender, SL2Mail.ServiceProxy.SendMailCompletedEventArgs e) { if (e.Result) { resultTextBlock.Foreground = new SolidColorBrush(Colors.Blue ); resultTextBlock.Text = "Your email has been sent successfully!"; resultTextBlock.Visibility = Visibility.Visible; } else { resultTextBlock.Text = "Sending failed. Please try again."; resultTextBlock.Foreground = new SolidColorBrush(Colors.Red); resultTextBlock.Visibility = Visibility.Visible; } } } }
thx in advance...
ken tucker
All-Star
16276 points
2,479 Posts
10-30-2009 8:43 AM |
viral0028: mailSrv.SendMailAsync(fromEmailAddressTextblock.Text, toEmailAddressTextbox.Text, subjectTextbox.Text, bodyTextbox.Text); mailSrv.SendMailCompleted +=new EventHandler<SL2Mail.ServiceProxy.SendMailCompletedEventArgs>(mailSrv_SendMailCompleted);
I would reverse these 2 lines of code. The completed event handler should be added before you make the call.
What error do you get?
10-30-2009 9:05 AM |
Thx for Replying
Please see the Error
here
10-30-2009 9:31 AM |
http://blogs.silverlight.net/blogs/msnow/archive/2008/10/20/silverlight-tip-of-the-day-63-how-to-monitor-http-traffic-for-errors.aspx
10-30-2009 9:48 AM |
Thx Ken Tucker...
But.....
Yeah i see that...but explain me about more....may be I forgot to include a client access policy and cross domain file. As a result I got the following exception when attempting to browse to my application
Please see it...................................................
http://www.MegaShare.com/1579813
Now what i do.....?????
Thx,, Agian.
Min-Hong...
Contributor
3376 points
377 Posts
11-03-2009 10:55 PM |
Hi Viral,
I am afraid your domain has expired, and i can not see the error message you are facing. You may upload your project to skydrive.live.com so that we can reproduced and find out a solution.
Or you can provide more information here so that we can figure out what you are dealing with.
Here is my suggest : you may check that if your silverlight application can access your wcf service properly first. If your wcf service is ok then it must be a client side problem. You need to use fiddler to monitor those outgoing and incoming messages.
Best Regards
11-04-2009 12:08 AM |
@ Min-hong Tang-MSF
Well..i upload my whole application in Sky-drive..Please see this Project.
http://cid-ceecabec8dfa2acc.skydrive.live.com/browse.aspx/.Public?uc=1&lc=16393
( i cannot put my E-mail address & Password in web config file.if possible then kindly use your e-mail address for testing)
Please make starts page my silverlight application page. & try to send mail form this page)
Thx for your time....
11-04-2009 6:03 AM |
Hi,
I have downloaded your project and successfully got it to work. Meanwhile i encountered two problem one is like this:
The server response was: 5.5.1 Authentication Required
The other is like this:
Server does not support secure connections
I do not know if you encountered them. Anyway here is how i solve them.
Problem 1: I changed the web.config's setting about the email address,username and password. (I changed it to use my own email address to test). Problem solved.
Problem 2: I set the smtpClient.EnableSsl to false. Then problem solved.
11-04-2009 7:33 AM |
hi...
Thx for help...
But did u Make My XAML page as Starts page & U enter value from this page to send a E-mail.?
11-04-2009 9:08 PM |
Nope, since we are using different version of Visual Studio i have to convert the project. And i just copied your code to my own silverlight application. But i used your send logic and exactly the same mail service(without a slight change).
And based on my knowledge , since i use the same code in xaml and codebehind , the different page should not effect the out come ,shouldn't it?
11-13-2009 8:55 AM |
when i make my xaml page as starts page it cannot be work why?
i got error this..
! Communication Exception was unhandled by user code
An error occurred while trying to make a request to URI 'http://localhost:50976/SL2Mail_Web/MailService.asmx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Please can anyone solve this .........
thx