@@ -113,8 +113,8 @@ public Library GetLibrary(string name)
113113 /// Loads the extension at the specified filename
114114 /// </summary>
115115 /// <param name="filename"></param>
116- /// <param name="forced "></param>
117- public void LoadExtension ( string filename , bool forced )
116+ /// <param name="isCoreOrGameExtension "></param>
117+ public void LoadExtension ( string filename , bool isCoreOrGameExtension = false )
118118 {
119119 string name = Utility . GetFileNameWithoutExtension ( filename ) ;
120120
@@ -125,13 +125,31 @@ public void LoadExtension(string filename, bool forced)
125125 return ;
126126 }
127127
128+ Assembly assembly = null ;
129+ if ( isCoreOrGameExtension ) // Prevent double loading of core extensions
130+ {
131+ foreach ( Assembly loadedAssembly in AppDomain . CurrentDomain . GetAssemblies ( ) )
132+ {
133+ if ( loadedAssembly . GetName ( ) . Name != name )
134+ {
135+ continue ;
136+ }
137+
138+ assembly = loadedAssembly ;
139+ break ;
140+ }
141+ }
142+
128143 try
129144 {
130- // Read the assembly from file
131- byte [ ] data = File . ReadAllBytes ( filename ) ;
145+ if ( assembly == null )
146+ {
147+ // Read the assembly from file
148+ byte [ ] data = File . ReadAllBytes ( filename ) ;
132149
133- // Load the assembly
134- Assembly assembly = Assembly . Load ( data ) ;
150+ // Load the assembly
151+ assembly = Assembly . Load ( data ) ;
152+ }
135153
136154 // Search for a type that derives Extension
137155 Type extType = typeof ( Extension ) ;
@@ -157,7 +175,7 @@ public void LoadExtension(string filename, bool forced)
157175 Extension extension = Activator . CreateInstance ( extensionType , this ) as Extension ;
158176 if ( extension != null )
159177 {
160- if ( ! forced )
178+ /* if (!forced)
161179 {
162180 if (extension.IsCoreExtension || extension.IsGameExtension)
163181 {
@@ -170,7 +188,7 @@ public void LoadExtension(string filename, bool forced)
170188 Logger.Write(LogType.Error, $"Failed to load extension '{name}': this extension does not support reloading.");
171189 return;
172190 }
173- }
191+ }*/
174192
175193 extension . Filename = filename ;
176194
@@ -333,7 +351,7 @@ public void LoadAllExtensions(string directory)
333351
334352 foreach ( string extPath in foundOther )
335353 {
336- LoadExtension ( Path . Combine ( directory , extPath ) , true ) ;
354+ LoadExtension ( Path . Combine ( directory , extPath ) ) ;
337355 }
338356
339357 foreach ( Extension ext in extensions . ToArray ( ) )
0 commit comments