1

Closed

[WinRT] Protocolactivation: Sequence contains more than one element

description

Hi,

for some reason I Need to save a file in a share charm on WinRT. As FilePicker is not permitted in share charm, I decided to implement a protocol based call from share charm to my App. When doing so caliburn micro throws an exception "Sequence contains more than one element". Sample is attached. In the sample I added another button in main view, but same result.
Any Suggestion how to overcome this?

file attachments

Closed Jan 26, 2013 at 3:06 PM by tibel
Not an issue.

comments

urgestein wrote Jan 25, 2013 at 4:44 PM

Hi,

I implemented following Workaround, without knowing whether this is a General solution:
 public object GetInstance(Type service, string key)
        {
            var entry = GetEntry(service, key);
            if (entry != null) {
#if !WinRT
                return entry.Single()(this);
#else
                if (entry.Count() > 1)
                {
                    return entry.Last()(this);   // Uncertain whether this is a good solution
                }
                else
                {
                    return entry.Single()(this);                    
                }
#endif 
            }

tibel wrote Jan 26, 2013 at 3:06 PM

This is not an issue and was already reported (http://caliburnmicro.codeplex.com/workitem/256).

Have a look at the Hello-WinRT Sample project how to implement OnShareTargetActivated:
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
    // Normally wouldn't need to do this but need the container to be initialised
    Initialise();

    // replace the share operation in the container
    container.UnregisterHandler(typeof(ShareOperation), null);
    container.Instance(args.ShareOperation);

    DisplayRootViewFor<ShareTargetViewModel>();
}

urgestein wrote Jan 26, 2013 at 4:14 PM

Hi tibel,

sorry my fault. I simply missed this line when copy/pasting...