Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <llsan@microsoft.com>2022-02-04 15:32:54 +0300
committerLluis Sanchez <llsan@microsoft.com>2022-02-04 15:34:08 +0300
commit750928d6a910c37e60d1d050ce371bd001305ce5 (patch)
treecbc05b711879cd8a531e585dc98b522781c36aa9
parent558f421c2c50740f4300dde768c8023c898c8981 (diff)
Fix CecilReflector load issue
Loading of CecilReflector was failing in .NET core since it was being loaded in the LoadFrom context.
-rw-r--r--Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs19
-rw-r--r--Version.props2
2 files changed, 18 insertions, 3 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs b/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs
index 5c113b2..8c6afad 100644
--- a/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs
+++ b/Mono.Addins/Mono.Addins.Database/AddinFileSystemExtension.cs
@@ -179,14 +179,29 @@ namespace Mono.Addins.Database
if (File.Exists (cecil))
Assembly.LoadFile (cecil);
- Assembly asm = Assembly.LoadFrom (asmFile);
+#if NETFRAMEWORK
+ var asm = Assembly.LoadFrom(asmFile);
+#else
+ // The assembly needs to be loaded in the Assembly.Load() context, so use Assembly.Load()
+ // after getting the AssemblyName (which, on .NET Core, also contains the full
+ // path information so Assembly.Load() will work).
+ var asm = Assembly.Load(AssemblyName.GetAssemblyName(asmFile));
+#endif
t = asm.GetType ("Mono.Addins.CecilReflector.Reflector");
}
else {
string refName = GetType().Assembly.FullName;
int i = refName.IndexOf (',');
refName = "Mono.Addins.CecilReflector.Reflector, Mono.Addins.CecilReflector" + refName.Substring (i);
- t = Type.GetType (refName, false);
+ try
+ {
+ t = Type.GetType(refName, false);
+ }
+ catch (FileLoadException)
+ {
+ // .NET Core may throw an exception if the assembly is not found
+ t = null;
+ }
}
if (t != null)
reflector = (IAssemblyReflector)Activator.CreateInstance (t);
diff --git a/Version.props b/Version.props
index 658346e..a2f976a 100644
--- a/Version.props
+++ b/Version.props
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
- <PackageVersion>1.3.10</PackageVersion>
+ <PackageVersion>1.3.11</PackageVersion>
<Authors>Microsoft</Authors>
<Owners>microsoft, xamarin</Owners>
<PackageLicenseUrl>https://github.com/mono/mono-addins/blob/main/COPYING</PackageLicenseUrl>