Andr谩s T贸th‘s professional blog
banditoth.net

Hey there 馃憢, I’m banditoth a .NET MAUI developer from Hungary.
I write about software development with .NET technologies.

You can find me on:
LinkedIn | Github | StackOverflow | X / Twitter | Threads

Tag: uwp

  • Xamarin.UWP FontImageSource does not get displayed

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    You may have noticed that if you give an image a FontImageSource, the image does not display properly on the UWP platform. This is probably because the default value of the FontImageSource Color property is white, and you probably want to draw it white. Check if you are giving an explicit value to the Color property. If not, try it.

    				            <Image>
    					            <Image.Source>
                                        <FontImageSource 
                                                        FontFamily="FontIcons"
                                                        Color="Black"
                                                        Glyph="?"
                                                        Size="25" />    
                                    </Image.Source>
    				            </Image>
    
  • Xamarin.UWP: Image from embedded resource throws “Operation is not supported on this platform” error

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    If you are getting the error “Operation is not supported on this platform” when you are trying to set an ImageResource from file for an image on Xamarin.UWP, then the problem comes from this line of code:

    IconSource = ImageSource.FromResource("afolder.animage.jpg");
    

    The solution: Image as Embadded Ressource shows “operation is not supported on this platform” in UWP and Release (microsoft.com)
    In a short brief: You need to use the second parameter for FromResource method call. You must pass an assembly in order to success on UWP platform. iOS and Android is not affected with this error.

    IconSource = ImageSource.FromResource("afolder.animage.jpg", typeof(AClassFromTheAssembly).Assembly);
    
  • Xamarin.UWP DryIoC error: Code generation not supported on this platform

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    If you are getting the following error when using DryIoC with Xamarin.Forms on UWP:

    System.PlatformNotSupportedException: Dynamic code generation is not
    supported on this platform.
    at System.Reflection.Emit. TypeBuilder.GetMethod (Type, Methodinfo) + 0x2d
    at
    Dryloc.FastExpressionCompiler.LightExpression.ExpressionCompiler.CompileNoA
    rgsNew(Constructorlnfo, Type, Type[, Type) + 0x5b
    at
    Dryloc.FastExpressionCompiler.LightExpression.ExpressionCompiler.TryCompileB
    oundToFirstClosureParam(Type, Expression, IParameterProvider, Typel, Type.
    CompilerFlags) + 0x73
    at Dryloc.FactoryDelegateCompiler.CompileToFactoryDelegate(Expression.
    Boolean) + 0x14c
    at Dryloc.Container.Dryloc.IResolver.Resolve(Type, IfUnresolved) + 0x23c
    

    Then instantiate your container with this code:

    Container = new Container(rules =>
    {
        // https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/ResolutionPipeline.md
        return rules.WithUseInterpretation();
    });
    

    The reason why you need to do this is here: DryIoc/ResolutionPipeline.md at master 路 dadhi/DryIoc 路 GitHub

  • Xamarin.UWP deployment failure: 0x80073D1F

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.
    Registering the application to run from layout...
    DEP0700: Registration of the app failed. [0x80073D1F] 
    	DeploymentSucceeded = False
    	DeploymentError = Err_Deploy_Register
    	DeploymentUserError = False
    	DeploymentHRESULT = 2147958047
    	HasSharedCode = False
    	Target.Id = 512
    	ProjectGuid = {5894aed2-9bb1-434b-8b49-3b86572709b7}
    	Project.TargetPlatformVersion = 10.0.19041.0
    	Project.TargetPlatformMinVersion = 10.0.17763.0
    Deleting file "vs.appxrecipe" from layout...
    DeployAsync: END (Failure, 0:00:01.499)
    Deploy: END (Failure, 0:00:01.5)
    

    Solution

    Remove your application source code from shared folder
    or
    You are being signed in with my Microsoft account in windows instead of the local user account
    or
    Visual Studio is not able to delete the application data in your local packages folder, go to C:\Users\<YOURNAME>\AppData\Local\Packages\ folder, and delete your applications folder manually.
    or
    browse more solution at here
    馃檪

  • Xamarin UWP: Use multilanguage resource files properly

    This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

    IIf you are experiencing the oddity that the UWP version of your application can’t find the correct language version of your ‘resx’ files, then you have probably fallen into the same error I did.

    The language management of UWP apps works differently to its Android and iOS counterparts.

    Reade more about it at: https://docs.microsoft.com/en-us/windows/apps/design/globalizing/manage-language-and-region

    How the UWP deals with multilingualism in brief

    Only the union can be set as UI language

    Two different lists are considered as the list of languages supported by the application. One is the list of languages supported by windows (language pack installed), and the other is the list of languages supported by the application (resx files created for them). The intersection of these can only be handled by the language switching code.

    Where to define all of the supported languages by the app

    Easily, without mainting it you can define them in only one line making a change in ‘Package.appxmanifest‘ file.

      <Resources>
        <Resource Language="x-generate" />
      </Resources>
    

    The x-generate value will collect all of the available languages on compile time.

    Otherwise, you will need to list all of them one by one:

      <Resources>
        <Resource Language="EN-US" />
        <Resource Language="JA-JP" />
        <Resource Language="FR-FR" />
      </Resources>
    

    Best practice?

    Perhaps, if the application is running on UWP platform, you should make an if statement for the runtime platform and filter out languages that are not supported by windows.

    // Get all of the supported language by windows in BCP-47 language tag (i.e. "en-US")
    IReadOnlyList<string> userLanguages = Windows.System.UserProfile.GlobalizationPreferences.Languages;