Reputation: 135
I have a C# program that I can run successfully from inside Visual Studio with the "Start without debugging" button, and I can run it successfully by double clicking on the executable in the file explorer. But I cannot run it through Command Prompt (Oh, yeah. I'm on Windows by the way) and there is no error returned. [Also, I cannot debug the project with "Start" button in Visual Studio. For some reason it throws an error if debugged, but not simply run].
It is a simple program that prints a label on a DYMO labeler. The issue likely is with something in DYMO.
I do not recommend DYMO.
Here is the minimal reproduceable code
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DymoSDK.Implementations;
using DymoSDK.Interfaces;
using System.IO;
namespace Testing_Relay_Board_Communication
{
internal static class Program
{
static void Main()
{
DymoSDK.App.Init();
string path = @"..\..\meee.dymo";
string lines = File.ReadAllText(path);
IEnumerable<IPrinter> printers = DymoPrinter.Instance.GetPrinters();
printers.ElementAt(0);
IDymoLabel ddd = DymoLabel.Instance;
ddd.LoadLabelFromFilePath(path);
DymoPrinter.Instance.PrintLabel(ddd, printers.ElementAt(0).Name);
return; //stop the program here. I don't need it to do anything else
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
I need to run this program from another program using the CLI. Does anybody know how to help?
I can only execute dymo code within a WPF project and not just a console project. Even though I can execute the dymo code before the window gets rendered.
Upvotes: -3
Views: 452
Reputation: 135
So I cannot run the executable from the command line. But I can run a link to the executable, and everything woks out just fine.
So instead of running "....\Testing Relay Board Communication - Copy\Testing Relay Board Communication\bin\Debug\Testing Relay Board Communication.exe", I just run "....\Testing Relay Board Communication\bin\Debug\Testing Relay Board Communication.exe - Shortcut.lnk" which is a link to the executable that won't run in command line.
Upvotes: -1