.net

Designer auto-generating unwanted code I can't get rid of

I just created a control with the following code: public partial class KindsEditor : NaviGroupList, INotifyPropertyChanged { private WebBrowser _Browser; private BasicProject _Project; public event PropertyChangedEventHandler PropertyChanged; public bool RequiredDataLoaded { get { return (Project != null) && (Browser !...

What is faster and more convenient: Hashtable or Dictionary<int, double>()?

Preamble: I'm working at heavy-loaded applicaion that produces large data arrays. I wrote the following class using System; using System.Collections; using System.Collections.Generic; namespace CSharpSampleApplication.Data.CoreObjects { [Serializable] public class CalcItem { pub...

Is creating a C# generic method that accepts (nullable) value type and reference type possible?

I want to create a simple method that accepts both value type and reference type parameters, i.e. int is value, and string is reference. So this is what I start with: public bool areBothNotNull<T>(T? p1, T? p2) { return (p1.HasValue && p2.HasValue); } So I want to be able to use it like this: var r1 = areBothNotNull<int>(3, 4);...

How to make software developed in WinForms .NET 3.5 with SQL Express portable

i found that its really pain to create setup and deployment packages for windows xp/vista/7 so my question is can i make my application portable with any third party tool such as thin app ? my application requires dot net 3.5 framework and sql express 05 installed i want to put it on usb drive and user can execute it directly from usb...

Cannot open LPT1(Printer Port) on win7 (64bit). The same applicaion works on win XP

I have an application that opens a port to a printer(it's a bar code printer) which works on win XP but when i switch to win7 (64bit) i have a problem. Here is the code: I am using this method to open the port: [DllImport("kernel32.dll", SetLastError = true)] public static extern SafeFileHandle CreateFile( St...

Pixelation when loading a greyscale image

I've got a tiff image that is greyscale, and when I load it using Image.FromFile, the quality of that image is very pixelated. However, if I save the tiff as indexed in Gimp beforehand, then loading that image with Image.FromFile is no longer pixelated. Is there anyway I can load a greyscale image at the original quality? [edit] Note t...

LINQ on a LinkedList - iterate over LinkedListNode<T>, not T

Hello SO; I'm having a problem understanding how to do something in LINQ. I have a linkedlist, the type of the object doesn't matter. What does matter is that I want to do something in a Where() based on the relationship between the current object and the next one in the list. Why can't I do something like: linkedlist.Where(n=>a_fun...

twitter like open source software for .Net platform?

Hello everyone, I am wondering whether there is twitter like open source platform written in .Net (C#, ASP.Net, SQL Server, etc)? I want to integrate twitter like feature into my own web application, but not want to use public twitter service. thanks in advance, George ...

Unable to edit any columns in my C# DataGridView - would anyone know why?

Hi folks, I'm trying to enabled editing for a number of columns in my DataGridView. Now, before anyone suggestions I should read the MSDN article: How to: Specify the Edit Mode for the Windows Forms DataGridView Control, I already have. In summary (and I quote): The underlying data source supports editing. The DataGridView control is...

How i can open all items in accordion control in silverlight?

I set the SelectionMode property to OneOrMore. How i can open all items, when conrol loaded? ...

Post to another page site works, but shows a blank page in the process

I am posting values to from an ASP.NET website to a completely different site (Paypal actually). I accomplish this by returning a page to the user that has all the hidden form inputs written and then a Javascript function that automatically submits the form. The process is supposed to be seamless, but the blank page is noticeable for th...

Multiple IndexReader/Writers in one process (Lucene)

We are maintaining a Lucene index which contains around 20mm documents. The nature of the search queries is such that indexing and quering can be easily split between different indexes. To achive that we need to keep many (potentially thousands) of IndexWriters or IndexReaders/Searchers in memory to deal with indexing and quering of eac...

Why do I get OutOfMemory Exceptions although the memory could be freed?

Hello everybody, I stumbled upon an OutOfMemory-Exception when working with lots of pictures (sequentially, not in parallel). I reproduced the behavior in some small portion of code like this: class ImageHolder { public Image Image; ~ImageHolder() { Image.Dispose(); } } public partial class Form1 : Form { ...

Calling WCF service with jquery and parameters synchronously

Hi, I am calling a .NET WCF service from Ajax like this: result = $.ajax({ type: "POST", // async: false, contentType: "application/json; charset=utf-8", url: BaseUrl + "Services/YucataService.svc/SetGameStatusSecure", data: "{'gameID':'" + gameID + "','pid':'" + pid + "','status':'" + newStatus + "','origStatus':'...

Randomly Cant connect to local MySQL?

This might be related to another problem i am having. But in this case my app was idling and i had a crash in my GetConnection() on conn.open(). Since i was idling i figure it had comething to do with my queue in the background and possibly garbage collection? I took a look at netstat and found 16 connections. Does mysql only accept 16...

Failed to load viewstate composite control

I have a composite control that contains a different set of child controls based on the value of one of it's properties at runtime. Whenever there is a postback, I get the following error: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during t...

Why is the pattern to update UI from a different thread not built into the .NET framework?

I know "why is my this framework like/not like xyz?" questions are a bit dangerous but I want to see what I'm missing. In WinForms, you can't update the UI from another thread. Most people use this pattern: private void EventHandler(object sender, DirtyEventArgs e) { if (myControl.InvokeRequired) myControl.Invoke(new Method...

Maven equivalent for .Net

For me, the best feature in Maven is not having to keep 3rd party libraries at part of the source tree. Is there a tool for .Net/Visual Studio that does something like that? ...

collections that track changes?

is there any collection that track changes made to the collection? say which object is deleted/modified/added? The ObservableCollection just give notifications, it will not keep the removed in say a RemovedItems property. I have to keep them somewhere. actually why i am asking the question is if i bind a collection to a datagrid, it see...

Is it OK to use Math.Pow (10, n)?

I need to compute power (10, n) Is it OK to use Math.Pow (10, n)? Or should I use a loop? for (int i = 0; i < n; i++){ x*=10; } Which one is better? and why? ...