Issues with Xamarin.iOS
See original GitHub issueI’ve been working on a .NET Standard 2.0 library for a while now, an using Scrutor with FromApplicationDependencies()
has been working fine in my unit tests.
However, when Scrutor is used in Xamarin.iOS both FromApplicationDependencies()
and FromDependencyContext(DependencyContext.Load(Assembly.GetEntryAssembly()))
throw an exception:
The type initializer for 'Microsoft.Extensions.DependencyModel.DependencyContextLoader' threw an exception.
...
System.NotImplementedException: The method or operation is not implemented.
...
at System.AppContext.GetData (System.String name) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.18/src/mono/mcs/class/referencesource/mscorlib/system/AppContext/AppContext.cs:46
at Microsoft.Extensions.DependencyModel.DependencyContextPaths.GetCurrent () [0x00000] in <8241b70107294c1cb31f55eb9c49a4a8>:0
at Microsoft.Extensions.DependencyModel.DependencyContextPaths..cctor () [0x0000a] in <8241b70107294c1cb31f55eb9c49a4a8>:0
I tried getting around this by doing the following:
var entryAssembly = Assembly.GetEntryAssembly();
var entryDependencyAssemblies = entryAssembly.GetReferencedAssemblies();
List<Assembly> scanAssemblies = new List<Assembly> { entryAssembly };
foreach (var assemblyName in entryDependencyAssemblies)
{
var assembly = Assembly.Load(assemblyName);
scanAssemblies.Add(assembly);
}
...
.FromAssemblies(scanAssemblies)
Unfortunately Scrutor is not finding any classes when I do this. Not sure if it matters, but I specify an array of base types that I scan for, like this:
.AddClasses(classes => classes.Where(c => scanTypes.Contains(c.BaseType)))
Note that the debugger is showing that scanAssemblies
does contain the correct assemblies, and I can see the types I want under DefinedTypes
.
Even a hacky workaround would be very much appreciated at this point!
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Issues · xamarin/Xamarin.Forms
Xamarin forms UI Elements bug after returning from a website. #15748 opened on May 22 by vsfeedback · [Bug] Find element by automation...
Read more >Troubleshooting Tips for Xamarin.iOS
This document provides various tips useful for troubleshooting during the development of Xamarin.iOS applications.
Read more >Connection Troubleshooting for a Xamarin.iOS Build Host
This guide provides troubleshooting steps for issues that may be encountered using the new connection manager, including connectivity and ...
Read more >Xamarin iOS Compatibility Issues with latest Xcode 15
Specifically, I am facing pairing issues with both IDEs, as no iOS simulators are available for debugging and I am unable to open...
Read more >Xamarin iOS in Visual Studio 2022 - Problem with ...
In VS 2019 there was an issue on iOS with provision profiles, that is fixed now in VS 2022 17.0.1 but now a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Dids Pushed a new version, 2.1.0 to NuGet with a new method,
FromAssemblyDependencies
, that does more or less what your code above does.FromApplicationDependencies
will now also fall back to this method, using the entry assembly when theDependencyContext
fails to load, i.e. on Xamarin/Mono.I’m closing this due to lack of activity. I’m assuming everything sorted itself out with the new methods 😄