Share Contract - Problems & attempts & Solutions
-
Upload
sara-silva -
Category
Health & Medicine
-
view
2.929 -
download
3
description
Transcript of Share Contract - Problems & attempts & Solutions
Share contract
By @saramgsilva Windows 8
Case study
Problems & Attempts & Solutions
Share Contract Windows 8
By @saramgsilva
I will use custom data format but could be another format.
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
Share Contract Windows 8
By @saramgsilva
Goals• Source Application
o Share a custom data format (called MyDataFormatID)
• Target Applicationo 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
processo The process is only complete on the last page when you
click done button
• Implementing MVVM using MVVM Light Library
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
Share Contract Windows 8
By @saramgsilva
Share Contract behavior
Share Contract Windows 8
By @saramgsilva
Expected behavior for general development• Navigation between pages:
Frame.Navigate(typeof (MainPage));.
• MVVM pattern :
Share Contract Windows 8
By @saramgsilva
• MVVM Light
• ViewModelLocalor in App.xaml
• MainViewModel for a ShareTargetPage
Expected behavior for general development
Share Contract Windows 8
By @saramgsilva
Source Application• Page where the share is called:
Share Contract Windows 8
By @saramgsilva
Source Application
Share Contract Windows 8
By @saramgsilva
Target Application• Manifest:
Share Contract Windows 8
By @saramgsilva
Target Application• In App.xaml.cs:
Share Contract Windows 8
By @saramgsilva
Target Application• Active method in ShareTarget:
Share Contract Windows 8
By @saramgsilva
Target Application• Active method in MainViewModel:
I call• ReportStart• ReportDataRetrieved
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
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.
Share Contract Windows 8
By @saramgsilva
Problems - phase 11. 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.
Share Contract Windows 8
By @saramgsilva
Problems - phase 1I not sure if the both application are running in VS2012 or only the source applicationThe errors were:
Share Contract Windows 8
By @saramgsilva
Problems - phase 1
Share Contract Windows 8
By @saramgsilva
Problems - phase 1
Share Contract Windows 8
By @saramgsilva
Attempts - phase 1My 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!
Failed!
Failed!
Share Contract Windows 8
By @saramgsilva
Attempts - phase 1My attempts for understand the problem:
• In source application subscribe the events• Destroyed • OperationCompleted
• from data package
• Note: sometimes I hit the Destroyed event!
Cannot use this for share!
Share Contract Windows 8
By @saramgsilva
Problems - phase 1Otherwise
• 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!
Failed!
Share Contract Windows 8
By @saramgsilva
Last attemptCreate 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
Crash! Why????
Here I confirmed my opinion there is problem in navigation when I’m in the Share Charm
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
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();
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
Share Contract Windows 8
By @saramgsilva
Problems - phase 2
Error FailedQI was detected
Share Contract Windows 8
By @saramgsilva
Problems - phase 2
FailedQI was detectedMessage: The call to QI for interface 'System.ComponentModel.PropertyChangedEventHandler' 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.
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.
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.
Share Contract Windows 8
By @saramgsilva
Problems - phase 2
I got this in phase 2
Share Contract Windows 8
By @saramgsilva
Problems - phase 2
I got this in phase 2
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
Share Contract Windows 8
By @saramgsilva
AttemptsForum 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
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
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
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
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.
Share Contract Windows 8
By @saramgsilva
Conclusion
Don´t use: Frame.NavigationDo: Active Page
Don´t use: Static field/properties
Cannot define the ViewModelLocator in App.xamlCannot define the ViewModel using the binding for the DataContextDo: 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!
Share Contract Windows 8
By @saramgsilva
Thanks
[email protected]@gmail.com
http://www.saramgsilva.comhttp://twitter.com/saramgsilvahttp://pt.linkedin.com/in/saramgsilvahttp://www.facebook.com/saramgsilvahttp://www.windowsphone.com/pt-PT/publishers/Sara%20Silva