Runnnig this code getting this error, could any one help figure out what is going on here?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace LSATest
{
class Program
{
public static List<string> listBox1 = new List<string>();
static void Main(string[] args)
{
DateTime systime = new DateTime(1601, 1, 1, 0, 0, 0, 0); //win32 systemdate
UInt64 count;
IntPtr luidPtr = IntPtr.Zero;
LSAClass.LsaEnumerateLogonSessions(out count, out luidPtr); //gets an array of pointers to LUIDs
IntPtr iter = luidPtr; //set the pointer to the start of the array
for (ulong i = 0; i < count; i++) //for each pointer in the array
{
IntPtr sessionData;
LSAClass.LsaGetLogonSessionData(iter, out sessionData);
LSAClass.SECURITY_LOGON_SESSION_DATA data = (LSAClass.SECURITY_LOGON_SESSION_DATA)Marshal.PtrToStructure(sessionData, typeof(LSAClass.SECURITY_LOGON_SESSION_DATA));
//if we have a valid logon
if (data.PSiD != IntPtr.Zero)
{
//get the security identifier for further use
System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(data.PSiD);
//extract some useful information from the session data struct
string username = Marshal.PtrToStringUni(data.Username.buffer).Trim(); //get the account username
string domain = Marshal.PtrToStringUni(data.LoginDomain.buffer).Trim(); //domain for this account
string authpackage = Marshal.PtrToStringUni(data.AuthenticationPackage.buffer).Trim(); //authentication package
LSAClass.SECURITY_LOGON_TYPE secType = (LSAClass.SECURITY_LOGON_TYPE)data.LogonType;
DateTime time = systime.AddTicks((long)data.LoginTime); //get the datetime the session was logged in
//do something with the extracted data, ie, add to a display control....
listBox1.Add("User: " + username + " *** Domain: " + domain + " *** Login Type: (" + data.LogonType + ") " + secType.ToString() + " *** Login Time: " + time.ToLocalTime().ToString());
}
iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LSAClass.LUID))); //move the pointer forward
LSAClass.LsaFreeReturnBuffer(sessionData); //free the SECURITY_LOGON_SESSION_DATA memory in the struct
}
LSAClass.LsaFreeReturnBuffer(luidPtr); //free the array of LUIDs
}
}
}
The error is because sessionData is null. That's because LsaGetLogonSessionData is failing. To diagnose this further, you need to start paying attention to the return value of the API functions and checking error codes in case of failure. That's your next step.
As an aside, you have declared the count variable incorrectly. In the C header file it is declared as ULONG. That's an unsigned 32 bit integer which makes it uint in C#. I've not checked anything more than this.
Related
I am a new bee to C# programming. I have a zebra bar code scanner. I made a C# code according to the software user manual. I am able to print the scandata. However this data consist of all the information about the scanner. It has serial number,module number,GUID,datatype and datalabel.
This datalabel is the information about the bar code. I am interested in this datalabel only. I need to develop further code using this datalabel.
How can I print only the datalabel?.
Here I am attaching my code. Thank you.
namespace ConsoleApp_scandata
{
class Program
{
//declare the core scanner class
static CCoreScannerClass cCoreScannerClass;
static void Main(string[] args)
{
cCoreScannerClass = new CoreScanner.CCoreScannerClass();
//CALL OPEN API
short[] scannerTypes = new short[1]; //scanner types intrested in
scannerTypes[0] = 1; // set all scanner types to 1
short numberOfScannerTypes = 1; // size of the scanner type array
int status; // Extend API return code
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
if (status == 0)
Console.WriteLine("CoreScanner API OPEN");
else
Console.WriteLine("CoreScanner API CLOSED");
// Lists all scanners connected to the host computer.
// will return nothing
short numberOfScanners;
int[] connectedScannerIDList = new int[255];
string outXML;
cCoreScannerClass.GetScanners(out numberOfScanners, connectedScannerIDList, out outXML, out status);
//below does not work because string is an xml file and is never NULL
Console.WriteLine(outXML);
// Console.WriteLine(outXML.ToString());
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
int opcode = 1001;
string inXML = "<inArgs>" +
"<cmdArgs>" +
"<arg-int>1</arg-int>" +
"<arg-int>1</arg-int>" +
"</cmdArgs>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
opcode = 2011;
inXML = "<inArgs>" +
"<scannerID>1</scannerID>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
while (true)
{
Console.Read();
}
}
private static void OnBarcodeEvent(short eventType, ref string pscanData)
{
Console.WriteLine("Scannner Event! Scan Data: " + pscanData);
}
}
}
Load pscanData in the XmlDocumentand your are ready to go, just copy this code:
private static void OnBarcodeEvent(short eventType, ref string pscanData)
{
Console.WriteLine("Scannner Event! Scan Data: " + pscanData);
XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.LoadXml(pscanData); //You should use this line as far as your XML tags are correct
xmlDoc.LoadXml("<scandata>" +
"<modeldata>" +
"099909" +
"</modeldata>" +
"<datalabel>" +
"0x68 0x74 0x74" +
"</datalabel>" +
"</scandata>"); //I use this harcoded XML because I don't have your pscanData, just delete this line and uncoment the one above
XmlNodeList datalabel = xmlDoc.GetElementsByTagName("datalabel");
XmlNode allInDataLabel = datalabel.Item(0);
string whatDatalabelContains = allInDataLabel.InnerText;
Console.WriteLine("Datalabel: " + ToText(whatDatalabelContains));
}
Edit: Hex to text
private static string ToText(string yourHex)
{
StringBuilder sb = new StringBuilder();
string[] dataArr = yourHex.Split(new char[] { ' ' });
for (int i = 0; i < dataArr.Length; i++)
{
sb.Append(Char.ConvertFromUtf32(Convert.ToInt32(dataArr[i], 16)));
}
return sb.ToString();
}
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
My program is supposed to take screenshots every 30 seconds and then store them in a hidden folder, C:\SysApp. I'm new to coding and Visual Studio doesn't say there are any errors so I am very confused. Maybe you can help me please? Thanks!
Here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Reflection;
using System.Windows.Forms;
using System.Net.Mail;
using System.IO;
using System.Drawing;
namespace screenshothoop
{
static class Program
{
static void Main()
{
//-----this code will make your program to automatically execute as computer starts----
try
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
Console.WriteLine(curAssembly.GetName());
}
catch { }
//------------------
//------------screenshot loop takes screenshots after 30 sec-----------
int n = 0;
while (n == 0)
{
Thread.Sleep(30000);
OnTimedEvent();
}
//-------------------------
}// main body ends !
public static string st = "";
public static string date = "";
public static string month = "";
public static string year = "";
public static string time = "";
public static string hour = "";
public static string min = "";
public static string sec = "";
private static void OnTimedEvent()
{
st = DateTime.Today.Date.ToString();
time = DateTime.Now.TimeOfDay.ToString();
hour = DateTime.Now.Hour.ToString();
min = DateTime.Now.Minute.ToString();
sec = DateTime.Now.Second.ToString();
date = DateTime.Today.Day.ToString();
month = DateTime.Today.Month.ToString();
year = DateTime.Today.Year.ToString();
Console.WriteLine("The Elapsed event was raised at {0}_{1}_{2} at time {3}_{4}_{5} ", date, month, year, hour, min, sec);
Bitmap memoryImage;
memoryImage = new Bitmap(1000, 800);
Size s = new Size(memoryImage.Width, memoryImage.Height);
// Create graphics
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
// Copy data from screen
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
string str = "";
//------------creating directory--------
if (Directory.Exists("C:\\SysApp"))
{
Console.WriteLine("directory exits");
}
else
{
Directory.CreateDirectory("C:\\SysApp");
File.SetAttributes("C:\\SysApp", FileAttributes.Hidden);
Console.WriteLine("new directory created");
}
//---------------------------------------
str = string.Format("d:\\screenshotn\\screen {0}_{1}.png", date + month + year, hour + min + sec);
//------------
try
{
memoryImage.Save(str);
}
catch (Exception er)
{
Console.WriteLine("Sorry, there was an error: " + er.Message);
}
//---------------------------------------------------------
}
}
}
First you check if C:\SysApp exists, if not, you create it. So far so good. Then you write the image to D:\screenshotn\Etc. which probably does not exists. Or if it does exist, you check the wrong folder for your images. :)
Change this line:
str = string.Format("d:\\screenshotn\\screen {0}_{1}.png", date + month + year, hour + min + sec);
to
str = string.Format("C:\\SysApp\\screen {0}_{1}.png", date + month + year, hour + min + sec);
Your code could be more clearly summarised as:
memoryImage = new Bitmap(1000, 800);
...
str = string.Format("d:\\screenshotn\\screen {0}_{1}.png", date + month + year, hour + min + sec);
...
memoryImage.Save(str);
If you look online for a resource explaining what Bitmap.Save does, found here, you'll see the first parameter describes where the file is written to disk.
As str is set to "d:\screenshotn\sc...", it therefore is being written to a different drive as the one you previously setup.
I am writing a piece of code that queries the existing logon sessions on a windows machine. For network logons, I am trying to find the IP address and/or name of the machine from which the logon was done.
I got the list of logon sessions so far by using LsaEnumerateLogonSessions/LsaGetLogonSessionData, but the IP is nowhere to be found in the returned SECURITY_LOGON_SESSION_DATA structure.
How do I get the IP address/machine name of a network logon session?
DateTime systime = new DateTime(1601, 1, 1, 0, 0, 0, 0);
UInt64 sessionCount;
IntPtr luidPtr;
LsaEnumerateLogonSessions(out sessionCount, out luidPtr);
IntPtr iter = luidPtr;
for (ulong i = 0; i < sessionCount; i++)
{
IntPtr sessionData;
LsaGetLogonSessionData(iter, out sessionData);
var data =
(SECURITY_LOGON_SESSION_DATA)Marshal.PtrToStructure(sessionData, typeof(SECURITY_LOGON_SESSION_DATA));
if (data.PSiD != IntPtr.Zero)
{
System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(data.PSiD);
SECURITY_LOGON_TYPE secType = (SECURITY_LOGON_TYPE)data.LogonType;
DateTime logonTime = systime.AddTicks((long)data.LoginTime);
string authpackage = Marshal.PtrToStringUni(data.AuthenticationPackage.buffer);
string domain = Marshal.PtrToStringUni(data.LoginDomain.buffer);
string username = Marshal.PtrToStringUni(data.Username.buffer);
string dnsDomainName = Marshal.PtrToStringUni(data.DnsDomainName.buffer);
string logonServer = Marshal.PtrToStringUni(data.LogonServer.buffer);
string upn = Marshal.PtrToStringUni(data.Upn.buffer);
Console.WriteLine("SID "+sid+" Type: " + secType + "\t" + domain + "\\" + username + "\tTime: " + logonTime);
if (secType == SECURITY_LOGON_TYPE.Network)
{
// TODO get IP/machine name
}
}
iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LUID)));
LsaFreeReturnBuffer(sessionData);
}
LsaFreeReturnBuffer(luidPtr);
SECURITY_LOGON_SESSION_DATA has a DnsDomainName field:
An LSA_UNICODE_STRING structure that contains the DNS name for the owner of the logon session.
If you need the IP address, do a reverse DNS lookup on that name using gethostbyname() or getaddrinfo().
Alternatively, SECURITY_LOGON_SESSION_DATA also has a Session field. If it is not 0, you can pass it to WTSQuerySessionInformation(), setting the WTSInfoClass parameter to WTSClientAddress and the ppBuffer parameter to the address of a WTS_CLIENT_ADDRESS* pointer variable.
I am using the following code to get and set environment variables.
public static string Get( string name, bool ExpandVariables=true ) {
if ( ExpandVariables ) {
return System.Environment.GetEnvironmentVariable( name );
} else {
return (string)Microsoft.Win32.Registry.LocalMachine.OpenSubKey( #"SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" ).GetValue( name, "", Microsoft.Win32.RegistryValueOptions.DoNotExpandEnvironmentNames );
}
}
public static void Set( string name, string value ) {
System.Environment.SetEnvironmentVariable( name, value );
}
The problem I face, is even when the program is running as administrator, the environment variable lasts only as long as the program is running. I have confirmed this by running a Get on the variable I set in a previous instance.
Example usage of above
Set("OPENSSL_CONF", #"c:\openssl\openssl.cfg");
And to retrieve
MessageBox.Show( Get("OPENSSL_CONF") );
While the program is running, after using Set, the value is returned using Get without any issue. The problem is the environment variable isn't permanent (being set on the system).
It also never shows up under advanced properties.
Thanks in advance.
While the program is running, after using Set, the value is returned
using Get without any issue. The problem is the environment variable
isn't permanent (being set on the system).
Thats because the overload of SetEnvironmentVariable that you're using stores in the process variables. From the docs:
Calling this method is equivalent to calling the
SetEnvironmentVariable(String, String, EnvironmentVariableTarget)
overload with a value of EnvironmentVariableTarget.Process for the
target argument.
You need to use the overload specifying EnvironmentVariableTarget.Machine instead:
public static void Set(string name, string value)
{
Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Machine);
}
According to MSDN the method you are using is just modifying the variable for the runtime of the process.
Try the overload described here: https://msdn.microsoft.com/library/96xafkes%28v=vs.110%29.aspx
This kind of question has already been asked multiple times, check the following links for more information:
Set Env Variable - 1
Set Env Variable - 2
Set Env Variable - Tutorial
Here's an example that permanently updates the User PATH variable by programmatically editing the registry:
// Admin Permission not-required:
// HKCU\Environment\Path
// Admin Permission required:
// HKLM\SYSTEM\CurrentControlSet\Control
// \Session Manager\Environment\Path
public static void UserPathAppend(string path, int verbose=1) {
string oldpath = UserPathGet();
List<string> newpathlist = oldpath.Split(';').ToList();
newpathlist.Add(path);
string newpath = String.Join(";", newpathlist.ToArray());
UserPathSet(newpath);
UpdateEnvPath();
if (verbose!=0) {
System.Windows.MessageBox.Show(
"PATH APPEND:\n\n"
+ path + "\n\n"
+ "OLD HKCU PATH:\n\n"
+ oldpath + "\n\n"
+ "NEW HKCU PATH:\n\n"
+ newpath + "\n\n"
+ "REGISTRY KEY MODIFIED:\n\n"
+ "HKCU\\Environment\\Path\n\n"
+ "NOTE:\n\n"
+ "'Command Path' is a concat of 'HKLM Path' & 'HKCU Path'.\n",
"Updated Current User Path Environment Variable"
);
}
}
public static void UserPathPrepend(string path, int verbose=1) {
string oldpath = UserPathGet();
List<string> newpathlist = oldpath.Split(';').ToList();
newpathlist.Insert(0, path);
string newpath = String.Join(";", newpathlist.ToArray());
UserPathSet(newpath);
UpdateEnvPath();
if (verbose != 0) {
System.Windows.MessageBox.Show(
"PATH PREPEND:\n\n"
+ path + "\n\n"
+ "OLD HKCU PATH:\n\n"
+ oldpath + "\n\n"
+ "NEW HKCU PATH:\n\n"
+ newpath + "\n\n"
+ "REGISTRY KEY MODIFIED:\n\n"
+ "HKCU\\Environment\\Path\n\n"
+ "NOTE:\n\n"
+ "'Command Path' is a concat of 'HKLM Path' & 'HKCU Path'.\n",
"Updated Current User Path Environment Variable"
);
}
}
public static string UserPathGet()
{
// Reads Registry Path "HKCU\Environment\Path"
string subKey = "Environment";
Microsoft.Win32.RegistryKey sk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(subKey);
if (sk == null)
return null;
else
return sk.GetValue("Path").ToString();
}
public static void UserPathSet(string newpath)
{
// Writes Registry Path "HKCU\Environment\Path"
string subKey = "Environment";
Microsoft.Win32.RegistryKey sk1 = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(subKey);
sk1.SetValue("Path", newpath);
}
//===========================================================
// Private: This part required if you don't want to logout
// and login again to see Path Variable update
//===========================================================
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr SendMessageTimeout(IntPtr hWnd,
uint Msg, UIntPtr wParam, string lParam,
SendMessageTimeoutFlags fuFlags,
uint uTimeout, out UIntPtr lpdwResult);
private enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0, SMTO_BLOCK = 0x1,
SMTO_ABORTIFHUNG = 0x2, SMTO_NOTIMEOUTIFNOTHUNG = 0x8
}
private static void UpdateEnvPath() {
// SEE: https://support.microsoft.com/en-us/help/104011/how-to-propagate-environment-variables-to-the-system
// Need to send WM_SETTINGCHANGE Message to
// propagage changes to Path env from registry
IntPtr HWND_BROADCAST = (IntPtr)0xffff;
const UInt32 WM_SETTINGCHANGE = 0x001A;
UIntPtr result;
IntPtr settingResult
= SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE, (UIntPtr)0,
"Environment",
SendMessageTimeoutFlags.SMTO_ABORTIFHUNG,
5000, out result);
}
So I have a background service written in C# which connects to a RFID-reader and reads out all the tags he sees. After that the service will place all tags in a database running on the Raspberry Pi as well. The problem is when I start the service that it keeps consuming more and more memory from the Pi. I've already ran it with mono-service --profile=default:alloc but this returns errors. Does anybody see anything in my code which could cause this memory usage?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using Impinj.OctaneSdk;
using MySql.Data.MySqlClient;
using Raspberry.IO.GeneralPurpose;
using System.IO.Ports;
using System.Xml;
using System.Threading;
namespace RFIDdaemon
{
public partial class RFIDdaemon : ServiceBase
{
// Create an instance of the ImpinjReader class.
static ImpinjReader reader = new ImpinjReader();
static int opIdUser, opIdTid;
static MySQL _oMySql = new MySQL(Properties.Resources.DatabaseHostname, Properties.Resources.Database, Properties.Resources.Uid, Properties.Resources.Pwd);
// Create a Dictionary to store the tags we've read.
static OutputPinConfiguration led1 = ConnectorPin.P1Pin18.Output();
static GpioConnection connection = new GpioConnection(led1);
static XmlDocument Power = new XmlDocument();
private Thread _oThread;
private ManualResetEvent _oManualResetEvent = new ManualResetEvent(false);
static string userData, tidData, epcData;
public RFIDdaemon()
{
this.ServiceName = "RFIDdaemon";
this.AutoLog = false;
InitializeComponent();
}
protected override void OnStart(string[] args)
{
if (_oThread == null)
{
_oThread = new Thread(Reader);
}
if (!_oThread.IsAlive)
{
_oManualResetEvent.Reset(); //Reset reset event te continue thread
_oThread = new Thread(Reader); //New thread
_oThread.Name = "RFIDreader";
_oThread.IsBackground = true;
_oThread.Start();
}
}
protected override void OnStop()
{
// Stop reading.
reader.Stop();
GC.Collect();
// Disconnect from the reader.
reader.Disconnect();
connection.Close();
}
static void Reader()
{
try
{
// Connect to the reader.
// Change the ReaderHostname constant in SolutionConstants.cs
// to the IP address or hostname of your reader.
reader.Connect(Properties.Resources.ReaderIP);
// Assign the TagOpComplete event handler.
// This specifies which method to call
// when tag operations are complete.
reader.TagOpComplete += OnTagOpComplete;
// Get the default settings
// We'll use these as a starting point
// and then modify the settings we're
// interested in.
Settings settings = reader.QueryDefaultSettings();
double[] Results = ReadXml();
if(Results != null)
{
settings.Antennas.GetAntenna(1).TxPowerInDbm = Results[0];
settings.Antennas.GetAntenna(1).RxSensitivityInDbm = Results[1];
}
// Create a tag read operation for User memory.
TagReadOp readUser = new TagReadOp();
// Read from user memory
readUser.MemoryBank = MemoryBank.User;
// Read two (16-bit) words
readUser.WordCount = 2;
// Starting at word 0
readUser.WordPointer = 0;
// Create a tag read operation for TID memory.
TagReadOp readTid = new TagReadOp();
// Read from TID memory
readTid.MemoryBank = MemoryBank.Tid;
// Read two (16-bit) words
readTid.WordCount = 8;
// Starting at word 0
readTid.WordPointer = 0;
// Add these operations to the reader as Optimized Read ops.
// Optimized Read ops apply to all tags, unlike
// Tag Operation Sequences, which can be applied to specific tags.
// Speedway Revolution supports up to two Optimized Read operations.
settings.Report.OptimizedReadOps.Add(readUser);
settings.Report.OptimizedReadOps.Add(readTid);
// Store the operation IDs for later.
opIdUser = readUser.Id;
opIdTid = readTid.Id;
// Apply the newly modified settings.
reader.ApplySettings(settings);
// Start reading.
reader.Start();
}
catch (OctaneSdkException e)
{
// Handle Octane SDK errors.
Console.WriteLine("Octane SDK exception: {0}", e.Message);
//Console.ReadLine();
}
catch (Exception e)
{
// Handle other .NET errors.
Console.WriteLine("Exception : {0}", e.Message);
}
}
// This event handler will be called when tag
// operations have been executed by the reader.
static void OnTagOpComplete(ImpinjReader reader, TagOpReport report)
{
try
{
userData = tidData = epcData = "";
// Loop through all the completed tag operations
foreach (TagOpResult result in report)
{
// Was this completed operation a tag read operation?
if (result is TagReadOpResult)
{
// Cast it to the correct type.
TagReadOpResult readResult = result as TagReadOpResult;
// Save the EPC
epcData = readResult.Tag.Epc.ToHexString();
// Are these the results for User memory or TID?
if (readResult.OpId == opIdUser)
userData = readResult.Data.ToHexString();
if (readResult.OpId == opIdTid)
tidData = readResult.Data.ToHexString();
if (epcData != "")
{
InsertTag(epcData, tidData, userData, DateTime.Now);
}
readResult = null;
}
}
userData = tidData = epcData = null;
}
catch
{
}
}
static void InsertTag(string EPC, string TID, string User, DateTime TagreadTime)
{
try
{
DataTable Time = _oMySql.Select("SELECT Tijd FROM biketable WHERE EPC = '" + EPC + "';").Tables[0];
DateTime OldTime = Convert.ToDateTime(Time.Rows[0][0]);
TimeSpan diff = TagreadTime.Subtract(OldTime);
string formatForMySql = TagreadTime.ToString("yyyy-MM-dd HH:mm:ss");
if (diff.TotalSeconds > 20)
{
connection.Blink(led1, 100);
if (_oMySql.Select("SELECT Binnen From biketable WHERE EPC = '" + EPC + "';").Tables[0].Rows[0][0].ToString() == "True")
_oMySql.Update("UPDATE biketable SET Tijd = '" + formatForMySql + "', TID = '" + TID + "', UserMem ='" + User + "', Binnen = 'False' WHERE EPC = '" + EPC + "';");
else
_oMySql.Update("UPDATE biketable SET Tijd = '" + formatForMySql + "', TID = '" + TID + "', UserMem ='" + User + "', Binnen = 'True' WHERE EPC = '" + EPC + "';");
}
Time = null;
formatForMySql = null;
}
catch
{
}
}
static double[] ReadXml()
{
double[] Results = new double[2];
try
{
string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Power.Load(dir + #"\\Power.XML");
XmlNodeList TXpower = Power.GetElementsByTagName("TXpower");
XmlNodeList RXpower = Power.GetElementsByTagName("RXpower");
Results[0] = System.Convert.ToDouble(TXpower[0].InnerXml);
Results[1] = System.Convert.ToDouble(RXpower[0].InnerXml);
return Results;
}
catch (Exception e)
{
return null;
}
}
}
}
when I run tail -n 1000 /var/log/syslog I get the following messages: note the last messages where it kills the service
http://cl.ly/image/343p2i2y251L
How can I easily detect the memory leak?
Thanks in advance