A common pattern in the .NET Framework is the TryXXX pattern (I don't know if that's what they really call it), in which the called method attempts to do something, returning True if it was successful, or False if the operation failed. A good example is the generic Dictionary.TryGetValue method.
Documentation for these methods say that...
Why does this work ?
var x = from p in db.People let oCount = p.Orders.Count select p;
And not this ?
var x = from p in db.People let oCount = Count(p) select p;
private int Count(DataContext.Order o)
{
return o.Count;
}
...
For some of monitoring applications and for tasks that are required to be scheduled to poll some service, we traditionally use a console application that in turn calls some methods in our business layer or polls file locations/ftp locations.
For another task I was carrying out I started playing about with Powershell and was pretty impr...
Suppose I have a number of elements to store like:
fruitList = "apple", "orange", "banana", "kiwi", ...
How would you store these in XML?
<FruitList>"apple", "orange", "banana", "kiwi"</FruitList>
OR
<Fruits Type="Expensive" List="apple", "orange", "banana", "kiwi"> </Fruits>
Is there a better way?
Whatever method is chosen, ho...
I'm taking values from a database and dynamically placing points on a 2d cartesian plane. I need a way to set the top and left css properties.
Any help would be much appreciated.
Thanks in advance
...
What's the best way to set all values in a C# Dictionary?
Here is what I am doing now, but I'm sure there is a better/cleaner way to do this:
Dictionary<string,bool> dict = GetDictionary();
var keys = dict.Keys.ToList();
for (int i = 0; i < keys.Count; i++)
{
dict[keys[i]] = false;
}
I have tried some other ways with foreach, but...
When i am trying to print an image to a printer for a 700kb file it is sending 120MB of data over to the printer. I can see this because I see the printer spooling 120MB. why would this happend?
Here is the code for the PrintDocument.PrintPage
private void PrintPage(object sender, PrintPageEventArgs ev)
{
sw.WriteLine("...
I'm having trouble logging into a secure site with a WatiN LogonDialogHandler running on a IE6 / Windows 2000 machine. It doesn't fill in the userid/password for the proxy site, but works fine on a IE7 / Windows XP machine.
Has anyone ever had/solved this problem?
I found the same question on dream.in.code, but it's unanswered.
I kno...
On properties inside my domain objects which I do not want lazy loading, I omit the virtual modifier, and also update the mapping file to reflect this using for example:
<property name="UserName" column="Name" type="String" length="40" lazy="false"/>
I would have though that setting the property lazy to false would make it accept that...
In my ASP.NET application, I have a line in the global application start event that configures the client remoting channel by calling RemotingConfiguration.Configure().
This works well the first time, but when my web application gets recycled, the application start event is fired again causing the following remoting exception:
Remoting...
I'm trying to tile an image or background image in a table cell in iTextSharp. The closest I have gotten is to attach an image directly to the cell using a PdfPTable and PdfPCell.
tempCell = new PdfPCell();
tempCell.Image = iTextSharp.text.Image.GetInstance(Path.Combine(GetImageDirectory(), "my_image.gif"));
table.AddCell(tempCell);
T...
Hi all,
New to .NET/C# stuff so please forgive me if it's something obvious ;-) I'm trying to get cell editing going on a DataGridView control (WinForms). I've set all "ReadOnly"-type options to false, I've set EditMode to "EditOnEnter", I've added a row and selected a current cell programmatically, I've tried calling BeginEdit() but a...
1) If ( inside web.config file ) I declare custom section named songPoem before <configSection> , an error is reported saying songPoem element is not recognized. Thus, the following gives me an error:
<songPoem song=”lalala” />
<configSection>
<section name=”songPoem” type=”A” />
</configSection>
while the following works just fin...
Ho do I go about adding random minutes to column in dataset, here is my code:
protected void btnUpdateTable_Click(object sender, EventArgs e)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
///check if column[logout] is null or empty, fill it
if(dr.IsNull("logout_time"))
{
///get the login colum ...
In my IE extension I am trying to get the screen co-ordinates of an element in C++/MSHTML. From my IHTMLDocument2, I do the following:
IHTMLDocument2:: pDoc->get_all(&pElemColl);
IHTMLElementCollection::pElemColl->item(varID, varIdx, &pElemDisp);
where
_variant_t varID = ("myID", VT_BSTR);
//myID is the tag name of the element I'm...
Hello all.
Let me start off by saying that I am completely new with WPF (this is my first project and I have been working in it for less than a week). With that being said, please be easy on me!
I have three list boxes that are being bound to ObservableCollections from a LINQ queries. In the beginning, everything is fine, all three a...
I'm using VS2008 and I'm creating a Windows Forms project. The form has a menu of MenuStrip class, and the items are (surprise, surprise) ToolStripMenuItem objects.
I want to add pretty icons from the FamFamFam Silk icon set. All is nice and fine, until I got to the "copy" icon. You can see it here (warning! 1MB image!) under the name "...
Hi,
I have a parent GridView that had a child GridView (code below), how do I get the value of the child gridview checkbox? And also, how do I save the state of the child gridview, i.e. if it is displayed or not? This is the function that is fired when the button is pressed that reads through the parent grid seeing which publications ...
Which is more correct and why?
Control.BeginInvoke(new Action(DoSomething), null);
private void DoSomething()
{
MessageBox.Show("What a great post");
}
or
Control.BeginInvoke((MethodInvoker)delegate { MessageBox.Show("What a great post"); });
I kinda feel like i am doing the same thing, so when is the right time to...
I'm communicating with a web server from .Net. The web server throws a 500 internal server error and writes a detailed error message.
I'm trying to read the error message that is received from a web exception, but getting another web exception. Why is the second WebException thrown?
try
{
var webResponse = (HttpWebResponse)webRequest...