CrossMedia works in Debug but not in Release for UWP - error msg about onecore(??)

Will.ItraxWill.Itrax CAMember ✭✭✭

Below is a snippet of my code. Each of the Debug.WriteLine output that starts with a "->" is to indicate the echoing of what code is about to be run. That is followed by an error message that the system produces that starts with either "onecore" or "onecoreuap". In this way it is easy to see the code and the message that it produces.

I looked up onecoreuap and this MS site
https://msdn.microsoft.com/en-us/library/windows/desktop/mt654040%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
indicates that "OneCoreUap.lib ... provides the exports for the subset of Win32 APIs that are common to all Windows 10 devices that support the Universal Windows Platform (UWP)."
However, a note at the end says:
"**Important **Windows Store apps should not use OneCoreUap.lib but need to use WindowsApp.lib instead."

1) how can I fix this?
2) how does that app get access to "onecore" or "onecoreuap" (when I do not want it and did not ask for it)?
3) how do I link in to "WindowsApp.lib instead" or do I even need it? (I tried through references in the UWP project)

Here is my code:
`

  Debug.WriteLine("->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions");
  mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
  {
      PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small,
  });
  IFolder baseFolder = FileSystem.Current.LocalStorage;
  IFolder picFolder = null;

// The following gets a path for the folder to contain the picture
picFolder = await Util.GetPicPath(baseFolder);

Debug.WriteLine("->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);" );
IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);

newFilePath = newFile.Path;

Debug.WriteLine("->using (Stream sWriter = mediaFile.GetStream())");
using (Stream sWriter = mediaFile.GetStream())
{
    Debug.WriteLine("-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))");
    using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))  
    {
        Debug.WriteLine("->await sWriter.CopyToAsync(stream);");
        await sWriter.CopyToAsync(stream);
    }
}


//==================================

`

Here is the output that I get:

pickPhoto
->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(5) tid(59b4) 80040154 Class not registered

->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);
onecoreuap\shell\windows.storage\dataaccess.cpp(4237)\windows.storage.dll!74610A1F: (caller: 746106BB) ReturnHr(1) tid(5904) 80004001 Not implemented

->using (Stream sWriter = mediaFile.GetStream())
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(2) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(6) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(7) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(8) tid(65b0) 80040154 Class not registered

-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(3) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(9) tid(65b0) 80040154 Class not registered

->await sWriter.CopyToAsync(stream);

Done pickPhoto

Environment:
Visual Studio 2017 v 15.5.4
Xam.Plugin.Media v 3.1.3
Xamarin.Forms v 2.4.0.280 (because I can not get the app to work with higher versions yet)
Xamarin.FFImageLoading v2.3.4
and many more plugins.

Any suggestions and insight are much appreciated.

Regards, Will

Best Answer

Answers

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    @FishDev When I set "Compile with .NET Native tool chain" to unchecked it worked! Thanks so much!

  • FishDevFishDev USMember ✭✭

    @Will.Itrax said:
    @FishDev When I set "Compile with .NET Native tool chain" to unchecked it worked! Thanks so much!

    Given your initial description I assume you intend to publish this app to the Windows App Store. If so, this unfortunately does not fix your problem because apps for the store must be compiled with .NET native tool chain. This might however help narrow down the cause of the issue. You might try including relevant assemblies to your Xamarin.Forms.Init() call in your UWP App.xaml.cs as per this:

    https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/#Troubleshooting

  • Will.ItraxWill.Itrax CAMember ✭✭✭

    @FishDev You are absolutely right. I tried to publish to the Windows Store having unchecked "Compile with .NET Native tool chain" and I got errors: (shown here for those who come across it in future, or a future self ;- )

    Error info: error 80080204: All app package manifests in a bundle must declare the same values under the XPath [local-name()='Package']/[local-name()='Dependencies']. The values under this XPath declared in the manifest for the package with file name "MyApp.UWP_1.1.129.0_x64.appx" and package full name "MyCompany.MyApp_1.1.129.0_x64__..." at line 11, column 4 don't match those declared in the manifest for the package with file name "MyApp.UWP_1.1.129.0_x86.appx" and package full name "MyCompany.MyApp_1.1.129.0_x86__..." at line 11, column 4.

    What it was, is that I had unchecked the X86 version but not the x64 and ARM versions. So, after I had unchecked them all, I resubmitted. As you probably know, it was not pretty. Here are the headlines of the errors that I got:
    1) Error Found: The binary analyzer test detected the following errors...
    2) Error Found: The supported APIs test detected the following errors...
    3) Error Found: The debug configuration test detected the following errors...

    So, I am back to the original question.

    When the program processes:

    mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small });

    I get the following error
    onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(5) tid(59b4) 80040154 Class not registered

    I even tried adding the following in App.xaml.cs in UWP:
    assembliesToInclude.Add(typeof(MediaFile).GetTypeInfo().Assembly); assembliesToInclude.Add(typeof(CrossMedia).GetTypeInfo().Assembly); assembliesToInclude.Add(typeof(PickMediaOptions).GetTypeInfo().Assembly);
    But I don't see how that would affect anything as they are used in my Cross Platform code - and so far everything else works.

    I may open a new question based on what I have learned.
    Thanks for your help.

  • leeyoleeyo USMember ✭✭

    You have to include the Renderer assembly, so basically:

    using Plugin.MediaManager.Forms.UWP; // for VideoViewRenderer type
    using System.Reflection; // for Assembly type
    List<Assembly> assembliesToAdd = new List<Assembly>();
    assembliesToAdd.Add(typeof(VideoViewRenderer).GetTypeInfo().Assembly);
    Xamarin.Forms.Forms.Init(e, assembliesToAdd);

    Just tried it out with last versions (Xamarin.Forms & MediaManager) and it works.

  • GSalunkheGSalunkhe INMember ✭✭

    @FishDev said:
    When set to Release mode, is "Compile with .NET Native tool chain" checked or not? Try changing that settings and see if you still get the issue.

    Thanks for help.

  • GSalunkheGSalunkhe INMember ✭✭

    @leeyo said:
    You have to include the Renderer assembly, so basically:

    using Plugin.MediaManager.Forms.UWP; // for VideoViewRenderer type
    using System.Reflection; // for Assembly type
    List<Assembly> assembliesToAdd = new List<Assembly>();
    assembliesToAdd.Add(typeof(VideoViewRenderer).GetTypeInfo().Assembly);
    Xamarin.Forms.Forms.Init(e, assembliesToAdd);

    Just tried it out with last versions (Xamarin.Forms & MediaManager) and it works.

    @leeyo Where we need to add above code. In common project OR uwp project.

  • GSalunkheGSalunkhe INMember ✭✭

    @GSalunkhe said:

    @leeyo said:
    You have to include the Renderer assembly, so basically:

    using Plugin.MediaManager.Forms.UWP; // for VideoViewRenderer type
    using System.Reflection; // for Assembly type
    List<Assembly> assembliesToAdd = new List<Assembly>();
    assembliesToAdd.Add(typeof(VideoViewRenderer).GetTypeInfo().Assembly);
    Xamarin.Forms.Forms.Init(e, assembliesToAdd);

    Just tried it out with last versions (Xamarin.Forms & MediaManager) and it works.

    @leeyo Where we need to add above code. In common project OR uwp project.

    I am using InTheHand.Forms

  • GSalunkheGSalunkhe INMember ✭✭

    @FishDev said:

    @Will.Itrax said:
    @FishDev When I set "Compile with .NET Native tool chain" to unchecked it worked! Thanks so much!

    Given your initial description I assume you intend to publish this app to the Windows App Store. If so, this unfortunately does not fix your problem because apps for the store must be compiled with .NET native tool chain. This might however help narrow down the cause of the issue. You might try including relevant assemblies to your Xamarin.Forms.Init() call in your UWP App.xaml.cs as per this:

    https://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/#Troubleshooting

    The link is changed to https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/windows/installation/ . Then go to Troubleshooting section

  • GSalunkheGSalunkhe INMember ✭✭

    Solved the issue :)

    Need to put in App.xaml.cs under UWP(App.xaml is created for individual platform if selected Master-Detail during project creation)

    have these namespaces

    using System.Reflection;
    using InTheHand.Forms;

    AND

        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
    

    .
    .
    .

                rootFrame = new Frame();
    
                rootFrame.NavigationFailed += OnNavigationFailed;
    
                //To make Recording work in Release mode for UWP.
                //Add the thirdparty class which all you are using.
                List<Assembly> assembliesToInclude = new List<Assembly>();
                assembliesToInclude.Add(typeof(InTheHand.Forms.Platform.WinRT.InTheHandForms).GetTypeInfo().Assembly);
                Xamarin.Forms.Forms.Init(e, assembliesToInclude);
    
                //Original Code
                //Xamarin.Forms.Forms.Init(e);
                InTheHand.Forms.Platform.WinRT.InTheHandForms.Init();
    
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
    
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
    
Sign In or Register to comment.