|
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 have tried to pass command line arguments to IrfanView to rotate a image, the code is below, the commented code works without a problem. The problem is the uncommented code, when the process is started, there are no errors but no changes are made to the image. I have tried the proper syntax code in VB.NET and it works as expected, any insight as to what's wrong?
//args = file1 + " " + "/rotate_r " + "/convert=" + file2 + "/killmesoftly";
//args = " " + file1 + " " + "/rotate_r " + "/jpgq=100" + "/convert=" + file2 + "/killmesoftly";
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
|
|
|
|
|
I don't know why newbs always insist on breaking up what should be a single string into a bunch of string concatenations, making it harder to debug your code. You can do this all in one string:
args = $"{file1} /jpg_rotate=(3,1,0,1,0,0,0,0) /killmesoftly";
Take a closer look at your uncommented code:
args = " " + file1 + " " + "/jpg_rotate=(3,1,0,1,0,0,0,0)" + "/killmesoftly";
This will result in an arguments string that looks like this:
[file1]
Notice there is no space before the /killmosoftly switch. That will probably generate an error for the Irfan command.
modified 55 mins ago.
|
|
|
|
|
Adding to Dave's wise words, your uncommented string doesn't specify an output file, so it may very well execute the process and discard the result.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hi everyone,
hard to phrase a title for what i am looking for, therefore following explanation.
I have the requirement to establish communication to a device via Secure WebSockets using TLS 1.3 and need to research on how i can do that from our applications that sadly are running with .NET Framework 4.0.
What i found out yet is that it might be a pain to get Secure WebSockets with TLS 1.3 running with that old framework and therefore i need to find a proper solution on how to circumnavigate this issue.
My Idea:
The old application will talk with a service / server specifically designed to just do the communication part, meaning the old stuff doesn't get touched and the service can run with .NET 8, which obviously should support the requirement.
What my questions are:
Does anyone have an idea or can point me into the right direction in terms of:
- How do they both communicate with each other (I would prefer not to use any COM stuff if possible)
- What type of project to use for the .NET 8 app?
--> I heard of the "Worker services in .NET" which seems the right thing to me, since the "service" needs to be run on demand (Only if required to be used), should support multiple connections and should not show stuff on a console while running.
Since the idea is to have a "secure" connection it would be strange if all the info can be read via COM communication. On the other hand that's a fairly new area for me, so i have no clue if that is just the way to go and does work "secure" as well. My head just says COM sounds old and may be wrong, but don't hate me for that
Additionally:
Regarding installation or installation of a "Service" there won't be much of issue afaik, in the end the user simply doesn't care, shouldn't know or bother how the magic works behind the UI.
Many thanks in advance!
Rules for the FOSW ![ ^]
MessageBox.Show(!string.IsNullOrWhiteSpace(_signature)
? $"This is my signature:{Environment.NewLine}{_signature}": "404-Signature not found");
|
|
|
|
|
HobbyProggy wrote: TLS 1.3 running
C# doesn't do TLS unless both the libraries and OS have the correct versions. Following has the magic of SecurityProtocolType.Tls12 and comment mentions the version of .Net needed.
https://stackoverflow.com/questions/55240173/how-to-handle-httpwebrequest-c-sharp-with-tls-1-3[^]
For OS following claims Windows server 2022 is needed. Although I thought there was a prior version where it could be turned on.
TLS1.3 is it supported? - Microsoft Q&A[^]
There are also encryption protocols that must be enabled or disabled.
Now all of the above is to make it easy. Question might be if someone could add a native library of some sort (not C#) and implement it from scratch. After all linux presumably has it and that means the code should exist. But I have not researched that myself.
|
|
|
|
|
|
I downloaded and installed a package from nuget
When I compile source code exe file cannot find dll file
but after package installation dll appeared on disk
How to fix it without using visual studio or copying dll's
modified 2 days ago.
|
|
|
|
|
Check your project references, and if they all look OK, check the folders: the compiled DLL needs to be in the "bin" folder under the relevant project. If you have the references set correctly, the required non-system DLL files will be built and then copied to the bin folders.
"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 added reference to the dll at compile time and executable was created but executable cannot find dll to load
This program has two files one cs and one dll
I compiled it from command line with csc given with Windows
(Windows gives us .Net Framework 4.8 and C# up to 5.0)
(It is simple program with one cs file and one dll file so i don't want to create project for that)
Yes copying the dll to the program folder is kind of solution but wasting disk space
Such copying is unnecessary in my opinion and better way would be for example choosing path to dll
for executable
I would like to do not need copying dlls to program folder for each program which uses that dll
Now I am trying to extract data from html and I found nuget package for this
Some time ago I found Rational number class I downloaded and installed it via nuget and executable couldn't
locate dll
But when I compiled dll from sources there was no problems with finding and loading dll by executable
|
|
|
|
|
Check the build parameters: if your exe is 64 bit and the DLL is 32 then it can't load it, and vice versa.
"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!
|
|
|
|
|
Hello, I divided my solution for a third party dll in VS 2022 into
a) 1st.dll in project 1
b) 2nd.dll in project 2
Project 1 references project 2 and creates instances of objects based on classes in project 2.
Both dlls are copied to the same folder but only 1st.dll is loaed by an Application to which I have no access except vie an API used by my 1st.dll.
My understanding was, that 2nd.dll is kind of linked to 1st.dll, so that it is no necessary in the same folder. I also only want to ONLY ship 1st.dll. But when I delete 2nd.dll from the path my approach does not work.
Question:
What do I have to to, so that it is sufficient to only have 1st.dll at the customer side available ?
|
|
|
|
|
No, the .DLL's are not "linked" in the way you're seem to be thinking. 2.dll is NOT "linked into" 1.dll. They will remain separate .DLL's when you compile them. You said it yourself, 1 REFERENCES 2, so the two .DLL's must be shipped together.
You have a choice. You can either rewrite and get rid of the second project, copying your code in the 2 project into the 1 project, then update the references and namespace using statements, rebuild and you'll get your 1.dll file you can ship.
OR
You can try to use ILMERGE[^] to combine both .DLL's into the same file. You may or may not get away with doing this.
|
|
|
|
|
Hello & thank you for your reply. Is there a reason why in C#/.Net we do not have statically linkable libraries (.lib-Files) like in C/C++ ?
|
|
|
|
|
No, static linking is not directly supported. If you want to know why, ask Microsoft.
The closest approximation to it is to use ILMerge or similar. Not every library is compatible though, like WPF assemblies or code that uses Reflection.
|
|
|
|
|
Imagine you have a switch with anything between 3 and a silly amount of comparisons, at which size does a lookup dictionary with delegates get faster?
I'm fully aware there are no exact answers to this, I just want some elaboration on what's affecting the performance.
|
|
|
|
|
Let me add to that question - not using a lookup dictionary, but a 2D array:
I regularly see people claim that they program in a 'state machine' fashion (breaking numerous rules for state machine programming, but that's not the question here), essentially as a switch or sequence of if-else on the event, each switch/else alternative being another switch/if-else on the current state. I find that coding style terrible, impossible to maintain.
My coding style for state machines is creating a 2D array of Action and Output delegate references and a NextState value, possibly headed by a predicate delegate reference (so the array becomes a 2,5D one). In the worst case, three delegates must be called, plus one per failing predicate. In the simplest case, a single delegate is called (no predicate, no output).
Obviously, there is also the initial indexing of the state table on event and state, and if the entry has a chain of predicated alternatives, the code to iterate over them. This is part of the basic transition mechanism, unrelated to the specific table/transition.
This way of coding state machines has so many advantages that I will be very reluctant to change it. Yet I wonder: Is this indexing and delegate calling a CPU costly way of doing it, compared to nesting of switch / if-else in 2-3 levels? Are there performance pitfalls I should be aware of when indexing / calling delegates?
Religious freedom is the freedom to say that two plus two make five.
|
|
|
|
|
Jörgen Andersson wrote: between 3 and a silly amount of comparisons, a
Presumably you mean cases.
Jörgen Andersson wrote: y with delegates get faster?
At the point where I have profiled the application (not the code) with realistic production data and determined that the specific code is in fact a performance bottle neck.
At that point then I would look at the design not the code to determine if there was some completely different way to do it.
|
|
|
|
|
Interesting question, to which I wouldn't like to guess the answer, but here's what I'd consider.
Firstly, what is it that is being switched? If its something primitive like an integer, the switch code would I expect boil down to a collection of CMP and BEQ instructions (compare and branch). These would be stupidly fast, and because they are consecutive in memory are likely to benefit from CPU caching, so in that instance, an awful lot of switch cases could be compared in the time of a dictionary look up.
If you are switching on strings though, things get more complicated. To do the dictionary look up, first the string needs to be hashed to give a bucket index, then an equality check is needed to make sure it matches. The switch statement doesn't need to do the hash, but has multiple equality checks to do, so I suspect the answer here boils down to the ratio of time taken to hash vs. time taken to do an equality check. So then you get into the realms of how similar are the strings? To check for equality, if the first character is different you can just bail out and fail the test quickly, but if its the last you have to go through every character before you can pass or fail the test.
It'd be interesting to profile this, but somehow the idea of creating a switch statement with hundreds/thousands of cases sounds unpleasant, I have no idea whether a compiler would accept it and would be completely impossible to work with.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: Firstly, what is it that is being switched?
It's strings.
Rob Philpott wrote: So then you get into the realms of how similar are the strings?
They are quite similar I'm afraid, as the words I'm parsing starts with the category.
So one of the larger switches will be 60+ words where the first difference is at the 19th position.
And as the files that will be parsed are in between GB and TB in size it will probably be worth some optimization.
|
|
|
|
|
Jörgen Andersson wrote: So one of the larger switches will be 60+ words where the first difference is at the 19th position.
Perhaps you could break that down a bit? Validate that the input contains at least 19 characters, then switch on the 19th character to decide which path to take.
if (input.Length >= 19)
{
return input[18] switch
{
'A' => ProcessA(input.AsSpan(19)),
'B' => ProcessB(input.AsSpan(19)),
...
};
}
You could even do that with a list pattern[^], although the repeated discards would look quite messy.
return input switch
{
[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 'A', ..] => ProcessA(input.AsSpan(19)),
...
};
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 30-Apr-24 6:24am.
|
|
|
|
|
C# has gone a bit bonkers hasn't it? I still have to look up how to do this 'new' stuff. Although I do like being able to create empty arrays with [] etc.
Oh, and I think you're out-by-one: return input[18] switch
Regards,
Rob Philpott.
|
|
|
|
|
List pattern looks interesting
|
|
|
|
|
Ah ok, so is it that you've got these large files to process and you're trying to optimise the switching (state changes) for speed? Which approach are you using at the moment (switch vs. array lookup/not dictionary, sorry just read your update)?
I suppose another difference is that switch statements are compile timed things, turned into code, whereas dictionaries are created and used at runtime. Does this mean the switch/state change logic is fixed in advance?
I think the only well to tell really is try both methods and see which is quicker (if noticeably so). What I would say is I'd expect them both to be fast, so is this really the bottleneck to performance gains, or could something else be optimised? Multithreading/pipelining etc. TPL Dataflow (if you're in .NET) is good for this.
Regards,
Rob Philpott.
|
|
|
|
|