share contract - problems & attempts & solutions

41
Share contract By @saramgsilva Windows 8 Case study Problems & Attempts & Solutions

Upload: sara-silva

Post on 15-Jan-2015

2.929 views

Category:

Health & Medicine


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Share Contract - Problems & attempts & Solutions

Share contract

By @saramgsilva Windows 8

Case study

Problems & Attempts & Solutions

Page 2: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

I will use custom data format but could be another format.

Page 3: Share Contract - Problems & attempts & Solutions

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

Page 4: Share Contract - Problems & attempts & Solutions

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

Page 5: Share Contract - Problems & attempts & Solutions

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

Page 6: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Share Contract behavior

Page 7: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Expected behavior for general development• Navigation between pages:

Frame.Navigate(typeof (MainPage));.

• MVVM pattern :

Page 8: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

• MVVM Light

• ViewModelLocalor in App.xaml

• MainViewModel for a ShareTargetPage

Expected behavior for general development

Page 9: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Source Application• Page where the share is called:

Page 10: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Source Application

Page 11: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Target Application• Manifest:

Page 12: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Target Application• In App.xaml.cs:

Page 13: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Target Application• Active method in ShareTarget:

Page 14: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Target Application• Active method in MainViewModel:

I call• ReportStart• ReportDataRetrieved

Page 15: Share Contract - Problems & attempts & Solutions

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

Page 16: Share Contract - Problems & attempts & Solutions

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.

Page 17: Share Contract - Problems & attempts & Solutions

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.

Page 18: Share Contract - Problems & attempts & Solutions

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:

Page 19: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Problems - phase 1

Page 20: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Problems - phase 1

Page 21: Share Contract - Problems & attempts & Solutions

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!

Page 22: Share Contract - Problems & attempts & Solutions

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!

Page 23: Share Contract - Problems & attempts & Solutions

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!

Page 24: Share Contract - Problems & attempts & Solutions

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

Page 25: Share Contract - Problems & attempts & Solutions

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

Page 26: Share Contract - Problems & attempts & Solutions

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();

Page 27: Share Contract - Problems & attempts & Solutions

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

Page 28: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Problems - phase 2

Error FailedQI was detected

Page 29: Share Contract - Problems & attempts & Solutions

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.

Page 30: Share Contract - Problems & attempts & Solutions

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.

Page 31: Share Contract - Problems & attempts & Solutions

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.

Page 32: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Problems - phase 2

I got this in phase 2

Page 33: Share Contract - Problems & attempts & Solutions

Share Contract Windows 8

By @saramgsilva

Problems - phase 2

I got this in phase 2

Page 34: Share Contract - Problems & attempts & Solutions

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

Page 36: Share Contract - Problems & attempts & Solutions

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

Page 37: Share Contract - Problems & attempts & Solutions

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

Page 38: Share Contract - Problems & attempts & Solutions

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

Page 39: Share Contract - Problems & attempts & Solutions

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.

Page 40: Share Contract - Problems & attempts & Solutions

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!

Page 41: Share Contract - Problems & attempts & Solutions

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