@@ -13,24 +13,31 @@ namespace PointCloudConverter.Plugins
1313{
1414 public static class PluginLoader
1515 {
16- static readonly string pluginDirectory = Path . Combine ( Directory . GetCurrentDirectory ( ) , "Plugins" ) ;
16+ // Resolve plugin folder relative to the .exe location instead of current working directory
17+ static readonly string pluginDirectory = Path . Combine ( Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) , "Plugins" ) ;
1718
1819 // TODO add logger, if needed
19- //static ILogger Log;
20+ // static ILogger Log;
2021
2122 public static IWriter LoadWriter ( string pluginName )
2223 {
23- //Log = logger;
24+ // Log = logger;
2425
26+ // Build the full path to the plugin DLL
2527 string pluginPath = Path . Combine ( pluginDirectory , pluginName + ".dll" ) ;
26- //Log.Write($"Loading plugin at {pluginPath}");
27- if ( File . Exists ( pluginPath ) == false ) throw new FileNotFoundException ( $ "The plugin at { pluginPath } could not be found.") ;
2828
29- // Load the plugin assembly
29+ // Log.Write($"Loading plugin at {pluginPath}");
30+
31+ // Check if the plugin DLL exists
32+ if ( File . Exists ( pluginPath ) == false )
33+ throw new FileNotFoundException ( $ "The plugin at { pluginPath } could not be found.") ;
34+
35+ // Load the plugin assembly from the DLL
3036 var pluginAssembly = Assembly . LoadFrom ( pluginPath ) ;
3137
32- // Find the specific type 'PointCloudConverter.Writers.GLTF'
33- var writerType = pluginAssembly . GetType ( "PointCloudConverter.Writers.GLB" ) ;
38+ // Find the specific type 'PointCloudConverter.Writers.<PluginName>'
39+ // This assumes the type name inside the DLL matches the filename
40+ var writerType = pluginAssembly . GetType ( "PointCloudConverter.Writers." + pluginName ) ;
3441
3542 if ( writerType == null )
3643 throw new InvalidOperationException ( $ "No valid implementation of IWriter found in { pluginPath } ") ;
0 commit comments