Skip to main content

Microsoft Silverlight

Answered Question can anyone solve this problem??RSS Feed

(0)

viral0028
viral0028

Member

Member

23 points

161 Posts

can anyone solve this problem??

 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
ken tucker

All-Star

All-Star

16276 points

2,479 Posts

Re: can anyone solve this problem??

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?

viral0028
viral0028

Member

Member

23 points

161 Posts

Re: can anyone solve this problem??

 Thx for Replying

 Please see the Error 

here

 

http://www.MegaShare.com/1579577

viral0028
viral0028

Member

Member

23 points

161 Posts

Re: Re: can anyone solve this problem??

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 Tang - MSFT
Min-Hong...

Contributor

Contributor

3376 points

377 Posts

Re: Re: can anyone solve this problem??

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

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

viral0028
viral0028

Member

Member

23 points

161 Posts

Re: Re: can anyone solve this problem??

@ Min-hong Tang-MSF

Hi...Thx for Replying.

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....

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3376 points

377 Posts

Answered Question

Re: can anyone solve this problem??

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.

Best Regards

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

viral0028
viral0028

Member

Member

23 points

161 Posts

Re: can anyone solve this problem??

 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.?

 

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3376 points

377 Posts

Re: can anyone solve this problem??

Hi,

   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?

Best Regards 

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

viral0028
viral0028

Member

Member

23 points

161 Posts

Re: can anyone solve this problem??

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

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities