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?
Edit: Answer – I have managed to find a work around. I will just leave it as an answer to my question.
Edit: Oh, I forgot to mention, 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.
2
Answers
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 - CopyTesting Relay Board CommunicationbinDebugTesting Relay Board Communication.exe", I just run "....Testing Relay Board CommunicationbinDebugTesting Relay Board Communication.exe - Shortcut.lnk" which is a link to the executable that won't run in command line.
I also try to run a Dymo from another application and wanted to use this code for a start. When I enter this code I can not run it. ‘Start Debugging’ is not available and behind the green Start button it says ‘Attach to Process’. But what should I attach to get the > Start or better; the debug option?
Thanks in advance.
PS. I’m not familiar with c# nor Visual Studio (but you probably already guessed that).