delphi - C# application with unmanaged DLL freezes whole system -
I am currently writing a software in Visual Studio 2012 for communication with RFID-card.
The problem is: My software is running fine on the machine, on which VS 2012 is installed on other systems it freezes itself or the whole system I have it x32 and x64 configuration on X XP / 7/8 Trying to do with I am using .NET 4.0.
After connecting to the reader, the software background worker, which starts with an order for the invoice card in the reader RF-field with the reader (at the rate of 200ms), reader. What is the actual accident is 10 sec 20 seconds after the reader is connected, in the Private Static Extraction Inventory (Intex ExtraLAN, Infrastructure Experiences) [in] Ref Intel Intel, Interpret UID, UINT 32HFFtime);
public string getCardID () {if (ConnectConnectet ()) {IntPtr UIDs = IntPtr.Zero; Int lane = 2 * 8; Byte [] zero = new byte [lane]; UID = Marshall Olochem; len; Thread.Sleep (50); Martial Copy (zero, 0, UID, lane); Int count = 0; Int erg; String writ; Try {erg = inventory (lane, ref count, UID, 50); } Grip (External Exposure) // It does not capture anything (i has set & inherited status exception policy enabled = "true" />) {return "\ 0"; } Finally {ret = Marshal.PtrToStringAnsi (UID, Lane); ITPTR RSLT = Local Free (UID); GC.Collect (); } If return (erg == 0) returns; And return zero. To string (); } And return "\ 0"; } DLL Delphi has written, code is DLL command:
function inventory (maximum: integer; var count: integer; uid: pibetarrere; hfftime : Cardinal = 50): Integer; STDCALL; I think there may be a memory leak, but I do not know how to find it ...
Edit:
I've added some ideas (obviously GC.Collect (), try-catch-end in my code, but it still does not work.
Here is the code that receives the call cardID ():
The action that runs every 200ms:
if (! Bgw_inventory.IsBusy) bgw_inventory.RunWorkerAsync (); Async backgroundWorker does: private zeros bgw_inventory_DoWork (object sender, DoWorkEventArgs e) {if (bgw_inventory. Cancellation payment) {e. Canal = true; Return; } Else {String UID = Reader .getCardID (); If (bgw_inventory.CancellationPending) {E.Canel = true; Return; } If (UID.Lambi == 16 & amp; UID.IndexOf ("\ 0") == -1) {setCardId (UID); If (all card. Of Canton (UID)) {All cards. Add (UID, New Card (UID)); } If (readCardActive || Dactivatecard Active || ActivitycardActive) {If (Last Action Card! = UID) ActionCard = UID; And set workingstats ("OK", color. Form ARBB (203, 218, 138)); }} And {setCardId ("none"); If (readCardActive || Deactivatecard Active || Active Academy) setWorkingStatus ("Waiting for the next card", Color. Yellow); }}}
Edit
So far, I have created some small recycled code (updated above). Now just app "TempConnect.dll "Crashes with 0xC00000FD (stack overflow) It does not happen if VS2012 is installed on the system or if I use DLL with native delphi! Does anyone have any other ideas?
Edit
Now I have staxed it by creating DLX and found something weird: if it is called from my C # programm and is found, then staxes Constantly changing up and down. If I do this from a natural diploma program, stacks are stable! So I check ahead, but I have no truth, what I have to find ...
I'm a bit worried how he is using the martial object as you are afraid of memory leak, it seems that memory is often allocated, but I do not release it clearly I am doing Garbage Collector Should (operative words) take care of that, but you say that you have some unmanaged code in the mix. For some good techniques, it is difficult with post information to find memory leaks in NIT. This will give you a ton of information about how memory is getting used to the managed end of your code (i.e., the part that you can control directly). Use Windows Display Monitor with breakpoint to track overall health of the system. If .NET behaves in behavior, but WPM is showing some sharp spikes, it is probably in unmanaged code. You can not really control anything, but there are your uses, so it's probably time to return to the document at that time.
Comments
Post a Comment