Linker preventing MvvmCross MvxApplication Initialize being called - mvvmcross

I have updated my Target Android Api to Android 12 (API 31) so our app can be accepted in the PlayStore. This meant that the Android X packages had to be updated as well.
However, our MvxApplication Intialize override is no longer called, meaning we can not call RegisterCustomAppStart, so the app gets stuck on the splash screen.
This only happens when Linker (Link SDK assemblies only) is enabled. When it is disabled, everything works fine.
I find it impossible to determine what is happening under the hood with MvvmCross startup process, and therefore determine what may be linked out. I have included as many classes and methods as I can think of in our "LinkerPleaseInclude" file, but that is really stabbing in the dark.

ADB will output the missing method at runtime. It is indeed stabbing in the dark. It's more of a Xamarin issue than an MvvmCross issue.
The Custom Linker Configuration is a superior alternative to LinkerPleaseInclude.cs. I use this XML to prevent linking out key MvvmCross bits with an Android MvvmCross 8.x app:
<assembly fullname="MvvmCross">
<type fullname="MvvmCross.IoC.MvxPropertyInjector" />
<type fullname="MvvmCross.Core.MvxSettings" />
<type fullname="MvvmCross.Core.MvxStringToTypeParser" />
<type fullname="MvvmCross.ViewModels.MvxViewModelLoader" />
<type fullname="MvvmCross.Platforms.Android.Views.MvxSavedStateConverter" />
<type fullname="MvvmCross.ViewModels.MvxAppStart`1" />
</assembly>
Here is a full example from an Android app built with MvvmCross 8.0.2. The idea is to keep only what is needed. For example, remove the NumberPicker parts if you don't use that widget in your app.
<?xml version="1.0" encoding="utf-8" ?>
<!--
This file prevents the Xamarin.Android Linker from removing code from the final executable.
C# Properties are implemented as two methods: get_PropertyName + put_PropertyName
C# Events are implemented as two methods: add_EventName + remove_EventName
C# Constructors are implemented as such:
default: .ctor
string parameter: System.Void .ctor(System.String)
See https://docs.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker for more information.
-->
<linker>
<!-- Mono.Android -->
<assembly fullname="Mono.Android">
<type fullname="Android.Views.View">
<method name="get_Text" />
<method name="put_Text" />
<method name="get_ContentDescription" />
<method name="put_ContentDescription" />
<method name="add_Click" />
<method name="remove_Click" />
<method name="add_LongClick" />
<method name="remove_LongClick" />
<method name="Invalidate" />
</type>
<type fullname="Android.Views.View.LongClickEventArgs">
<method name="System.Void .ctor(System.Boolean)" />
<method name="get_Handled" />
<method name="put_Handled" />
</type>
<type fullname="Android.Widget.TextView">
<method name="add_AfterTextChanged" />
<method name="remove_AfterTextChanged" />
</type>
<type fullname="Android.Widget.NumberPicker">
<method name="get_Value" />
<method name="put_Value" />
<method name="add_ValueChanged" />
<method name="remove_ValueChanged" />
</type>
<type fullname="Android.Widget.NumberPicker.ValueChangeEventArgs">
<method name="get_Picker" />
<method name="put_Picker" />
<method name="get_OldVal" />
<method name="put_OldVal" />
<method name="get_NewVal" />
<method name="put_NewVal" />
</type>
</assembly>
<!-- netstandard -->
<assembly fullname="netstandard">
<type fullname="System.TimeSpan" >
<method name="get_Hours" />
<method name="get_Minutes" />
<method name="get_Seconds" />
</type>
</assembly>
<!-- Google Material Design Components -->
<assembly fullname="Xamarin.Google.Android.Material">
<type fullname="Google.Android.Material.TextField.TextInputLayout">
<method name="get_Hint" />
<method name="set_Hint" />
<method name="get_Error" />
<method name="set_Error" />
</type>
<type fullname="Google.Android.Material.TextField.TextInputEditText">
<method name="get_Text" />
<method name="set_Text" />
</type>
</assembly>
<!-- MvvmCross -->
<assembly fullname="MvvmCross">
<type fullname="MvvmCross.IoC.MvxPropertyInjector" />
<type fullname="MvvmCross.Core.MvxSettings" />
<type fullname="MvvmCross.Core.MvxStringToTypeParser" />
<type fullname="MvvmCross.ViewModels.MvxViewModelLoader" />
<type fullname="MvvmCross.Platforms.Android.Views.MvxSavedStateConverter" />
<type fullname="MvvmCross.ViewModels.MvxAppStart`1" />
</assembly>
<!-- Xamarin.AndroidX.Core -->
<assembly fullname="Xamarin.AndroidX.Core">
<type fullname="AndroidX.Core.App.CoreComponentFactory" />
</assembly>
</linker>

Related

Adding supported file type in windows phone 8.1

I have added four file type association in my package.appmanifest file
in which .pdf is one of them. Due to this when i am clicking on any
external pdf file, My app is also coming in the list along with Adobe
reader. What could be the reason.
Following is the code of my app.manifest file
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="195c0ec0-b933-4837-99c7-30250bbd0f9b" Publisher="CN=etu10" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="195c0ec0-b933-4837-99c7-30250bbd0f9b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>eBasta</DisplayName>
<PublisherDisplayName>etu10</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="eBasta.App">
<m3:VisualElements DisplayName="eBasta" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="eBasta" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
<m3:InitialRotationPreference>
<m3:Rotation Preference="portrait" />
<m3:Rotation Preference="landscape" />
<m3:Rotation Preference="landscapeFlipped" />
</m3:InitialRotationPreference>
</m3:VisualElements>
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="text">
<DisplayName>text</DisplayName>
<SupportedFileTypes>
<FileType ContentType="text/xml">.xml</FileType>
<FileType ContentType="application/pdf">.pdf</FileType>
<FileType ContentType="application/zip">.zip</FileType>
<FileType ContentType="application/zip">.ebs</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name=".pdf">
<DisplayName>pdf</DisplayName>
<SupportedFileTypes>
<FileType ContentType="application/pdf">.pdf</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="removableStorage" />
<Capability Name="picturesLibrary" />
<Capability Name="musicLibrary" />
<Capability Name="enterpriseAuthentication" />
<m3:Capability Name="contacts" />
<m3:Capability Name="appointments" />
<Capability Name="sharedUserCertificates" />
<Capability Name="videosLibrary" />
<DeviceCapability Name="location" />
<DeviceCapability Name="proximity" />
<DeviceCapability Name="webcam" />
</Capabilities>
</Package>
Well it's normal that your app is listed there as you supported that file extension. If you expected that your app opens the file alone, that's not possible in Windows phone as defining default file opener is not supported

Package.appxmanifest not showing all 7 Tabs

I re-targeted my project from wp8 to wp8.1. At first my package.appxmanifest file's build action was not set to Appxmanifest. Also it is only showing 4 tabs
-Application
-capabilities
-Declarations
-Packaging
Tabs that are missing are
-Visual Assets
-content URI's
-Declarations
What should i do.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="37576f76-9ac9-4f78-b2d9-cb51446fb500" Publisher="CN=R" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="e4312153-3f4c-49dd-904d-5fbe8f1d6000" PhonePublisherId="3f72d71c-dd80-408e-affb-aa06372f300a" />
<Properties>
<DisplayName>app</DisplayName>
<PublisherDisplayName>app</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="xe4312153y3f4cy49ddy904dy5fbe8f1d6073x" Executable="AGHost.exe" EntryPoint="MainPage.xaml">
<m3:VisualElements DisplayName="app" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="app" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="SplashScreenImage.jpg" />
<m3:ApplicationView MinWidth="width320" />
<!--Used in XAML Designer. DO NOT REMOVE-->
</m3:VisualElements>
</Application>
</Applications>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>AgHostSvcs.dll</Path>
<ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>
Silverlight-based apps don't have those extra tabs; they are only applicable to non-Silverlight (WinRT) apps. You set things like your Tile icons via the WMAppManifest.xml file.

Trouble using two different databases in Mule JDBC flow

I have two JDBC flows in Mule 3.2.0, one using MySQL database and other using SQLServer database.
<mule ...
<spring:bean id="MySQL-jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName"
value="com.mysql.jdbc.Driver" />
<spring:property name="url"
value="jdbc:mysql://host:port/schema" />
</spring:bean>
<jdbc:connector name="MySQL-jdbcConnector"
dataSource-ref="MySQL-jdbcDataSource" pollingFrequency="${MySQL.db.poll}"
transactionPerMessage="false">
<jdbc:query key="read" value="${MySQL.db.jdbc_query}" />
</jdbc:connector>
<flow name="MySQL-flow">
<jdbc:inbound-endpoint queryKey="read"
connector-ref="MySQL-jdbcConnector">
<jdbc:transaction action="ALWAYS_BEGIN"/>
<property key="receiveMessageInTransaction" value="true"/>
</jdbc:inbound-endpoint>
<vm:outbound-endpoint path="path" connector-ref="first-level">
<message-properties-transformer scope="outbound">
<add-message-property key="identifier" value="MySQL"/>
</message-properties-transformer>
<vm:transaction action="NONE"/>
</vm:outbound-endpoint>
</flow>
</mule>
And
<mule ...
<spring:bean id="SQLServer-jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<spring:property name="url"
value="jdbc:sqlserver://host:port;databaseName=schema" />
</spring:bean>
<jdbc:connector name="SQLServer-jdbcConnector"
dataSource-ref="SQLServer-jdbcDataSource" pollingFrequency="${SQLServer.db.poll}"
transactionPerMessage="false">
<jdbc:query key="read" value="${SQLServer.db.jdbc_query}" />
</jdbc:connector>
<flow name="SQLServer-flow">
<jdbc:inbound-endpoint queryKey="read"
connector-ref="SQLServer-jdbcConnector">
<jdbc:transaction action="ALWAYS_BEGIN"/>
<property key="receiveMessageInTransaction" value="true"/>
</jdbc:inbound-endpoint>
<vm:outbound-endpoint path="${sv.vm.queue.name}" connector-ref="first-level-xform">
<message-properties-transformer scope="outbound">
<add-message-property key="${sv.vm.msg.identifier}" value="SQLServer"/>
</message-properties-transformer>
<vm:transaction action="NONE"/>
</vm:outbound-endpoint>
</flow>
</mule>
When I deploy any one of these floes in mule-deploy.properties, it runs ok. But when I deploy both of these flows at the same time, none of them works. I do not get any error or exception, but it seems like none of these flows run.
Any ideas what might be wrong? Probably something related to JDBC transactions?
if you have 2 different flows in same application .. then remove :-
<spring:bean id="SQLServer-jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<spring:property name="url"
value="jdbc:sqlserver://host:port;databaseName=schema" />
</spring:bean>
<jdbc:connector name="SQLServer-jdbcConnector"
dataSource-ref="SQLServer-jdbcDataSource" pollingFrequency="${SQLServer.db.poll}"
transactionPerMessage="false">
<jdbc:query key="read" value="${SQLServer.db.jdbc_query}" />
</jdbc:connector>
from any of the flow ... Since it is declared as global ... it can be used from any of the flow in the application .. what I mean is .. just remove the above line of code from one of the flow ... since you have declared in both the flow I guess it's a duplicate and not required to place in each and every flow ... and yes just mention the reference connector-ref="SQLServer-jdbcConnector" in both the mule flow ... ex:-
<jdbc:inbound-endpoint queryKey="read"
connector-ref="SQLServer-jdbcConnector">

Update app.config from WIX setup?

I am trying Wix 3.6 and this is how it looks right now :
<?xml version="1.0" encoding="UTF-8"?>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="myappINSTALLDIR" Name="myapp5Service">
<Component Id="SampleServiceComponent" DiskId="1" Guid="6f51c0f3-776c-4aec-a200-1f199352c6c3" Win64="yes">
<File Id="myapp5.WindowsService.exe" Name="myapp5.WindowsService.exe" Source="$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService.exe" KeyPath='yes'/>
...
<ServiceInstall Id="InstallmyappService" DisplayName="myappService" Name="myapp5.WindowsService.exe" Description="myapp 5 Service - För effektivare och enklare operationsplanering" Account="LocalSystem" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" />
<ServiceControl Id="ControlmyappService" Name="myapp5.WindowsService.exe" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
</Directory>
</Directory>
<WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Image\myappTopBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Image\myappDialogBackground.bmp" />
<Property Id="WIXUI_INSTALLDIR" Value="myappINSTALLDIR" />
<UIRef Id="WixUI_InstallDir" />
<Feature Id="ProductFeature" Title="Wix_myapp.WindowsService" Level="1">
<ComponentRef Id="SampleServiceComponent" />
</Feature>
<Media Id="1" Cabinet="SampleServiceComponent.cab" EmbedCab="yes" />
</Product>
Now I need to add a dialog to the Wix setup where one appSetting and one baseadress(WCF) is set to the app.config. This most be done before the installation becouse it will decide the name of the Windows Service that the Wix is installning.
And exampel would be great!
Edit 1:
<WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Image\myappTopBanner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Image\myappDialogBackground.bmp" />
<Property Id="SERVICEADDRESS" Value="http://serviceaddress"/>
<Property Id="WIXUI_INSTALLDIR" Value="myappINSTALLDIR" />
<UIRef Id="WixUI_InstallDir" />
<util:XmlFile Id="UpdateBaseAddress"
Action="setValue"
File="$(var.myapp.WindowsService.TargetDir)\myapp5.WindowsService.exe.config"
SelectionLanguage="XPath"
Permanent="yes"
ElementPath="/configuration/applicationSettings/ServiceName"
Name="baseAddress" Value="[SERVICEADDRESS]" />
<Feature Id="ProductFeature" Title="Wix_myapp.WindowsService" Level="1">
<ComponentRef Id="SampleServiceComponent" />
</Feature>
<Media Id="1" Cabinet="SampleServiceComponent.cab" EmbedCab="yes" />
</Product>
You could add in a reference to the WixUtilExtension.dll to the installer project, then use XmlFile to update the app.config like:
<Property Id="SERVICEADDRESS" Value="http://serviceaddress"/>
<util:XmlFile Id="UpdateBaseAddress"
Action="setValue"
File="[DirApplication]$(var.app.config)"
SelectionLanguage="XPath"
Permanent="yes"
ElementPath="/configuration/applicationSettings/...."
Name="baseAddress" Value="[SERVICEADDRESS]" />
Note that you'll need to set the directory and the name of the .config file (you could just use $(var.ProjectName.TargetFileName).config which should work it out for you automatically

Can't resolve types from unity config file

Trying to set up Unity via XML configurations I'm getting this exception
The type name or alias ServiceHost could not be resolved. Please check your configuration file and verify this type name.
Trying to comment that out I get the same exception for the next and then the next after that so the problem must lie somewhere in my setup.
<unity>
<typeAliases>
<!-- Lifetime manager types -->
<typeAlias alias="singleton"
type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
Microsoft.Practices.Unity" />
<typeAlias alias="external"
type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
Microsoft.Practices.Unity" />
<typeAlias alias="perThread"
type="Microsoft.Practices.Unity.PerThreadLifetimeManager,
Microsoft.Practices.Unity" />
<!-- User-defined type aliases -->
<typeAlias alias="ServiceHost"
type="System.ServiceModel.ServiceHost, System.ServiceModel" />
<typeAlias alias="UnityServiceHost"
type="MyProjectServiceLibrary.Hosting.UnityServiceHost" />
<typeAlias alias="IServiceBehavior"
type="System.ServiceModel.Descriptions.IServiceBehavior, System.ServiceModel" />
<typeAlias alias="UnityServiceBehavior"
type="MyProjectServiceLibrary.Hosting.UnityServiceBehavior, MyProjectServiceLibrary" />
<typeAlias alias="IInstanceProvider"
type="System.ServiceModel.Dispatcher.IInstanceProvider, System.ServiceModel" />
<typeAlias alias="UnityInstanceProvider"
type="MyProjectServiceLibrary.Hosting.UnityInstanceProvider, MyProjectServiceLibrary" />
<typeAlias alias="MyProjectService"
type="MyProjectServiceLibrary.Service.MyProjectService, MyProjectServiceLibrary" />
<typeAlias alias="IRepositoryFactory"
type="MyProjectDataModelLibrary.Repository.IRepositoryFactory, MyProjectDataModelLibrary" />
<typeAlias alias="RepositoryFactory"
type="MyProjectDataModelLibrary.Repository.RepositoryFactory, MyProjectDataModelLibrary" />
<typeAlias alias="IDbContext"
type="MyProjectDataModelLibrary.DataContext.IDbContext, MyProjectDataModelLibrary" />
<typeAlias alias="MyProjectDatabase"
type="MyProjectDataModelLibrary.DataContext.MyProjectDatabase, MyProjectDataModelLibrary" />
<typeAlias alias="IRepositoryOfT"
type="MyProjectDataModelLibrary.Repository.IRepository`1, MyProjectDataModelLibrary" />
<typeAlias alias="EntityRepositoryOfT"
type="MyProjectDataModelLibrary.Repository.EntityRepository`1, MyProjectDataModelLibrary" />
</typeAliases>
<containers>
<container>
<types>
<type type="MyProjectService" />
<type type="ServiceHost"
mapTo="UnityServiceHost" />
<type type="IServiceBehavior"
mapTo="UnityServiceBehavior" />
<type type="IInstanceProvider"
mapTo="UnityInstanceProvider" />
<type type="IRepositoryFactory"
mapTo="RepositoryFactory" />
<type type="IDbContext"
mapTo="MyProjectDatabase" />
<type type="IRepositoryOfT"
mapTo="EntityRepositoryOfT" />
</types>
</container>
</containers>
</unity>
I've tried reading around to see what I'm doing wrong. I doubt it's the fully qualified name though I can't be sure as I haven't really used that before.
IUnityContainer container = new UnityContainer();
container.RegisterInstance<IUnityContainer>(container);
UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
section.Configure(container);
The exception is thrown in the last line here.
Since you're referencing system types, it's most likely trying to pull those types from the GAC. In that case, you'll need to use the fully qualified assembly names, including version number, culture, and public key token. Something like this:
<typeAlias alias="ServiceHost"
type="System.ServiceModel.ServiceHost, System.ServiceModel,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,
processorArchitecture=MSIL" />
You'll need to look up the appropriate version # and public key tokens for the version of .NET you're using, of course.