Creating MvvmCross Application using V3 - System.Windows missing on iOS - xamarin.ios

I currently try to setup my app using V3.
Works actually fine for WP8 and Android. But I'm strugeling over iOS.
As described in the new tutorial I've added the following references to my Core-Project:
Cirrious.CrossCore.dll
Cirrious.MvvmCross.dll
When I open my solution on my mac (got a solution which only includes the iOS and the Core project) Xamarin Studio starts to complain, that it can not find the System.Windows.Input stuff which is needed for the ICommand.
Currently it does not find ICommand/IList/MvxRealyCommand in the code... :S
So the question:
Which dll's I've to reference ein the core project to make it work in Xamarin Studio?
edit:
Ok, I've to add the following references to my Core-Project:
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Serialization" />
</ItemGroup>
Not sure whether I need all of them, just copy pasted them from the Conference-Example.
I've to do some more researches on this :S

Update June 2013
Xamarin has now released their first PCL support.
Further, one simple workaround for this issue has been found: simply don't use MvxCommand but instead use your own local-project MyCommand implementation of System.Windows.Input.ICommand as part of your Core project.
End of Update
Xamarin doesn't yet support PCLs properly
As a result you must compile your pcl projects separately for ios builds - and you must reference dll's built for iOS rather than dll's built for 'proper PCL'
When following the current mvx walkthrough this just means that you need to use different mvvmcross binaries on the Mac. I generally do this by just putting different dll files in /lib/mvx folder
The repo https://github.com/slodge/mvvmcross-binaries contains four sets of binaries currently - these cover all of pcl and ios, debug and release
More on this situation is available in http://slodge.blogspot.co.uk/2013/01/almost-portable-binaries.html?m=1
Hopefully this situation is changing soon - as soon as proper PCL support arrives then we should be able to use the same set of binaries on all platforms :)

Related

The type 'Memory<T>' exists in both 'System.Memory 4.0.1.0 and mscorlib 2.0.5.0

i'm having hard time resolving this new issue.
It appears only on the xamarin.ios project of the solution at compile time.
The xamarin.android project is compiling ok.
I did not reference system.memory but netstandard 2.0 projects.
That was compiling fine until recently.
Is it a known issue in xamarin.ios tooling ? any workaround ?
I've tried:
googling
add the system.memory nuget to the ios project
delete bin/obj/.vs folders, clean/rebuild
I'm dry.
I found the solution here !
Add at the end of your ios project file:
<Target
Name="VS16_RemoveSystemMemory"
BeforeTargets="FindReferenceAssembliesForReferences"
Condition="'$(MSBuildVersion)' >= '16.0'">
<ItemGroup>
<_ReferencePathToRemove
Include="#(ReferencePath)"
Condition="'%(ReferencePath.NuGetPackageId)'=='System.Memory'" />
<ReferencePath Remove="#(_ReferencePathToRemove)" />
</ItemGroup>
<Message Text="Removing System.Memory for VS 2019 compatibility" Importance="high"/>
</Target>
And magically it compiles !
I don't know from where this nuget dependency came, but it's not from my code, it's from a third party nuget, most probably from the Google ones.
For anyone that arrives here on a related issue around Span<T> or ReadOnlySpan<T> being ambiguous in Xamarin iOS with .NET Standard 2.1 dependencies, the issue is still related to System.Memory but the answer pointed out by Softlion did not solve for me. The reasoning and workaround pointed out in this [thread][2] was my underlying problem:
There are two types of the same name System.ReadOnlySpan in the app declared and cannot be unified.
The first one is declared in System.Memory.dll (one implementation)
The second one is in netstandard.dll (the type-forwarder to the second implementation inside mscorlib.dll)
The bug is in System.Memory nuget because it's missing netstandard2.1 TFM implementation where the System.ReadOnlySpan type would not be declared in the assembly but referenced from netstandard.dll
Adding package references for System.Memory 4.5.4 and System.Buffers 4.5.1 was the workaround I needed.

The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded

I'm trying to publish a newly created asp.net 4.6 web project to Azure web apps and receiving the following error:
remote: D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly D:\home\site\repository\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\home\site\repository\WebApp\WebApp.csproj]
Everything builds fine via Visual Studio 2015 on my local machine. I thought Azure web apps were all set to support VS 2015 RTM upon release, but it would appear they do not have MSBuild 14.0 installed. Is there a work around or a roadmap for this problem?
Here was the fix for me.
Using Nuget Package Manager, remove these two packages if referenced:
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the
Diff against previous revision
In my case I have to edit my .csproj file and find below lines and delete them
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
Now everything is fine,
Azure Web Apps doesn't support ASP.NET 4.6 yet. It's on it's way though, so stay tuned.

Unit testing with portable library for Windows Phone 7 and 8

I currently have a VS2012 solution with a WP71 project and a WP8 project. Each of these projects reference a Portable Class Library project where I keep the view models. I also have a Unit Test project that references the PCL and contains tests for the view models.
The problem I'm having is when I compile the unit test project I get the following error:
error CS0012: The type 'System.Windows.Input.ICommand' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
All of the projects, including the unit test project, reference the Portable.MvvmLightLibs NuGet package.
After looking around for this assembly I noticed that there are different versions, one for WP8, one for Silverlight 4, etc. Out of all these versions I'm not sure which to use.
The unit test project is targeting .NET Framework 4.5, so I added the System.Windows assembly for that version which works, but I then get the following error:
error : CA0001 : Could not resolve reference to System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
Seeing as this is a code analysis error I'm tempted to simply ignore this and carry on, but I was wondering if anyone had any ideas on how to solve this or whether it is safe to ignore it?
So, I figured a way to solve the problem.
To get the test project to compile I had to add the System.Windows.dll assembly from:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71
But, adding it using the Add Reference dialog automatically adds the .NET 4.5 version even if I browsed directly to the folder. To fix this I opened the *.csproj for the test project and replaced the line:
<Reference Include="System.Windows"/>
with
<Reference Include="System.Windows">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\System.Windows.dll</HintPath>
</Reference>
This ensured that the 2.0.5.0 version was referenced instead of the .NET 4.5 version. The problem with this approach is certain types conflict with other assemblies, namely the System.dll, but seeing as I'm only testing view models from a Portable Class Library, I'm not all that bothered.
Ideally the test project would also be a Portable Class Library, but I've not got round to testing that.
One other issue was I tend to have warnings show up as errors when building in release mode, so this always fails because there will always be a warning complaining about naming clashes with System.dll.

Can't add Fakes assembly of Microsoft.Practices.EnterpriseLibrary.Logging on VS2012 Update 1

After installing VS2012 Update 1 I'm unable to create fake assembly for Microsoft.Practices.EnterpriseLibrary.Logging.dll reference. However fakes assemblies for Microsoft.Practices.EnterpriseLibrary.Commom.dll, System.dll and others creates normally. The only solution for this problem I found, was to uninstall Update 1 of VS2012 and things got back to normal. The problem occurred both on local machine and on tfs build server.
Here is the error, that VS2012 shows in its error list:
'Microsoft.Practices.EnterpriseLibrary.Logging.Fakes.StubLogWriter' does not implement inherited abstract member 'Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.GetFilter(string)' [c:\users\administrator\documents\visual studio 2012\Projects\DeleteMe\DeleteMe\obj\Debug\Fakes\mpell\f.csproj] c:\users\administrator\documents\visual studio 2012\Projects\DeleteMe\DeleteMe\f.cs 68219 DeleteMe 26
I suppose it's a bug of VS2012 Update 1, but maybe I'm missing some property to check or something?
In Visual Studio 2012 Update 1, we removed several internal limitations that caused Fakes silently skip generation of stubs and shims. LogWriter happened to be one of the classes that VS2012 RTM silently skipped. Unfortunately, improvements in Update 1 expose some other limitations in Fakes, which in this case is its inability to distinguish between generic and non-generic overloads of the GetFilter method of the LogWriter class.
As a workaround, remove this type from Fakes configuration. Here is a .Fakes file that accomplishes that.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="Microsoft.Practices.EnterpriseLibrary.Logging" Version="5.0.505.0"/>
<StubGeneration>
<Remove FullName="Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter!"/>
</StubGeneration>
</Fakes>
As a general practice, it is better to modify the default .Fakes files and specify only the stub and shim types you need in your project. This significantly improves build time and helps avoid Fakes limitations that don't apply to your testing needs.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="Microsoft.Practices.EnterpriseLibrary.Logging" Version="5.0.505.0"/>
<StubGeneration>
<Clear/>
<Add FullName="Namespace.TypeName!"/>
</StubGeneration>
<ShimGeneration>
<Clear/>
<Add FullName="Namespace.TypeName!"/>
</ShimGeneration>
</Fakes>

Does Azure support building F# 3.0/VS2012 projects?

I'm trying to deploy an MVC4 web application to Azure. It has a dependency on an F# project (houses the controllers for the MVC app) which keeps failing to build w/ error:
C:\DWASFiles\Sites\jbf\VirtualDirectory0\site\repository\JBF.Web\JBF.Web.Controllers\JBF.Web.FSharp.fsproj : error MSB4057: The target "Build" does not exist in the project.
The project(s) exist in VS2012 which forces the upgrade of F# projects. I'm wondering if this is a dependency that Azure doesn't support yet with all of the 4.5 refs found in the import statements from the fsproj:
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.5\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.5\Microsoft.FSharp.Targets')" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets'))" />
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (!Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets'))" />
For the record if I pre-build the DLL and deploy that (with a reference to the DLL instead of the project) it works just fine. Also, the fsproj has no actual dependency on F# 3.0 (it's an F# 2.0 project migrated to VS2012).
Update: this issue is tracked by https://github.com/projectkudu/kudu/issues/137
I just reproed this. Here is the sample repo: https://github.com/KuduApps/WebAppWithFSharpLibrary.
It's definitely a bug. Could you please open an issue on https://github.com/projectkudu/kudu to track this? It's best to track issue there then as StackOverflow questions. Thanks!

Resources