|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
I was able to get 2 seperate processes to run the tera term applications within WinForm successfully. I have a DUT that has 2 ports and each process to communicate with one of the port. Manually sending the command within the tera term process window works well.
However, I have the list of commands using DataGridView above two terminals. I was planning on having the user to click on the command from the datagridview and send the command to one of the tera term process.
I'm not sure on how to issue the command string to the process. Been searching online and wasn't sure on how to do this.
Any ideas? If you want me to plug in the code, I would be happy to do so with what I did.
modified 6hrs 15mins ago.
|
|
|
|
|
Hi. I'm working with Visual Studio 2022 and I have an application that uses excel. I'd like to know your opinion on the interfaces available: Interop, ClosedXML or any other. Which one is the best?
Thank you.
|
|
|
|
|
There is no "best", only most appropriate, and what's most appropriate depends on your application type and what exactly you're going to be doing with either Excel or an Excel sheet.
|
|
|
|
|
Hi, Dave.
I search for an easy to use interface with a relation of the available commands. I know Excel reasonably well and want to create visually good sheets.
Do you have any suggestion?
|
|
|
|
|
The OpenXML SDK can create workbooks and sheets and do it a lot faster than Excel Interop.
The ClosedXML SDK can do the same thing, but it's a third-party library.
The problem with using either is the learning curve. You're going to have to learn how workbooks and sheets are built and rewrite your code to do the same thing.
|
|
|
|
|
Thanks, Dave. I'll consider it.
|
|
|
|
|
Dave is exactly right - it depends on what you are trying to do with the Excel file.
But ... if you are trying to use an Excel file as a database, then one word applies: "DON'T!"
Excel is a spreadsheet, and while it can work quite well as a database for single user small scale projects, as soon as the data size becomes in any way significant performance drops off a cliff.
Part of this is the way .XLSX files work: they are a zip file containing a bunch of XML files. And XML files are text based - human readable if you are patient. So making any change to an XLSX file means opening the zip, decompressing it, reading the whole XML file, making changes, writing the XML back, then zip compressing it all back to an XLSX.
That's fine for a small dataset, but once it grows ... life is too short. Then there ios the fun if two or more users want to work with the same data: Excel won't allow that, so you have to open the Excel connection in your code, wait for the file to be free, make your changes, and close the connection.
If you want a DB, use a DB: SQLite, Access, MSSQL, MYSQL, ... depending on what exactly you have available, and are doing. But don't use a spreadsheet - it will just cause you massive problems later on!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hi, OriginalGriff.
I don't have the intention of using Excel as a DB. In fact I use SQL Server. Excel is only a way of showing results in a pleasant way. At this time I use Interop Excel interface, but it's very difficult to find the commands and its variations. If you know a way of getting the library of these commands, I'd appreciate to know it. Thanks.
|
|
|
|
|
Excel as a display control seems somewhat overkill - especially as it requires Excel to be fully installed (and licenced) on the target machine.
What does it do for your "pleasant display" that a standard DataGridView doesn't?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I know Excel reasonably well, but I know only the basic of DataGridView. Excel is installed, and also, if I want other people to see the data, Excel is more appropriate.
|
|
|
|
|
Without seeing any code we can only guess what may be wrong. You should run your code in the debugger to see where the error occurs. You can then work backwards to identify why the reference is null.
|
|
|
|
|
Spam, Spam, Spam, Spam!
Lovely Spam! Wonderful Spam!
Lovely Spam! Wonderful Spam!
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Lovely Spam! (Lovely Spam!)
Lovely Spam! (Lovely Spam!)
Lovely Spam!
Spam, Spam, Spam, Spam!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Lobster Thermidor au Crevettes with a mornay sauce served in a Provencale manner with shallots and aubergines garnished with truffle pate, brandy and with a fried egg on top and spam.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can I replace the egg with a sausage?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Dang, missed again.
|
|
|
|
|
Hello,
I have a VS project to implement a dll.
This dll is a kind of "Master" dll and it should be possible to extend its functionality with "Extension" dlls without touching the "Master" dll.
The "Master" dll should check everytime when it is loaded, what other dlls are available and thus extend or reduce its functionality by itself.
If "Extension" dlls are missing, the "Master" dll should recognize this without any error and function with reduced functionality.
Any hints from your side which approach would make sense here.
|
|
|
|
|
That sounds the wrong way round to me. The base (not master) dll should not have, or even need, any knowledge of extensions. The point of an extension class is to offer extra or enhanced functionality to an application. So the only process that needs to know whether the extensions are present is the application that wants to use its features.
|
|
|
|
|
The "Master" dll (or base dll) is the application in this case. It is a plugin dll for a software where i do not have the source cose and also extends the functionality of that software. So you could consider the base dll as the application.
|
|
|
|
|
That is not something I have ever had to work on.
|
|
|
|
|
Hi,
I have an appliction that loads extensions from a specific folder; each extension is a class that derives from a base class DTF_ComponentBase , which happens to be a UserControl as all extensions need a very similar dialog window. Each extension is built into a separate DLL file. This is the heart of the code that loads those DLL files:
private readonly List<DTF_ComponentBase> DTFlist=new List<DTF_ComponentBase>();
...
DTFlist.Clear();
string folder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
log("folder=" + folder);
Directory.CreateDirectory(folder);
string[] dlls = Directory.GetFiles(folder, "*.dll");
Exception firstException = null;
List<string> errors = new List<string>();
foreach (string dll in dlls) {
if (dll.Contains("LPplatformDLL.dll")) continue;
try {
log("File: " + dll);
if (dll.Contains("DTF_ComponentBase.dll")) continue;
Assembly asm2 = Assembly.LoadFile(dll);
Type[] types = asm2.GetTypes();
foreach (Type type in types) {
if (type.IsSubclassOf(typeof(UserControl))) {
UserControl uc = (UserControl)Activator.CreateInstance(type);
if (uc is DTF_ComponentBase comp && !comp.Skip) {
DTFlist.Add(comp);
break;
}
}
}
} catch (Exception exc) {
if (firstException == null) firstException = exc;
errors.Add("Error loading "+dll+"; "+exc.Message);
}
}
At the end DTFlist contains all the extensions that were found and instantiated; a foreach loop can then be used to issue commands such as Start, Stop, ... whatever the base class provides.
Hope this helps.
Luc Pattyn [My Articles]
The Windows 11 taskbar is a disgrace; a third-party add-on is needed to reverse the deterioration. I decline such a downgrade.
modified 28-Sep-24 16:01pm.
|
|
|
|
|
Presumably you have a well designed understanding of what the additional functionality is in general.
There are a number of design patterns that might be useful in structuring the code.
- Chain of responsibility
- Fly weight
- Decorator
- Composite
- Template
As suggested other response you use reflection to load classes dynamically. Those will need either an interface or base class for your code to interact with it. You will need to at least consider dependencies (other dlls required by the dll that is loaded) in that they must be located somewhere. Either load those also dynamically or insure that the application can find them.
AtaChris wrote: with reduced functionality
That is a design and business consideration which cannot be addressed generically. For example perhaps you want to switch out your database driver. But the application cannot operate without any database. Same thing with supporting multiple card card processor interfaces. If you expect two but only find one then that is ok. But if you find none then the application probably cannot continue.
There are ways around failure cases but they add significant complexity and even business risk.
|
|
|
|
|
I'm having trouble getting my mind around how a default method in an interface works.
Picture the below interface and default method implementation:
public interface IClientForm
{
delegate void WindowClosedDelegate(object sender, WindowEventArgs args);
event WindowClosedDelegate OnClosed;
long FormId { get; set; }
UIContextClass UIContext { get; set; }
IClientForm ParentForm { get; set; }
void Window_Closed(object sender, WindowEventArgs args);
}
public static class IClientFormHelper
{
public static void SetUiContext(this IClientForm iClientForm, UIContextClass _UiContext)
{
iClientForm.UIContext = _UiContext;
iClientForm.FormId = _UiContext.AppContext.ClientGetUniqueFormId();
iClientForm.UIContext.AddForm(iClientForm);
iClientForm.OnClosed += iClientForm.UIContext.Window_Closed;
}
} The main problem I see right now is that the default method code never runs. I assume the code is supposed to run as soon as I call the setter for UIContext that's declared in the main interface.
Apparently, this is something I don't understand.
What I want is for every IClientForm window to run the default code whenever the UIContext setter is called for that form, so that each separate window class doesn't need the same code repeated inside of it.
Can someone spot what I've done wrong and point me in the right direction? I sincerely appreciate your time.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|