Hi everyone, I'm trying to run a custom Creo parametric C++ plugin by creating a Process in C# and calling "parametric.exe".
I'm using Creo Parametric 7.0.9.0 with C# .NET Framework 4.8.
This is the C# code to create the process and run parametric.exe:
process.StartInfo.FileName = "\"C:\Program Files\PTC\Creo 7.0.9.0\Parametric\bin\parametric.exe\"";
process.StartInfo.Arguments = $"+Assypath=\"{_settings.WorkingDirectory}\\{assemblyName}\" ";
process.StartInfo.Arguments += $"+Output_Dir=\"{_settings.WorkingDirectory}\" ";
...
// Some other arg setting...
...
process.StartInfo.UseShellExecute = false;
process.EnableRaisingEvents = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.Exited += (sender, args) =>
{
int exitCode = process.ExitCode;
if (exitCode == 0)
{
Logger.LogMessage("Ran successfully");
}
else
{
Logger.LogMessage($"Exited with error code: {exitCode}");
}
};
var errorData = new StringBuilder();
process.ErrorDataReceived += (sender, args) => errorData.Append(args.Data ?? string.Empty);
_ = process.Start();
process.BeginErrorReadLine();
bool exited = process.WaitForExit(_settings.CreoParametricTimeoutMs);
Logger.LogMessage(errorData.ToString());
However, every time the process exits, it returns a Process.ExitCode of 1 and the errorData has the following errors:
Files\PTC\Creo was unexpected at this time.
The process cannot access the file because it is being used by another process.
The plugin calls ProEngineerEnd() to close the Creo session, but even if I remove that call from the plugin and close the Creo window manually, the same error is returned.
I think that the spaces in the parametric.exe path (C:\Program Files\PTC\Creo 7.0.9.0\Parametric\bin\parametric.exe) are causing the issue in the first error since it matches the "Files\PTC\Creo" section, but I'm not sure who or what is accessing that path value incorrectly. The plugin runs correctly and throws no errors of its own.
I'm not sure how to debug the second line as I'm not sure what file is causing the access error (unless it's talking about the "Files\PTC\Creo" path?)
Are these common errors that can be ignored since the Creo plugin runs successfully all thing considered? Should I just ignore the exit code 1?
Any help with this issue would be greatly appreciated. Thanks!