Quantcast
Channel: Visual C# forum
Viewing all 31927 articles
Browse latest View live

C# - How to convert Excel sheet to data table dynamically

$
0
0

Hi,

I have the excel and i want to convert same structure format as datatable.

for example,

below is my screenshot and output.

The datatable should dynamically generate based on my excel column input.

for example.

if i have 5 excel columns then datatable only A to E,

if i have 3 excel columns then datatable only A to C, like that.

How to do this.??


SendKeys.Send Does Not Work on Remote Server

$
0
0

Hi, it works when I open the application. But how do I solve if sendkeys don't work when I leave the server?

--Windows Server 2012 R2


Need help with binary

$
0
0

Hello,

I am creating a program that saves info to an xml.

I want to create a binary file from the xml data.

But I only want to read the opening nodes, not the closed one's.

and only the inner text of the attributes 

Here is a sample to work with :

<?xml version="1.0" encoding="utf-16"?><File Version="1.0" AppVersion="1.0.0.0"><Parent><Eldest_Child><Grand_Child_One><Info Name="Grand_Child_One_Name">John Doe</Info></Grand_Child_One></Eldest_Child></Parent><File>

I want to use BinaryReader to read through the xml 

and then use BinaryWriter to save everything except 

the opening nodes  and the inner text 

leave the opening nodes  and the inner text, binary everything else .

Example :

  Parent
     Eldest_Child
        Grand_Child_One
                             Grand_Child_One_Name
   

Any help with methods would be great

Regards


TcpClient - receives unasked messages, concept

$
0
0
Hello,
I have a client that needs to respond to messages.
The message are XML structure.
It seems to work, the problem where I see it, I read the list and then it will be filled.
 List<string> listMessages = new List<string>();
 
I need your expert knowledge.
Do I have to use a thread-safe list, if so, how?
BlockingCollection<string> bc = new BlockingCollection<string>()
How do I delete the entries?
STEP1
public void Execute()
{
	MyTokenSource = new CancellationTokenSource();
	MyToken = MyTokenSource.Token;
	try
	{
		Task.Run(() =>
		{
			Workingloop(MyToken);  // besser so verwenden
		});//STEP2
public async void Workingloop(CancellationToken token)
{
	int value1 = 0;
	int value2 = 0;
	string value3 = "";
	try
	{
		while (!token.IsCancellationRequested)
		{
			List<string> recList = await SocketClient.ReceiveSocket(SocketDataEchange, token);

			if (recList != null && recList.Count == 1)
			{
				if (recList[0] == "ConnectionReset")
				{
					recList.Clear();
					Stop();
					Connect(IP, Port);
					Execute();
				}
				else
				{
					if (recList[0].Length > 0 && recList[0].Substring(0, 1) != "<")
						recList.Clear();
				}
			}//STEP3
internal class SocketsSendReceive
{
	byte[] Buffer = new byte[1000];
	String ReceiveBuffer = string.Empty;
	int SizeReceive = -1;
	internal async Task<List<string>> ReceiveSocket(Socket sck, CancellationToken myToken)
	{
		return await Task.Run(() =>
		 {
			 List<string> listMessages = new List<string>();
			 while (SizeReceive != 0 && !myToken.IsCancellationRequested)
			 {
				 if (sck.Connected == false)
				 {
					 return null;
				 }

				 try
				 {
				    // Sync
					 SizeReceive = sck.Receive(Buffer, 0, Buffer.Length, SocketFlags.None);
				 }
				 catch (SocketException eS)
				 {
					 Log.Error($"Socket Exception {eS.Message}");

					 listMessages = new List<string>();

					 switch ((SocketError)eS.ErrorCode)
					 {
						 default:
							 listMessages.Add(((SocketError)eS.ErrorCode).ToString());
							 break;
					 }
					 return listMessages;
				 }
				 catch (Exception e1)
				 {
					 break;
				 }

				 ReceiveBuffer += Encoding.ASCII.GetString(Buffer, 0, SizeReceive).Replace('\r', ' ').Replace('\n', ' '); 
				 int lengthFirstTag = ReceiveBuffer.IndexOf(">");
				 if (lengthFirstTag <= 0)
					 continue;
Best regards, Markus

string split

$
0
0

Hi,

I have below use cases like:

email: john.wills@abc.com

email: au-account-payable@abc.com

I do the following to extract the names from email this way:

 var email_prop = email.Remove(email.IndexOf("@"));
 var user = email_prop.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
 var name= string.Format("{0},{1}", user[1], user[0]);

// Update the property column in sharepoint list as below

item["Property"] = name;                                                                                                          

I get exception for use case where email does not contain "." based on which I split as in var user

I want to populate the Property column for each file as name from email as:

Wills,John for email that contain "."

OR

au-account-payable for those where email do not contain "."

How do I achieve this.


Getting Error : Cannot convert lambda expression to type

$
0
0

I have two winform application like app1 and app2 which are very similar and code also very similar. i copied few forms and code from app1 to app2 and when compile then i started getting below error.

Error      1061       Cannot convert lambda expression to type 'System.Collections.Generic.IEqualityComparer<RDSS_Workbench.QcVerticalViewNew.QcVerticalViewNewProcess.TickerBrokerStandardDateLineitemValue>' because it is not a delegate type              

 

 this is the code from where error was throwing

var TickerBrokerStandardDateLineitemValueAllBrokerBogeyDistinct = (from data1 in allTickerBrokerStandardDateLineitemValue2

   select new TickerBrokerStandardDateLineitemValue

   {

       TabName = data1.TabName,

       StandardLineItem = data1.StandardLineItem,

       BRTab = "",

       BRLineItem = "",

       Action = "",

       StandardValue = "",

       BrokerName = data1.BrokerName,

       CalValue = "",

   }).DistinctBy(x => new { x.TabName, x.StandardLineItem, x.BrokerName }).ToList();



var resultNotPersentInAllBrokerBogey = StandardBorgeyForEachBroker.Except(TickerBrokerStandardDateLineitemValueAllBrokerBogeyDistinct, (x, y) => x.TabName.Equals(y.TabName)&& x.StandardLineItem.Equals(y.StandardLineItem)&& x.BrokerName.Equals(y.BrokerName)).DistinctBy(x => new { x.TabName, x.StandardLineItem, x.BrokerName }).ToList();



allTickerBrokerStandardDateLineitemValue2.AddRange(resultNotPersentInAllBrokerBogey);

this below line was throwing error actually

var resultNotPersentInAllBrokerBogey = StandardBorgeyForEachBroker.Except

(TickerBrokerStandardDateLineitemValueAllBrokerBogeyDistinct, (x, y) => x.TabName.Equals(y.TabName)&& x.StandardLineItem.Equals(y.StandardLineItem)&& x.BrokerName.Equals(y.BrokerName)).DistinctBy(x => new

{ x.TabName, x.StandardLineItem, x.BrokerName }).ToList();

this line showing squiggle red (x, y)

i really do not understand what was missing in app2 which was causing this error the same code was working fine in app1. so anyone can tell me what i was missing ?

please help me sort the error.



c# and bluetooth device

$
0
0
hello guys,
i have to done a project that will perform data send from mobile to pc via bluetooth device. a bluetooth device will be connect to computer, and  my mobile phone will send data/file to computer via bluetooth. The project must be done by C#. my C# application must be read data from mobile phone.

Please, help me !!!!!

-arefin

Who will be announced as the next Visual C# Guru? Read more about February 2019 competition!!

$
0
0


What is TechNet Guru Competition?

Each month the TechNet Wiki council organizes a contest of the best articles posted that month. This is your chance to be announced as MICROSOFT TECHNOLOGY GURU OF THE MONTH!

One winner in each category will be selected each month for glory and adoration by the MSDN/TechNet Ninjas and community as a whole. Winners will be announced in dedicated blog post that will be published in Microsoft Wiki Ninjas blog, a tweet from the Wiki Ninjas Twitter account, links will be published at Microsoft TNWiki group on Facebook, and other acknowledgement from the community will follow.

Some of our biggest community voices and many MVPs have passed through these halls on their way to fame and fortune.

If you have already made a contribution in the forums or gallery or you published a nice blog, then you can simply convert it into a shared wiki article, reference the original post, and register the article for the TechNet Guru Competition. The articles must be written in February 2019 and must be in English. However, the original blog or forum content can be from beforeFebruary 2019.

Come and see who is making waves in all your favorite technologies. Maybe it will be you!


Who can join the Competition?

Anyone who has basic knowledge and the desire to share the knowledge is welcome. Articles can appeal to beginners or discusse advanced topics. All you have to do is to add your article to TechNet Wiki from your own specialty category.


How can you win?

  1. Please copy/Write over your Microsoft technical solutions and revelations to TechNetWiki.
  2. Add a link to your new article on THIS WIKI COMPETITION PAGE (so we know you've contributed)
  3. (Optional but recommended) Add a link to your article at the TechNetWiki group on Facebook. The group is very active and people love to help, you can get feedback and even direct improvements in the article before the contest starts.

Do you have any question or want more information?

Feel free to ask any questions below, or Join us at the official MicrosoftTechNet Wiki groups on facebook. Read More about TechNet Guru Awards.

If you win, people will sing your praises online and your name will be raised as Guru of the Month.


PS: Above top banner came from Vimal Kalathil.



linq expression for string comparison that counts equal words

$
0
0

Hello there,


I want to define a linq expression that finds all list items they matches my needle best. For example I have the following list and needle: 


List<string> colors = new List<string>();
colors.Add("yello dark blue orange");
colors.Add("red apple green");
string needle = "blue orange apple"

Now I want to get all list items back where the needle fits best. That means  "blue orange apple" and "yellow dark blue orange" have 2 words in common and  "blue orange apple" and "red apple green" only one, so it should return a list that contains the element "yellow dark blue orange".


walking thru a network of nodes in c#

$
0
0

Hi. I'd like to model a 40-50 node network in my db on a single sql server table.  And use c# to walk thru the network triggering work on a separate thread for each node that is enabled.

Each node would have 1-n predecessor nodes.  Every time work is completed on a thread, c# would check the network for new nodes that can be triggered based on the fact that a completed work status for Node X has just been returned.

I can handle the network (schedule) model in the db table.  And marking node "completed" flags to help this algorithm along.

I'd like some advice on the rest of it.  I see an article and example at https://www.codeproject.com/Articles/18976/A-simple-Binary-Search-Tree-written-in-C but suspect that a binary search tree is not what I am describing because I can have more than one predecessor for any node.  The oval (coming off d,f,g,h) in the diagram is what I call a phantom.  I may have phantoms in my model as a convenient way of not repeating more complicated predecessor groups of nodes.  

Does the community know of an example I can look at?  I am just a novice with c#.  I've pasted an image of a very simplified network example below.  Maybe I can hydrate a known class from the table and borrow some examples out there that walk such a class?


How do you develop a language model with speech sdk 11

$
0
0
I am interested in developing a custom language model for speech sdk 11. The old dictation resource kit is no longer avaialble. Not ready for cognitive services yet.

AesCng Class

$
0
0

Hello... I upgraded to the .NET Framework 4.6.2 so I could take advantage of the new AesCng Class in the Cryptography namespace.

However, when comparing it "side by side" with regular Aes there seems to be no difference. For example this function...

private string AesCrypto()
{
    string DataToEncrypt = "Hello!";
    byte[] Key = new byte[32] { };
    byte[] IV = new byte[16] { };

    using (AesCryptoServiceProvider AES = new AesCryptoServiceProvider())
    {
        byte[] DataByteArray = Encoding.UTF8.GetBytes(DataToEncrypt);
        MemoryStream ms = new MemoryStream();
        CryptoStream cs = new CryptoStream(ms, AES.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
        cs.Write(DataByteArray, 0, DataByteArray.Length);
        cs.FlushFinalBlock();

        return Convert.ToBase64String(ms.ToArray());
    }
}

returns the value: ylsH2mi5zN3DOxdvL00fzQ==

And so does this function:

private string AesCrypto()
{
    string DataToEncrypt = "Hello!";
    byte[] Key = new byte[32] { };
    byte[] IV = new byte[16] { };

    using (AesCng AES = new AesCng())
    {
        byte[] DataByteArray = Encoding.UTF8.GetBytes(DataToEncrypt);
        MemoryStream ms = new MemoryStream();
        CryptoStream cs = new CryptoStream(ms, AES.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
        cs.Write(DataByteArray, 0, DataByteArray.Length);
        cs.FlushFinalBlock();

        return Convert.ToBase64String(ms.ToArray());
    }
}

They both return the same result: ylsH2mi5zN3DOxdvL00fzQ==

The only difference is one uses AesCryptoServiceProvider and the other uses AesCng.

Should the results be the same? Or should AesCng be different? Perhaps I am not implementing it correctly?

I could not find any clear examples on microsoft.com or any other site, explaining the use of AesCng.

Any help would be greatly appreciated. Thank you!

USB freezing.

$
0
0

I have designed a usb pc oscilloscope using a PIC32MX microcontroller.

The C# pc software is from www.waitingforfriday.com

This works great and has no problems.

I have now ported this across to a PIC32MZ microcontroller.

Again this works great.

However, if I exit the pc program 5 seconds later the USB bus goes into suspend.

Then if I go back into the pc program the usb bus is frozen in suspend mode.

If I go back in before 5 seconds are up then it runs fine.

I have disabled power down and selective suspend on my pc but the problem persists.

 Is there a C# command I can use to take the USB bus out of suspend ?


n.Wright

VS Setup Project runs custom action as another user

$
0
0

hi there

i have created an .Net application and now i am about create a setup file for it, so i started with a VS setup project. while installing this application i need to create some registry keys (just keep that that was not seem possible to create them with setup project itself) so i added a custom action on commit stage that runs an .exe file to create these keys in registry and also install a certificate and ... 

the problem is while installer runs the custom action, the .exe file does all its jobs, but it does not create registry keys in HKCU hive, although its creating some keys in HKLM hive. it seems that installer runs the custom action as another user rather that the user who is trying to install the application. 

note: i have read somthing on VS documents also that has mentiond that while running custom action in Commit stage the "msirunmode" is change to "runmode_commit". 

how can i change this "msirunmode" t run actions as the user, or how can i solve this problem other way?

How to apply process on very fast receiving response in websocket data ?

$
0
0

Hi, I am making connection with stock market live data provider through web sockets. I am getting nearly 40,000 records per minute in response for all companies live price. I need to store all that data into text file and so that I need to apply my code for all responses and when I write code for all responses then it makes process very slow. When I apply code on response then it execute only 5,000 records. So it's very slow as compare to our responses. So how to make our process fast so I can store data with receiving speed. Please help me to solve this.

I have write my code below :

public static string tempFile = @"D:\LiveData.txt";
private void websocket_MessageReceived(object sender, MessageReceivedEventArgs e)
{
 using (w = System.IO.File.AppendText(tempFile))
 {
    Log(e.Message, w);
 }
 using (System.IO.StreamReader r = System.IO.File.OpenText(tempFile))
 {
     DumpLog(r);
 }
}

public static void Log(string responseMessage, System.IO.TextWriter w)
{
    w.WriteLine(responseMessage);
}

static string tempPath = @"D:\LongTimeHoldingDataFile.txt";

public static void DumpLog(System.IO.StreamReader r)
{
   string line;
   while ((line = r.ReadLine()) != null)
   {
     using (System.IO.StreamWriter w = System.IO.File.AppendText(tempPath))
     {
         w.WriteLine(line);
         w.Close();
         something();
      }
   }
   r.Close();
   var lines = System.IO.File.ReadAllLines(tempFile).Skip(1);
   System.IO.File.WriteAllLines(tempFile, lines);
}

private const string DirPath = @"D:\seprateSymbolPair";
private const string Separator = @",";
public static void something()
{
    System.IO.File.ReadLines(tempFile).ToList()
                .AsParallel()
     .Select(Newtonsoft.Json.JsonConvert.DeserializeObject<List<CryptoObject>>)
                .ForAll(WriteRecord);
}

public static void WriteRecord(List<CryptoObject> data)
{
   foreach (var item in data)
   {
     var fileNames = System.IO.Directory.GetFiles(DirPath, item.pair + ".txt", System.IO.SearchOption.AllDirectories);
     foreach (var fileName in fileNames)
     {
       List<string> teFil = new List<string>();
       try
       {
         var fileLines = System.IO.File.ReadAllLines(fileName).Skip(1).ToList();
         teFil = fileLines;
         writeLineTo(fileName, fileLines, item.pair, item.ap, (int)item.bp);
       }
       catch (Exception ex)
       {
          if (ex.Message.StartsWith("The process cannot access the file"))
          {
             System.Threading.Thread.Sleep(500);
             writeLineTo(fileName, teFil, item.pair, item.ap, (int)item.bp);
           }
        }
     }
   }
}

public static void writeLineTo(string fileName, List<string> fileLines, string sym, double clo, int vol)
{
    try
    {
        fileLines.Add(new StringBuilder().Append(sym).Append(Separator)
.Append(clo).Append(Separator).Append(vol).Append(Environment.NewLine)
       .ToString());
        System.IO.File.WriteAllLines(fileName, fileLines);
     }
     catch (Exception ex)
     {
        if (ex.Message.StartsWith("The process cannot access the file"))
        {
           System.Threading.Thread.Sleep(5);
           fileLines.Add(new StringBuilder().Append(sym).Append(Separator)
            .Append(clo).Append(Separator).Append(vol)
            .Append(Environment.NewLine).ToString());
            System.IO.File.WriteAllLines(fileName, fileLines);
        }
     }
}


Converting DataTable to List of objects

$
0
0
I am trying to convert my DataTable to a list of objects but I am getting an error saying "specified cast is not valid"  when I am now trying to create a list from the data I got from the database
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            myConnectionString = "Data Source=" + ".\\SQLServerInstance" + @";Initial Catalog = " + "DatabaseName" + @";Integrated Security=SSPI;";
        }
        string myConnectionString;
        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection myGetTaxTypeConnection = new SqlConnection(myConnectionString);
            SqlDataAdapter myGetTaxTypeDataAdapter = new SqlDataAdapter("SELECT * FROM Settings_TaxType", myGetTaxTypeConnection);
            SqlCommandBuilder myGetTaxTypeCommandBuilder = new SqlCommandBuilder(myGetTaxTypeDataAdapter);
            DataTable myGetTaxTypeDataTable = new DataTable();
            myGetTaxTypeDataTable.Reset();
            myGetTaxTypeDataAdapter.Fill(myGetTaxTypeDataTable);

            List<myTaxType> myTaxTypesList = (from myDataRow in myGetTaxTypeDataTable.AsEnumerable()
            select new myTaxType()
            {
                    TaxTypeID = myDataRow.Field<int>("TaxTypeID"),
                    TaxType = myDataRow.Field<string>("TaxType"),
                    TaxRate = myDataRow.Field<decimal>("TaxRate"),
                    TaxStartDate = myDataRow.Field<DateTime>("TaxStartDate"),
                    TaxEndDate = myDataRow.Field<DateTime>("TaxEndDate"),
                    Discontinued = myDataRow.Field<bool>("Discontinued")
            }).ToList();
        }
        class myTaxType
        {
            public int TaxTypeID { get; set; }
            public string TaxType { get; set; }
            public decimal TaxRate { get; set; }
            public DateTime TaxStartDate { get; set; }
            public DateTime TaxEndDate { get; set; }
            public bool Discontinued { get; set; }
        }        
    }
}
When this method did not work I tried a different approach like this and it is also giving the same error
List<TaxType> listName = myGetTaxTypeDataTable.AsEnumerable().Select(m => new TaxType()
{
    TaxTypeID = m.Field<int>("TaxTypeID"),
    myTaxType = m.Field<string>("TaxType"),
    TaxRate = m.Field<decimal>("TaxRate"),
    TaxStartDate = m.Field<DateTime>("TaxStartDate"),
    TaxEndDate = m.Field<DateTime>("TaxEndDate")
}).ToList();
Please help me . I dont want to loop

If you think it you can achieve it

I am not understanding the code

$
0
0

I have came across this code line where I am not understanding whats the problem.

Its showing the error: CS0103  C# The name 'Properties' does not exist in the current context

code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.GPU;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using Emgu.CV.UI;
using Newtonsoft.Json;
using System.IO;
using System.Timers;

namespace Emgu_4._0
{

    /// <summary>
    /// Used to callibrate the outermoust positions of the screen to be used when calculating servo positions
    /// </summary>
    public partial class Calibration : Form
    {
        private buttonState buttonState = new buttonState();
        private System.Timers.Timer buttonHoldtimer;
        private Capture capture;
        private Settings settings;
        private Point virtualPoint = new Point(90, 90);

        public Calibration()
        {
            InitializeComponent();
            initializePerepherals();
            initializeSettings();
            initializeTimer();
            resetPos();
            
            Application.Idle += displayImage;
            MessageBox.Show("Use the arrows to adjust the laser to the outermost part of the screen");

        }

        private void initializeTimer()
        {
            buttonHoldtimer = new System.Timers.Timer();
            buttonHoldtimer.Interval = 1;
            buttonHoldtimer.Enabled = false;
            buttonHoldtimer.Elapsed += timerEllapsed;
            buttonHoldtimer.AutoReset = true;

        }

        /// <summary>
        /// Winforms has no event for buttonhold, this is a makeshift one
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerEllapsed(object sender, ElapsedEventArgs e)
        {
            switch (buttonState)
            {
                case buttonState.Right:
                    virtualPoint.X--;
                    break;

                case buttonState.Up:
                    virtualPoint.Y++;
                    break;

                case buttonState.Left:
                    virtualPoint.X++;
                    break;

                case buttonState.Down:
                    virtualPoint.Y--;
                    break;
            }

            sendSerial();

            buttonHoldtimer.Interval = 100;
        }

        private void displayImage(object sender, EventArgs arg)
        {
            imageBox1.Image = capture.QueryFrame();


        }

        private void initializeSettings()
        {

            try
            {
                settings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(Properties.Resources.settingsFileName));
            }
            catch (FileNotFoundException e)
            {
                MessageBox.Show("No memory file detected, generating one");
                settings = new Settings();
                saveSettings();

            }
            catch (JsonReaderException e)
            {
                MessageBox.Show("Corrupt Memory File");
                File.Delete(Properties.Resources.settingsFileName);
                this.Close();
            }
        }

        private void saveSettings()
        {
            File.WriteAllText(Properties.Resources.settingsFileName, JsonConvert.SerializeObject(settings));

        }
        private void resetPos()
        {
            serialPort1.Write("X90:Y90");
        }

        private void initializePerepherals()
        {
            try
            {
                capture = new Capture();
            }
            catch (Exception e)
            {
                MessageBox.Show("Cannot initialize camera");
                this.Close();
            }

            try
            {
                serialPort1.Open();
            }
            catch (Exception e)
            {
                MessageBox.Show("Cannot initialize on COM port");
                this.Close();
            }
        }

        private void sendSerial()
        {
            if (virtualPoint.X < 180 && virtualPoint.X > 0 && virtualPoint.Y < 180 && virtualPoint.Y > 0)
            {
                serialPort1.Write("X" + (virtualPoint.X).ToString() + ":Y" + (virtualPoint.Y).ToString()); //Data stream format
            }

        }




        private void Calibration_FormClosing(object sender, FormClosingEventArgs e)
        {
            capture.Dispose();
            resetPos();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Calibrate " + radDropDownList1.Text + "?", "", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                if (radDropDownList1.SelectedIndex != -1)
                {
                    if (radDropDownList1.SelectedIndex == 0)
                    {
                        settings.xLeftCalibration = virtualPoint.X;
                    }
                    else if (radDropDownList1.SelectedIndex == 1)
                    {
                        settings.xRightCalibration = virtualPoint.X;
                    }
                    else if (radDropDownList1.SelectedIndex == 2)
                    {
                        settings.yTopCalibration = virtualPoint.Y;
                    }
                    else if (radDropDownList1.SelectedIndex == 3)
                    {
                        settings.yBotCalibration = virtualPoint.Y;
                    }

                    saveToFile();
                }
            }

        }

        private void saveToFile()
        {
            File.WriteAllText(Properties.Resources.settingsFileName, JsonConvert.SerializeObject(settings));

        }

        private void mouseDown(object sender, MouseEventArgs e)
        {
            Button button = (Button)sender;

            if (button.Equals(upButton))
            {
                buttonState = buttonState.Up;
            }
            else if (button.Equals(rightButton))
            {
                buttonState = buttonState.Right;
            }
            else if (button.Equals(downButton))
            {
                buttonState = buttonState.Down;
            }
            else if (button.Equals(leftButton))
            {
                buttonState = buttonState.Left;
            }


            buttonHoldtimer.Enabled = true;
        }

        private void mouseUp(object sender, MouseEventArgs e)
        {
            buttonHoldtimer.Enabled = false;
        }
    }

    public enum buttonState
    {
        Up, Down, Right, Left    
    }

    public enum soundType
    {
        Detection, Missing, Startup, Shutdown, Saddness
    }
}

SendKeys.Send Does Not Work on Remote Server

$
0
0

Hi, it works when I open the application. But how do I solve if sendkeys don't work when I leave the server?

--Windows Server 2012 R2


DNS.GetHostEntry when NetBIOS enabled at the NICs

$
0
0

We have been finding that when the DNS cache is empty, Dns.GetHostEntry(IP Address) can take up to about 9 seconds to return when NetBIOS over Tcpip is enabled on the NICs on Windows 10 & Windows 8.1. Wireshark shows that there is a reverse lookup query to the DNS server which returns with the correct hostname within a fraction of a second. There is then the delay of up to 9 seconds. There is then a forward lookup to DNS of the hostname which returns with the correct data in a fraction of a second. The hostname that GetHostEntry returns with is always the correct one. If NetBIOS over Tcpip is disabled on the NICs, then GetHostEntry returns with the correct hostname in a fraction of a second. We have tested this with a simple c# test program to isolate it from our legacy application. The problem occurs with both Visual Studio 2015 & 2005. Nslookup from the command line works pretty well instantly regardless of the NetBIOS NIC setting and the DNS cache. Dns.GetHostEntry is instantaneous once the DNS cache is populated.

Observation showed that the long delay occurs when the machine corresponding to the IP Address is switched off. When this machine is switched on, we have seen from Wireshark, that NetBIOS queries seem to occur between the DNS reverse and forward lookups, the GetHostEntry delay is reduced to 1 to 2 seconds. However this is still significant for us in the terms of our legacy application which is compiling a list of hostnames on start-up.

Is there any way thru the registry or whatever, of stopping Dns.GetHostEntry from doing NetBIOS stuff without having to disable NetBIOS at the NICs?

what is the benfits of IMEX in connection to excel file 2007 ?

$
0
0

I work on windows form application c# 

i write connection as below

  string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=D:\\Attendance Sheet.xlsx;Mode=ReadWrite;Extended Properties=Excel 12.0 Xml;");

connection above is work without any problem for select and read data and update data 

what is benfit IMEX and how i write in connection above ?

and are connection above is best for performance ?

Viewing all 31927 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>