-
Notifications
You must be signed in to change notification settings - Fork 14
Dynamic Assemblies causes registration of providers to fail silently #16
Copy link
Copy link
Open
Description
I was having an issue, where sometimes the maps would fail loading with the exception indicating that the provider couldn't be found.
After a lot of digging, I found the root cause. Trying to register dynamic assemblies throws an exception like this:
2018-04-06 13:23:15,194 [P6412/D7/T8] ERROR Terratype.Frisk.Frisk - Error registering assemblies in AppDomain, asesembly Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
System.NotSupportedException: The invoked member is not supported in a dynamic assembly.
at System.Reflection.Emit.InternalAssemblyBuilder.get_Location()
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Umbraco.Core.Logging.Logger.Info(Type type, String generateMessageFormat, Func`1[] formatItems)
at Terratype.Frisk.Frisk.<>c.<.cctor>b__4_0()
I had to add a try-catch in the foreach loop i Frisk.cs to even catch this exception. It was failing silently, with the Lazy swallowing the exception (not at all what I expected - a yellow screen of death would have been easier).
My fix is to just not even attempt registering dynamic assemblies:
foreach (Assembly currAssembly in AppDomain.CurrentDomain.GetAssemblies())
{
try
{
if (!currAssembly.IsDynamic)
{
filenames.Add(currAssembly.Location.ToLowerInvariant());
registerAssembly(currAssembly, ref installed);
}
}
catch (Exception ex)
{
LogHelper.Error(typeof(Frisk), $"Error registering assemblies in AppDomain, asesembly {currAssembly.FullName}", ex);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels