Share Contract - Problems & attempts & Solutions

3,633 views

Published on

Published in: Health & Medicine, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,633
On SlideShare
0
From Embeds
0
Number of Embeds
1,109
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Share Contract - Problems & attempts & Solutions

  1. 1. Share contract By @saramgsilva Windows 8 Case study Problems & Attempts & Solutions
  2. 2. Share Contract Windows 8 By @saramgsilva I will use custom data format but could be another format.
  3. 3. Share Contract Windows 8 By @saramgsilva • Goals • Share Contract behavior • Expected behavior for general development • The source application • The target application • Problems & Attempts & Solution • Phase 1 • Phase 2 • Conclusion Summary
  4. 4. Share Contract Windows 8 By @saramgsilva Goals • Source Application o Share a custom data format (called MyDataFormatID) • Target Application o Received a custom data format (called MyDataFormatID) o Start the process o Do some steps (like navigation between pages but never return back) o Maybe in each step you can have a button for cancel the process o The process is only complete on the last page when you click done button • Implementing MVVM using MVVM Light Library
  5. 5. Share is a way in which users can quickly exchange data from one app to another. With share, the focus is on quick scenarios that the user can complete with another app while staying in their original app. Share Contract Windows 8 By @saramgsilva Share Contract behavior
  6. 6. Share Contract Windows 8 By @saramgsilva Share Contract behavior
  7. 7. Share Contract Windows 8 By @saramgsilva Expected behavior for general development • Navigation between pages: Frame.Navigate(typeof (MainPage));. • MVVM pattern :
  8. 8. Share Contract Windows 8 By @saramgsilva • MVVM Light • ViewModelLocalor in App.xaml • MainViewModel for a ShareTargetPage Expected behavior for general development
  9. 9. Share Contract Windows 8 By @saramgsilva Source Application • Page where the share is called:
  10. 10. Share Contract Windows 8 By @saramgsilva Source Application
  11. 11. Share Contract Windows 8 By @saramgsilva Target Application • Manifest:
  12. 12. Share Contract Windows 8 By @saramgsilva Target Application • In App.xaml.cs:
  13. 13. Share Contract Windows 8 By @saramgsilva Target Application • Active method in ShareTarget:
  14. 14. Share Contract Windows 8 By @saramgsilva Target Application • Active method in MainViewModel: I call • ReportStart • ReportDataRetrieved
  15. 15. Share Contract Windows 8 By @saramgsilva Target Application • The navigation in MainViewModel • The ShareOperation in MainViewModel I did not think much about it was provisional
  16. 16. Share Contract Windows 8 By @saramgsilva Source Application & Target Application knows the same data Note: I’m not focus in the schema of the custom data, it depend for each application. You can see more about it in: MSDN - Using schema-based formats.
  17. 17. Share Contract Windows 8 By @saramgsilva Problems - phase 1 1. Install source application (debug mode) 2. Install target application (debug mode) 3. Run source application and call the charm to share with target application I assume this happen because I did F5 for target application and then I close the application, but I did not stop the visual studio. I assume this because I started to do deploy only and it’s not happen.
  18. 18. Share Contract Windows 8 By @saramgsilva Problems - phase 1 I not sure if the both application are running in VS2012 or only the source application The errors were:
  19. 19. Share Contract Windows 8 By @saramgsilva Problems - phase 1
  20. 20. Share Contract Windows 8 By @saramgsilva Problems - phase 1
  21. 21. Share Contract Windows 8 By @saramgsilva Attempts - phase 1 My attempts for understand the problem: • Debugging to the Target application • Using the simulator • In Local machine It not works correctly and charm close all time. but I could sometimes • Logging to a file Failed because UnhandledException never occurs and in my steps I cannot catch the error. • Debug Options – check all • Read documentation and test samples, again!
  22. 22. Share Contract Windows 8 By @saramgsilva Attempts - phase 1 My attempts for understand the problem: • In source application subscribe the events • Destroyed • OperationCompleted • from data package • Note: sometimes I hit the Destroyed event!
  23. 23. Share Contract Windows 8 By @saramgsilva Problems - phase 1 Otherwise • Using only the Share Target Page with N user controls For each step change the visibility for the currents Return to the first code… continues to crash!
  24. 24. Share Contract Windows 8 By @saramgsilva Last attempt Create a project (Split Template) for a new target application: • Create N pages each page have 1 button and the page name • Try navigate between them Here I confirmed my opinion there is problem in navigation when I’m in the Share Charm
  25. 25. Share Contract Windows 8 By @saramgsilva Solution - phase 1 The Property lost the context In the share contract I cannot do this!!!! I did not know, all thinks that I read I did not found nothing about this
  26. 26. Share Contract Windows 8 By @saramgsilva Solution - phase 1 The right way: Do: var step2Page = new Step2Page(); step2Page.Activate(shareOperation); In the Active method do: Window.Current.Content = this; Window.Current.Activate();
  27. 27. Share Contract Windows 8 By @saramgsilva Problems - phase 2 Now I can navigate I still have problems • In debug mode, the application crash • I normal mode, I catch the errors
  28. 28. Share Contract Windows 8 By @saramgsilva Problems - phase 2 Error FailedQI was detected
  29. 29. Share Contract Windows 8 By @saramgsilva Problems - phase 2 FailedQI was detected Message: The call to QI for interface 'System.ComponentModel.PropertyChangedEventHa ndler' with IID '{50F19C16-0A22-4D8E-A089- 1EA9951657D2}' failed with HRESULT 0x80004002 (No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))). One likely reason this failed is that the object does not have a proxy/stub dll properly registered.
  30. 30. Share Contract Windows 8 By @saramgsilva Problems - phase 2 Error COM object that has been separated from its underlying RCW cannot be used This image is from the phase1 but this error still happen and is only images I have. I removed this! Only for see the message and object state.
  31. 31. Share Contract Windows 8 By @saramgsilva Problems - phase 2 This image is from the phase1 but this error still happen and is only images I have. I removed this! Only for see the message and object state.
  32. 32. Share Contract Windows 8 By @saramgsilva Problems - phase 2 I got this in phase 2
  33. 33. Share Contract Windows 8 By @saramgsilva Problems - phase 2 I got this in phase 2
  34. 34. Share Contract Windows 8 By @saramgsilva Problems - phase 2 • A method was called at an unexpected time. (exception from HRESULT 0x8000000E) Other errors: • UIASendMessageTimeOut I think it is because in the package I set a image but it is not correct I need to confirm
  35. 35. Share Contract Windows 8 By @saramgsilva Attempts Forum MSDN FailedQI was detected UIASendMessageTimeout failed InvalidComObjectException in the target application (Sharing) Contact to Laurent Bugnion (owner of the MVVM Light Library) about the FailedQI
  36. 36. Share Contract Windows 8 By @saramgsilva Reply FailedQI was detected InvalidComObjectException in the target application (Sharing) Laurent Bugnion want to know more about the error. Let’s do crash the target application…. An estrange think happens, I didn´t know, the errors: Occurs here: If I’m not wrong, InvalidComObjectException occurs in others places
  37. 37. Share Contract Windows 8 By @saramgsilva Reply InvalidComObjectException in the target application (Sharing) For me this error: Is something like the objects lost the context
  38. 38. Share Contract Windows 8 By @saramgsilva Solution – phase 2 I will remove the locator and the binding for each datacontext ViewModelLocator is a static resource
  39. 39. Share Contract Windows 8 By @saramgsilva Solution – phase 2 I did this In this case I don´t inject dependencies. I did my process for X times without close the source application and without an errors!! I was happy and I could not believe. 
  40. 40. Share Contract Windows 8 By @saramgsilva Conclusion Don´t use: Frame.Navigation Do: Active Page Don´t use: Static field/properties Cannot define the ViewModelLocator in App.xaml Cannot define the ViewModel using the binding for the DataContext Do: Initialize the ViewModel for each page in the constructor of the page I think: • The problem is not from MVVM Light • The developer do not expect this!
  41. 41. Share Contract Windows 8 By @saramgsilva Thanks SaraSilva geral@saramgsilva.com saramgsilva@gmail.com http://www.saramgsilva.com http://twitter.com/saramgsilva http://pt.linkedin.com/in/saramgsilva http://www.facebook.com/saramgsilva http://www.windowsphone.com/pt-PT/publishers/Sara%20Silva

×