locked
Target Invocation Exception ( Web Exception ) RRS feed

  • Question

  • I am currently testing ADO.NET sync service.

    I have 5 tables and i did not put any foreign key between them for the testing purpose.

    When I synced b4 inserting any record to local CE, synchronization worked.
    It showed me the statistics of how many records have been uploaed and downloaed.
    But
    after inserting records to 5 tables in LocalCE and I synced, i am getting "TargetInvocation" Exception and Inner Exception is "WebException".

    When I checked sql profiler, none of the sync commands got executed.

    Any reason?

    Thanks in advance for ur cooperation.

    Regards
    Bo bo
    • Moved by Hengzhe Li Friday, April 22, 2011 3:11 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, May 22, 2009 2:16 AM

Answers

  • Hi Phil

    Changing to ASP.NET Web Service solved the problem.
    I tried to sync with as many photos and it had no problem at all.

    What I did was I just copied all syn adapter classes and server provider class which were generated by VS Designer in WCF
    to ASP.NET web service. It worked perfectly for now.

    But I dont know if it is right to do or not.

    Any comment?

    Regards
    Bo Bo
    • Marked as answer by Bo Bo Lwin Friday, May 29, 2009 3:46 AM
    Friday, May 29, 2009 3:18 AM

All replies

  • Update :

    Out of 5 tables, 1 table have Image DataType. The problem is in that table.
    Without images, Synchronization works fine.
    But when synced with Image Data Type, I have the problem.

    the following is my code snippet :
    I take the picture with the Mobile and save in the bitmap type.
    After that i convert that picture into byte array and save it to " photodata.Photo " which is a byte[] array type.

    Bitmap bmp = new Bitmap(cameraCaptureDialog.FileName);
    MemoryStream stream = new MemoryStream();
    bmp.Save(stream,System.Drawing.Imaging.ImageFormat.Bmp);
    photodata.Photo = stream.ToArray();
    obj[] imageData = new object[0];
    imageData[0] = photodata;

     

     


    I get a few objects like that.
    Later ... I loop through image data array like this to insert into local CE.

    foreach (PhotoData obj in imageData)
    {
    if (obj != null)
    {
    SqlCeCommand cmdImage = new SqlCeCommand();
    cmdImage.Connection = conn;
    cmdImage.Transaction = transaction;
    cmdImage.CommandType = CommandType.Text;
    cmdImage.CommandText = "Insert into [Photo](photo) values (@photo)";
    cmdImage.Parameters.Add("@photo", SqlDbType.Image).Value =obj.photo;
    cmdImage.ExecuteNonQuery();
    }


    After that I do the synchronization as usual. That s where i got target invocation exception.


    Thanks & Regards
    Bo Bo

     

     

    Friday, May 22, 2009 7:56 AM
  • Could you provide more details on the exceptions you are getting and where they are occurring?

    Thanks,
    Phil
    Tuesday, May 26, 2009 4:30 PM
  • Hi Phil,

    After testing so many times, I found out that the image size is 64KB and if I take more than one photos and
    do the synchronization, I have got that error. The inner message is "WebException" only.

    Is that the limitation of ADO.NET Synchronization Service?


    Note: I hosted my WCF service on IIS already.

    Thanks in advance.
    Bo Bo

    Wednesday, May 27, 2009 6:11 AM
  • This seems like a transport layer issue.  If you remove the WCF service and try a 2-tier approach of directly syncing to the DB do you experience this issue? 

    Thanks-
    Phil
    Wednesday, May 27, 2009 5:13 PM
  • Because I am testing for mobile application and 2-tier approach is not the one for me.
    I definitely have to go n-tier approach.
    What about asp.net web service?
    I will try to change WCF to ASP.NET this weekend and update you.

    Thanks for the reply.
    Appreciate that.

    Regards
    Bo Bo

    Thursday, May 28, 2009 1:18 AM
  • Can you paste the complete TargetInvocationException with the inner exception and stack trace?
    Thanks
    Mahesh
    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    Thursday, May 28, 2009 7:36 PM
    Moderator
  • Hi Mahesh,

    The following is my inner exception.


    Stack Trace -

       at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at ProxiHomesv1._0.Wcf.ProxiHomesDataCacheSyncService.ApplyChanges(SyncGroupMetadata groupMetadata, DataSet dataSet, SyncSession syncSession)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

    Message - WebException

    [System.Net.WebException] -> Status - Protocal Error


    Regards
    Bo Bo

    Friday, May 29, 2009 2:14 AM
  • Hi Phil

    Changing to ASP.NET Web Service solved the problem.
    I tried to sync with as many photos and it had no problem at all.

    What I did was I just copied all syn adapter classes and server provider class which were generated by VS Designer in WCF
    to ASP.NET web service. It worked perfectly for now.

    But I dont know if it is right to do or not.

    Any comment?

    Regards
    Bo Bo
    • Marked as answer by Bo Bo Lwin Friday, May 29, 2009 3:46 AM
    Friday, May 29, 2009 3:18 AM