@@ -13,24 +13,31 @@ namespace PointCloudConverter.Plugins
13
13
{
14
14
public static class PluginLoader
15
15
{
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" ) ;
17
18
18
19
// TODO add logger, if needed
19
- //static ILogger Log;
20
+ // static ILogger Log;
20
21
21
22
public static IWriter LoadWriter ( string pluginName )
22
23
{
23
- //Log = logger;
24
+ // Log = logger;
24
25
26
+ // Build the full path to the plugin DLL
25
27
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.") ;
28
28
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
30
36
var pluginAssembly = Assembly . LoadFrom ( pluginPath ) ;
31
37
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 ) ;
34
41
35
42
if ( writerType == null )
36
43
throw new InvalidOperationException ( $ "No valid implementation of IWriter found in { pluginPath } ") ;
0 commit comments