From ae50b8dc8f5ca90aef33fefa7d6cada90d238347 Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Tue, 22 Dec 2015 16:02:32 +0000 Subject: [PATCH 1/2] Fix for 3dsMax Python Importing clr in 3dsMax python, causes the application to crash on GetTypes from certain assemblies. --- src/runtime/assemblymanager.cs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/runtime/assemblymanager.cs b/src/runtime/assemblymanager.cs index 583b5c945..a93843a31 100644 --- a/src/runtime/assemblymanager.cs +++ b/src/runtime/assemblymanager.cs @@ -12,6 +12,7 @@ using System.Collections; using System.Collections.Specialized; using System.Collections.Generic; +using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; @@ -57,10 +58,17 @@ internal static void Initialize() { domain.AssemblyResolve += rhandler; Assembly[] items = domain.GetAssemblies(); - for (int i = 0; i < items.Length; i++) { - Assembly a = items[i]; - assemblies.Add(a); - ScanAssembly(a); + foreach (var a in items) + { + try + { + ScanAssembly(a); + assemblies.Add(a); + } + catch (Exception ex) + { + Debug.WriteLine($"Error scaning assembly {a}. {ex}"); + } } } @@ -282,15 +290,15 @@ public static bool LoadImplicit(string name, bool warn=true) { // be valid namespaces (to better match Python import semantics). //=================================================================== - static void ScanAssembly(Assembly assembly) { - + static void ScanAssembly(Assembly assembly) + { // A couple of things we want to do here: first, we want to // gather a list of all of the namespaces contributed to by // the assembly. Type[] types = assembly.GetTypes(); - for (int i = 0; i < types.Length; i++) { - Type t = types[i]; + foreach (var t in types) + { string ns = t.Namespace; if ((ns != null) && (!namespaces.ContainsKey(ns))) { string[] names = ns.Split('.'); @@ -298,9 +306,7 @@ static void ScanAssembly(Assembly assembly) { for (int n = 0; n < names.Length; n++) { s = (n == 0) ? names[0] : s + "." + names[n]; if (!namespaces.ContainsKey(s)) { - namespaces.Add(s, - new Dictionary() - ); + namespaces.Add(s, new Dictionary()); } } } From 8dbc6d346ccec97fb30f72b71cff791eb44ac33a Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Thu, 7 Jan 2016 17:28:48 +0000 Subject: [PATCH 2/2] Removed dependency on C#6 --- src/runtime/assemblymanager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/assemblymanager.cs b/src/runtime/assemblymanager.cs index a93843a31..18666ad72 100644 --- a/src/runtime/assemblymanager.cs +++ b/src/runtime/assemblymanager.cs @@ -67,7 +67,7 @@ internal static void Initialize() { } catch (Exception ex) { - Debug.WriteLine($"Error scaning assembly {a}. {ex}"); + Debug.WriteLine(string.Format("Error scanning assembly {0}. {1}", a, ex)); } } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy