.net

Trying to use Dictionary<Dictionary<int, int>, Dictionary<int, int>> advice please

I'm looking to nest dictionaries inside of one another in order to house x y coordinates of blocks. So I would have IDictionary<IDictionary<int, int>, IDictionary<int, int>> and the key Dictionary would house the column, row combination while the value Dictionary would house the x and y coordinates. It will be used to draw a 2D wir...

align the tab control to the right

is there any way that i can align the tab control to the right? by default, the tabs are to the left. can i change it to the right or centre.?? ...

Commit current dirty cell on clicking save button from any datagridview on form

I have a form with multiple datagridviews. On save the entire dataset will be serialized to a strongly typed property bound to a sql varbinary(max) Works fine. Of course the current "dirty" cell will not be saved as mentioned here : http://stackoverflow.com/questions/963601/datagridview-value-does-not-gets-saved-if-selection-is-not...

a timeit function for F#

I am trying to write something like let timeit (x:'a->'b) = let start = System.DateTime.Now x let duration = System.DateTime.Now - start printfn "time usage = %A" duration.Milliseconds () it works for let matrixtest() = let x = vector[1.;2.;4.] let y = matrix[[1.;2.;4.;];[3.;4.;9.;]] printfn "%A" (y ...

C# RichTextBox strange behaviour

greetings, for the first time ever im investigating RichTextBox control in C# windows forms. i know i need this control in my app as textBox is to simple for my needs. i have the followig code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using...

Webclient.Uploadfile via Https and proxy server

I have a method that works fine for uploading a file to an HTTPS server directly. However, if the customer site requires the customer go through a proxy server, it no longer works. I'd like to support the default proxy server as defined by the default browser. This seems to be the typical way it is set up. The inital (non-proxy) code...

.NET File Stream write method writes all empty lines

I am having a C# console application access files over a network and write to it. I noticed that some files have been corrupted and have only null written to them. I did not get any exceptions. I am using simple code that writes a byte array to the file's stream. When opening the files in Binary mode, all i see are Zeros, something like...

How do I implement pushdown automaton in C#?

I want to code this for PDA. How would I do that in C#? a^nbc^n (n>=0) ...

.NET ASMX - Returning Pure JSON?

I am going nuts here. I've looked at the following entries and none of them are correcting the aberrant behavior I am seeing: http://stackoverflow.com/questions/288850/how-to-return-json-from-a-2-0-asmx-web-service http://stackoverflow.com/questions/1678101/how-to-return-json-from-asp-net-asmx http://stackoverflow.com/questions/211348...

Specify client certificates in HttpWebRequest in .NET Compact Framework 3.5

Previously, I was trying to use client certificate on .NET CF 2.0 (see here) and I ultimately had to give up. I'm now on .NET CF 3.5 which has support for the ClientCertificates property on the HttpWebRequest object. However, I can't figure out how to instantiate the X509Certificate or X509Certificate2 object with a pfx file. On the f...

Which Exception to throw when a method try to use a field that can be null?

Hello, I am actually working on a Framework development, which means require a really strong coding methodology. I am facing a problem where I do not know which System.Exception derivated class I need to throw. Basically the case is when I have a class with fields that can be optionnaly initialized by the constructor and that have meth...

Table Row Limit in XPATH in HtmlAgilityPack's SelectNodes method?

Has anyone encountered a limit to the number of rows in a table HtmlAgilityPack's SelectNodes method can handle? I have an html table in a web page with 40 plus rows. When I feed the XPATH of the 21st row to HtmlAgilityPack, the SelectNodes method returns null. I've validated the html of the rows and cells in the table and they are al...

Should I keep a SerialPort connection open?

I am working with serial communication and I'm wondering whether I should keep the SerialPort open or not? I'm creating a queue of commands and only one will be running at a time. Should I create a SerialPort and open/close it in each command, or should I have another class which holds the port open and is called from the commands? Or d...

Best Linq2Sql equivalent of IsNull(Max(id))

I'm looking to convert the following SQL into Linq2SQL. select isnull(max(Id),0) from tbl Even though I have Id defined as Int NOT NULL I wish to be able to have a defult value of 0, even when there are no rows in the table. The best readable approach I've been able to come up with is var maxId = dc.tbl.Select(row => row.Id) ...

How do I automatically have the build date inserted at design time

Hope fully the title was somewhat descriptive. I have a winform application written in C# with .net 2.0. I would like to have the last compile date automatically updated to a variable for use in the about box and initial splash box. Currently I have a string variable that I update manually. Is there any way to do this? VS2008 .net 2.0 ...

How to Consume a Web Service in a .NET Class Project

I want to create a class library .NET web project that encapsulates the functionality of consuming a web service. I can create the .NET class web project and add a web service (Visual Studio 2005) but I cannot seem to figure out how to reference it. It's easy to reference in a web site (simply address it by name), but apparently in the...

Is it possible to request temporary trusted access to VBA project object model?

I need to access the VBA code of Office documents (Excel workbooks, but it's not relevant) through .Net / C#. I know how to do this, but this requires the Office user to have granted trusted access to the VBA project object model through the Office app. This makes me uncomfortable, because there is a risk that the user leaves things set ...

Convert.ToBoolean and Boolean.Parse don't accept 0 and 1

Why was it decided that when parsing a boolean, 0/1 are not acceptable? When parsing any integer type value, it accepts numerical strings to be parsed. (And if .NET can parse the string "One hundred million two hundred and sixty five thousand eight hundred and sixty five" I would be surprised). What makes booleans special? They are ess...

How to better initialize nullable type from non-nullable?

My objects often has nullable types properties that used as SQL commands parameters. I initialize them next way: public int? Amount { get { int i; int? amount = null; if (Int32.TryParse(Request["amount"], out i)) { amount = i; } return amount; } } command.Parameters.Add("@amount").Value = (object)this.Amount ?? DbNul...

How might i do these IPC techinques?

I remember back in the day while using C and win32 i had a number of IPC techniques. So far i haven't ran into any of them in .NET or seen them outside of C so i thought i ask how might i do these inter-process communication techniques? Shared/Global memory. Simply allocate ram that can be change by another process without any signal. ...