This isn't a limitation of C#, but of how Windows and controls work.
The combobox control you drag over from the toolbox is just a wrapper for a standard Windows control from the Common Controls Library. The way these controls works requires sending messages to the controls to get them to do things, like add an item to a collection in your combobox.
Not working... as I mention previously, the MessageQueue.GET... methods show the Public and/or Private queues but not the OutGoing Queues...
I can "create" outgoing queue by send message with exact syntax of connection but can't get the list of current outgoing queues...
I have a dll created with delphi language (Borland Delphi 7) which thus contains functions in delphi which I would like to use in C# under Visual Studio 2017. It is a native dll.
I want to use for example the GENERATE_FILE function contained in test.dll.
Delphi code :
procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
procedure GENERATE _FILE(Path, Input_File : AnsiString); stdcall;
GENERATE_CALC(Path_And_File, CRC32, Total, err);
In C#, I want to use the function GENERATE_FILE contained in test.dll but what is the type of the parameters Path and Input_File in C# ?
Below is an example of C# code I made to use test.dll in delphi in C#. I setstringas a type for parameters of the function GENERATE_FILE.
Public class Program
[DllImport("test.dll", CharSet = CharSet.Ansi)]
publicstaticexternbool CREATE_FILE(string pathDirectory, string filename);
staticvoid Main(string args)
I added the test.dll in Visual Studio by right clicking on the project then add an existing element, then, in the properties of the test.dll, I put "Content"in Generation action and I put "Always copy "(output directory). When I run the solution, I have the test.dll in bin\Debug.
But when I test this program, I get the following error at the line that contains:
System.DllNotFoundException: 'Unable to load DLL' test.dll ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) '
How to solve this problem ?
I think the issue is about the type of parameters in the function GENERATE_FILE. What are the type equivalents between delphi and C# for the function GENERATE_FILE ?
Thank you for your help.
I am planning a different approach - have written half of the code, but it is not ready for testing yet. In my case, it is one subsystem written in C++, others in C#.
Rather than messing around with P/invoke and all sorts of parameter transfer, synchronization and whathaveyou, I run it as two processes. The two subsystems have limited, and structurally very simple, data interchange. I find it far easier to exchange those data through a named pipe. The data format is application specific, but as these two subsystems belong to the same application, it is like an internal API with no more need to adhere to a standard than any other internal interface.
I like strong isolation between subsystems and modules. It gives greater freedom within each subsystem/module, and it keeps the architecture clean. And it makes the system flexible: If I later want to replace that C++ subsystem with one written in Cobol, say , I could do so without any effect on the C# part. Well, if I could access that Cobol code through the same P/invoke interface, it might be similar, but now I don't have to worry about that at all.
I am considering the same approach even when the subsystems are all in C#: Threads are fair enough, but do not provide the same isolation as separate processes. When different tasks really are independent (such as one monitoring external equipent/events, the other one interacting with the user; the only common data are the summary reports from the monitor process), they might as well be implemented and run as completely separate entities. Two simple entities are better than one complex.
and when i upload the file i test on, it creates the same sha256 as my code for the file does.
But when i read the data from the longblob and creates a sha256 it is different.
The strange part, is that if i use my website to download the same longblob and saves it as a file... FC cant find any diffeneces.
I'm not familiar with the MySql connector, and I tend not to store files in databases (it does not make much sense to me, it only inflates the DB size). However I noted what follows:
at the bottom of your code there is a while loop, wherein you call Sha256.ComputeHash.
That piece of code looks very suspicious: what remains is just the SHA256 of the last loop iteration, so either you only have one iteration (and the while should be an if), or your logic is wrong (you should collect all the data and then calculate SHA256 on the whole thing).
You could try with a small file, say less than 1KB. Or you could track the while loop behavior, either by adding an output statement, or by using a debugger...
That is the plan, when i come there... but first step is to be able to compare the 2 hash values.
If i upload a file to the database with a hash, it's ok, but for database maintenance purpose i would like to be able to recalculate the value "on the fly", with out having to save all 3000+ files one at a time to recalculate hash value.
And i just can wrap my brain around the difference... basicly its an array of bytes - both the longblob and the filestream.
As for saving the file to database... this a give premis for this task. I have very limited space in the OS environment, but unlimited space in the database.
Hello, I'm new to the forum and new to C# and programming in general so any help with this is appreciated.
I have two arrays of strings. sTime holds the string TimePosition and the second holds a text string.
I have an Audio file playing using mediaPlayer.
I am trying to sample the mediaPlayer position to trigger an event when it reached a desired time.
There will be multiple sTimes that will be at random positions throughout the Audio File.
Each time the mediaPlayer.position compares to the sTime it will display the text string associated with the sTime.
Think Teleprompter or Karaoke Player.
I think mediaPlayer is not robust enough the capture every millisecond to compare, so I miss the event.
I could try comparing to see if position is greater or equal to 10.000 but I'll miss 10.678 but this code never triggers the MessageBox.
It also would be more efficient if I knew how to capture the mediaPlayer.position directly and compare it to a variable without all the wasted conversion time. But I don't.
I read this source code then I built my form to draw a rectangle and make it able to resize/ move it, some how, the logic I follow is wrong, because the mouse when it moves up the small rectangles then the mouse cursor should change, it is some times change and others not, even in the console I can see the mouse cursor should apply. Also if I try to resize it then a new rectangle drawn. My form source code:
unfortunately your code already contains a lot of details, making it hard to pinpoint what exactly is the problem. IMHO one should always work on smaller pieces and get them to run satisfactorily before adding to them.
So I will limit my reply to a number of comments, which taken together really indicate I'm not so happy with the current code:
It seems you want a hovering mouse to show what would happen if the mouse were clicked in its current position; that should consist of:
- deciding which if any rectangle is hovered over;
- deciding how it is hit (i.e. in the size handles or in the body).
As size handles overlap the actual rectangle, one must be careful in what order the Contains() logic is applied. I would probably use a slightly larger rectangle and check that first, assuming a move is intended, and on a hit then check whether any of the size handles is hit (which would overrule the move).
Once the mouse goes down, the decision (from #1) should be frozen, and data should be set up to initiate the actual move/resize.
Back in the mouse move handler, the actual action should happen until mouse up is reached.
As a consequence:
- the MouseMove handler should have two completely distinct halves, one for the decision process (mouse still up), one for the execution (mouse down); a single bool (set/cleared by MouseDown/MouseUp) would decide between the halves.
- the MouseDown handler shouldn't do much at all.
If I were creating something like this, I would start from scratch, and initially keep it as simple as possible.
I would also choose variable and method names carefully, e.g. DrawResizableRectNode isn't OK as it does not draw at all.
Added later, two smaller issues I forgot to mention:
There is no need to create a Graphics object explicitly; you get it for free as one of the properties of the PaintEventArgs in a Paint handler.
You should keep Paint handlers as lean as possible, in particular you should create the drawing objects (Pens, Fonts, ...) you need only once, and save them in class level variables for reuse. In your case, that applies to rectPen.
And if you fail to keep them around, it is your duty to dispose of them (by calling their Dispose method or applying a using statement), in order to avoid Windows problems such as handle shortages.
Your notes are helpful to help where to look in my code, but still I can't get it work
I started from scratch and made the first step is just to move the rectangle, my issue now is to calculate the new starting XY, but it seems resize the rectangle when mouseUp: