Class MultiInstanceSolidworksManager
- Namespace
- Hymma.Solidworks.Extensions
- Assembly
- Hymma.Solidworks.Extensions.dll
Manages starting multiple SolidWorks instances without journal file conflicts.
[Obsolete("This class is not practical for production use due to SolidWorks startup time (~60+ seconds per instance). Consider using the existing SolidWorks instance or COM automation with CreateObject instead.")]
public class MultiInstanceSolidworksManager : IDisposable
- Inheritance
-
MultiInstanceSolidworksManager
- Implements
- Inherited Members
Remarks
When starting multiple SolidWorks instances, each instance tries to write to the same journal file, causing a warning dialog. This class temporarily modifies the registry to give each instance a unique journal folder path, avoiding the conflict.
Supports multiple installed SolidWorks versions (e.g., 2023, 2024, 2025) and can modify registry settings for all versions or a specific version.
Note: Starting new SolidWorks instances is inherently slow (60+ seconds per instance). For most use cases, consider using the existing SolidWorks instance instead.
Properties
Instances
Gets the list of active SolidWorks instances managed by this manager.
public IReadOnlyList<SolidWorksInstanceInfo> Instances { get; }
Property Value
Methods
CloseAllInstances(bool)
Closes all managed SolidWorks instances and restores registry settings.
public void CloseAllInstances(bool forceKill = false)
Parameters
forceKillboolIf true, forcefully kills processes that don't close gracefully.
CloseInstance(SolidWorksInstanceInfo, bool)
Closes a specific SolidWorks instance and restores its registry settings.
public void CloseInstance(SolidWorksInstanceInfo instance, bool forceKill = false)
Parameters
instanceSolidWorksInstanceInfoThe instance to close.
forceKillboolIf true, forcefully kills the process if it doesn't close gracefully.
Dispose()
Releases all resources and closes all managed instances.
public void Dispose()
Dispose(bool)
Releases resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolTrue if called from Dispose(), false if from finalizer.
~MultiInstanceSolidworksManager()
Finalizer.
protected ~MultiInstanceSolidworksManager()
GetAllInstallations()
Gets the installation information for all installed SolidWorks versions.
public static Dictionary<string, string> GetAllInstallations()
Returns
- Dictionary<string, string>
Dictionary mapping version strings to executable paths.
GetDefaultSolidWorksPath()
Gets the default SolidWorks installation path (latest version).
public static string GetDefaultSolidWorksPath()
Returns
- string
Path to SLDWORKS.exe or null if not found.
GetExecutablePathForVersion(string)
Gets the executable path for a specific SolidWorks version.
public static string GetExecutablePathForVersion(string version)
Parameters
versionstringVersion string (e.g., "SOLIDWORKS 2024").
Returns
- string
Path to SLDWORKS.exe or null if not found.
GetExecutablePathForYear(int)
Gets the executable path for a specific SolidWorks version year.
public static string GetExecutablePathForYear(int year)
Parameters
yearintVersion year (e.g., 2023, 2024, 2025).
Returns
- string
Path to SLDWORKS.exe or null if not found.
GetInstalledVersions()
Gets all installed SolidWorks versions from the registry, ordered by version descending.
public static List<string> GetInstalledVersions()
Returns
- List<string>
List of version strings (e.g., ["SOLIDWORKS 2025", "SOLIDWORKS 2024", "SOLIDWORKS 2023"]).
GetLatestInstalledVersion()
Gets the latest installed SolidWorks version from the registry.
public static string GetLatestInstalledVersion()
Returns
- string
Version string (e.g., "SOLIDWORKS 2024") or null if not found.
StartInstance(string, int, ProcessWindowStyle)
Starts a new SolidWorks instance with a unique journal folder to avoid conflicts. Modifies the registry for ALL installed SolidWorks versions to prevent journal file conflicts regardless of which version starts.
public SolidWorksInstanceInfo StartInstance(string executablePath = null, int timeoutSeconds = 60, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)
Parameters
executablePathstringPath to SLDWORKS.exe. If null, uses default installation path.
timeoutSecondsintTimeout in seconds to wait for SolidWorks to start.
windowStyleProcessWindowStyleWindow style for the new process.
Returns
- SolidWorksInstanceInfo
Information about the started SolidWorks instance.
Exceptions
- TimeoutException
Thrown when SolidWorks doesn't start within the timeout period.
- InvalidOperationException
Thrown when unable to find or modify registry settings.
StartInstance(string, int, ProcessWindowStyle, bool, string)
Starts a new SolidWorks instance with a unique journal folder to avoid conflicts.
public SolidWorksInstanceInfo StartInstance(string executablePath, int timeoutSeconds, ProcessWindowStyle windowStyle, bool modifyAllVersions, string targetVersion)
Parameters
executablePathstringPath to SLDWORKS.exe. If null, uses default installation path.
timeoutSecondsintTimeout in seconds to wait for SolidWorks to start.
windowStyleProcessWindowStyleWindow style for the new process.
modifyAllVersionsboolIf true, modifies registry for all installed SolidWorks versions. If false, only modifies the target version.
targetVersionstringSpecific version to target (e.g., "SOLIDWORKS 2024"). If null and modifyAllVersions is false, attempts to detect from executable path.
Returns
- SolidWorksInstanceInfo
Information about the started SolidWorks instance.
Exceptions
- TimeoutException
Thrown when SolidWorks doesn't start within the timeout period.
- InvalidOperationException
Thrown when unable to find or modify registry settings.
StartInstanceByYear(int, int, ProcessWindowStyle, bool)
Starts a new SolidWorks instance for a specific version year (e.g., 2023, 2024, 2025).
public SolidWorksInstanceInfo StartInstanceByYear(int year, int timeoutSeconds = 60, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, bool modifyAllVersions = true)
Parameters
yearintThe SolidWorks version year (e.g., 2023, 2024, 2025).
timeoutSecondsintTimeout in seconds to wait for SolidWorks to start.
windowStyleProcessWindowStyleWindow style for the new process.
modifyAllVersionsboolIf true, modifies registry for all installed versions to prevent conflicts.
Returns
- SolidWorksInstanceInfo
Information about the started SolidWorks instance.
StartInstances(int, string, int, int, ProcessWindowStyle)
Starts multiple SolidWorks instances sequentially.
public List<SolidWorksInstanceInfo> StartInstances(int count, string executablePath = null, int timeoutSecondsPerInstance = 60, int delayBetweenStartsMs = 2000, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)
Parameters
countintNumber of instances to start.
executablePathstringPath to SLDWORKS.exe. If null, uses default installation path.
timeoutSecondsPerInstanceintTimeout in seconds for each instance to start.
delayBetweenStartsMsintDelay in milliseconds between starting each instance.
windowStyleProcessWindowStyleWindow style for the new processes.
Returns
- List<SolidWorksInstanceInfo>
List of information about the started SolidWorks instances.