CS0121 errors using DryIoc when migrating from PCL to netstandard Xamarin.Forms - xamarin.forms

I needed to migrate a Xamarin.Forms project from PCL to .netstandard. I use the PCL compatibility nuget package to consume PCLs referenced in the project but I am having a problem with DryIoc that I'm not sure why it is happening. I figured maybe someone here has seen this and can help. Basically I'm getting CS0121 errors (call is ambiguous between 'method1' and 'method2' ) One of the errors is below. I replaced part of the path with the ~ but it looks like it is confused with itself.
~/.nuget/packages/dryioc/2.12.7/contentFiles/cs/any/Container.cs(56,56): Error CS0121: The call is ambiguous between the following methods or properties: 'DryIoc.ReflectionTools.GetFieldOrNull(System.Type, string)' and 'DryIoc.ReflectionTools.GetFieldOrNull(System.Type, string)' (CS0121) (Masterflex)
Thanks!

Fixed this error by replacing the PackageReference of DryIoc with a Reference node in the csproj file:
<Reference Include="DryIoc">
<HintPath>..\packages\DryIoc.dll.4.1.0\lib\netstandard2.0\DryIoc.dll</HintPath>
</Reference>

Related

Why does a force downgrade causes an assembly load exception in .Net Core?

I have a sample solution with a console and library project. Both reference the same nuget but a different version. The console project also has a reference to the library project. So the structure is like this:
- Solution
- ConsoleApp
- Project Reference: Library
- Nuget: NServiceBus.RabbitMQ (5.2.0)
- Library
- Nuget: NServiceBus.RabbitMQ (6.0.0)
You can find the solution here.
Since Nuget uses the nearest wins rule, the nuget package that gets resolved is version 5.2.0. This is what I want, so far so good. But when I run the application and run a method of the Library I get the following exception:
Could not load file or assembly 'NServiceBus.Transport.RabbitMQ, Version=6.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
In .NET Framework I would solve this with an assembly redirect. But that isn't available in .Net Core. I always thought that .Net Core solves this automatically by using the deps.json file. There I see the following statement:
"Library/1.0.0": {
"dependencies": {
"NServiceBus.RabbitMQ": "5.2.0"
},
"runtime": {
"Library.dll": {}
}
}
But still at runtime he tries to resolve the 6.0.0 version. I'm using the latest .Dot Net 3.1.X SDK.
I'm I doing something wrong or does this seem like a bug?
For the record, this is a simple sample project. The actual situation where I need this is much more complex. I also do understand that doing this can cause runtime exceptions while running the application.
It appears to be by design.
A little bit of searching, I found this: https://github.com/dotnet/fsharp/issues/3408#issuecomment-319466999
The coreclr will load an assembly of the version or higher than the reference. If the assembly discovered is lower than the reference then it fails.
Also this: https://github.com/dotnet/sdk/issues/384#issuecomment-260457776
downgrading the assembly version isn't supported on .NET Core
So, to confirm, I spent much more time than I intended looking/searching through https://github.com/dotnet/runtime. Eventually I found the assembly version compatibility method: https://github.com/dotnet/runtime/blob/172059af6623d04fa0468ec286ab2c240409abe3/src/coreclr/binder/assemblybindercommon.cpp#L49-L53
It checks all the components of the version separately, but if we look at just one, we can see what it's doing:
if (!pFoundVersion->HasMajor() || pRequestedVersion->GetMajor() > pFoundVersion->GetMajor())
{
// - A specific requested version component does not match an unspecified value for the same component in
// the found version, regardless of lesser-order version components
// - Or, the requested version is greater than the found version
return false;
}
As the comment says, the loader will reject the assembly if the assembly's version is lower than the requested version. In your case, assuming that the assembly version matches the package version (which it doesn't have to), your library is requesting version 6.0.0, but the assembly loader/binder, found version 5.2.0 on disk, which is lower. Hence, it rejects that dll, keeps looking, but then can't find a suitable version of the assembly on the probing path and eventually throws the FileLoadException.
What's not clear to me is if this assembly compatibility is checked only on the default assembly loader, or even if you add your own event handler to AssemblyLoadContext.Default.Resolving. You could try adding your own handler and when it requests the assembly of the higher version, you return the lower version assembly anyway. It might be a way to work around the issue.

AddRazorRuntimeCompilation causing deployment problems

When I try to deploy my project it fails with the following message:-
Startup.cs(75,25): error CS1061: 'IMvcBuilder' does not contain a definition for 'AddRazorRuntimeCompilation'
and no accessible extension method 'AddRazorRuntimeCompilation' accepting a first argument of type 'IMvcBuilder'
could be found (are you missing a using directive or an assembly reference?)
I found an answer here How to fix 'IMvcBuilder' doesn't contain a definition for 'AddXmlDataContractSerializerFormatters' however after installing the suggested MVC formatter package(s) The issue persisted.
The only way I have been able to deploy is to comment out the following lines in my startup class
var builder = services.AddRazorPages();
if (Env.IsDevelopment())
{
builder.AddRazorRuntimeCompilation();
}
Maybe I need to update something on the deployment server? It is the organisation's first DotNet Core 3.1 application
You need to install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation, but not the latest version. Something compatible with .Net Core 3.x.
E.g.
Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 3.1.19

Kotlin 1.2.50 and databinding issue

Today I just updated my project to use kotlin 1.2.50 and after when I started compilation i just get an errors :
\app\build\intermediates\feature_data_binding_base_feature_info\demoDebug\dataBindingExportFeaturePackageIdsDemoDebug\out' specified for property 'annotationProcessorOptionProviders$kotlin_gradle_plugin.$0.$0.baseFeatureInfoDir' does not exist.
\app\build\intermediates\feature_data_binding_base_feature_info\demoDebug\dataBindingExportFeaturePackageIdsDemoDebug\out' specified for property 'databinding.baseFeatureInfoDir' does not exist.
On version 1.2.41 compile well.
Does anyone know what is the issue in this case?
Today update for Android Studio solve the issue.
classpath 'com.android.tools.build:gradle:3.2.0-beta01'
-> classpath 'com.android.tools.build:gradle:3.2.0-beta02'

Can't reference Microsoft.Practices namespace after NuGet update

I updated NuGet packages today (8/19/2014) for both MVVM Light and the CommonServiceLocator. After doing this, my project can no longer resolve the Microsoft.Practices namespace. This means that the following won't work:
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
What should I do to resolve this? Thanks.
Are you having a namespace collision with another package perhaps?
You can access the object with it's full namespace:
Microsoft.Practices.ServiceLocation.ServiceLocator
Posting the full error message will help.
Can you make sure that the CommonServiceLocator dll and reference made it into the project?

Flex4.6 : works in debug but not in Release build

My flex4.6 works normally in debug.
But when I create a release version, I got:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.adobe.serializers.utility::TypeUtility$/getArrayType()
at com.adobe.serializers.json::JSONDecoder/parseObject()
at com.adobe.serializers.json::JSONDecoder/parseValue()
at com.adobe.serializers.json::JSONDecoder/decode()
at com.bravolucy.football.utilities::Utilities$/getAsObj()
looks like:
http://forums.adobe.com/message/4250338
Original project was done in flex4.0 and it uses some swc libraries.
The answer of your question is in your question itself
"Original project was done in flex4.0 and it uses some swc libraries"
before this para it was said
flex4.6 works normally in debug
It should be working fine with 4.6 because with this version playerglobal.version 11.1 being used normally which has JSON lib included with it but prior version to playerglobal - 11 you need to include "as3corelib.swc" in your project libs.
More details you can find at - http://blog.infrared5.com/2011/07/working-with-native-json-in-flash-player-11/
Thanks,
Varun
You need to add and tick as3corelib.swc in project properties.
But even better would be to switch to native JSON.parse

Resources