.net

Is there a way to make derived classes override ToString()?

(I'm working in .NET 4.0 beta, C#.) I have an interface, and all classes derived from this interface should implement custom ToString() logic. Is that enforceable? If so, how? ...

Text differencing

We have an Winforms application that has access to many versions of a plain text document. We'd like to have a component that takes a list of documents and allows a user to pick two, and then shows the differences in terms of crossed out and other-colored text. Something like 37Signals "Writeboard". We know we can use a version of di...

Problem using OpenProcess and ReadProcessMemory

I'm having some problems implementing an algorithm to read a foreign process' memory. Here is the main code: System.Diagnostics.Process.EnterDebugMode(); IntPtr retValue = WinApi.OpenProcess((int)WinApi.OpenProcess_Access.VMRead | (int)WinApi.OpenProcess_Access.QueryInformation, 0, (uint)_proc.Id); _p...

Is SeDebugPrivilege() api function the same as System.Diagnostics.Process.EnterDebugMode?

What the title says. Are they the same? I've noticed that the first does have arguments and such, but are they going to give the same end result? ...

Why is C# triggering a Socket Timeout issue on another machine?

I ran an application on my machine and it ran fine; I then run the apoplication on another machine but I'm getting a socket timeout isse connecting to the box even though Pinging works fine. Below is my socket connection Logic: private bool openConnection(out IPEndPoint connection_Point) { bool connected = false; ...

changing datetimemode using SQLDataReader

Hi, Does anyone know whether it is possible to change the datetimemode when using a datareader. All the examples, as below, I can find use a datatable. SqlCommand command = new SqlCommand("SELECT EmployeeID, FullName, DateCreated, DateAppointment FROM [Employees] ...", connection); SqlDataAdapter adapter = new SqlDataAdapter(...

IEnumerable list through override chain

Alright, hard to phrase an exact title for this question, but here goes... I have an abstract class called Block, that looks something like this: public abstract class Block { public bool Enabled{get; private set;} public virtual IEnumerable<KeyValuePair<string, string>> GetDefaultUsages() { yield return new KeyValuePair...

What is a good query layer to be used when you write your own DAL? Do we need to write our own query processor and query object model?

So, here I am, about to roll my own data access layer. The key features that I needed in my DAL are asynchronous programming model, cloud based databases (eventual consistency, caching, REST protocols etc), multi-valued attributes, retrieving partial objects etc. I need to provide rich support for object oriented access - lists, dictiona...

How does C# evaluate Logic block??

I have the following line of code: public bool dcpl_radar() { if (radar == null) return false; else { if (radar != null) { if (radar.InvokeRequired) radar.BeginInvoke(new MethodInvoker(delegate() ...

An architecture question

Hi guys, I got a general architecture question, hope guys can help me. So some basic background first. I have a midsize customer base using my flagship product, which is mainly a crm accounting software. Its a windows based product and they host the data on their servers (usually at their offices). I have a clickonce application that u...

expand column width of a grid view

HI, I need to expand column width of the grid view by dragging it to suitable length like we do in excel after selecting a column.Is it possible? ...

MsgBox is coming below the Splash screen in VB.NET

I have a splash screen set using the Application Framework. In my main form, I check for some conditions in Load() event of the MainForm and display a MsgBox if some of them fails. But the problem is, the MsgBox comes below the Splash Screen. Is there any way to correct this? ...

Silverlight out of sandbox?

I'd like to use Silverlight's CLR instead of .NET CLR. For these reasons, at least: Cross-platform ability I need to avoid any compatibility problems for my .NET-written plugin. Process can host only sole .NET CLR, and when several plugins targeted for different CLR versions are in the same process - it becomes a great pain. Silverligh...

Arguments for CloseHandle() winapi call in .net

When accessing the winapi method CloseHandle() via .net P/Invoke, should the argument be IntPtr or HandleRef, and why? ...

How get this xaml to work from app.xaml

I made this UpButton.xaml file by converting it from an .ai-file that our graphics guys made but i just can't get it to work. I was thinking of making this some sort of template/style for buttons, but our buttons are made up from rectangles and not the button object. I've been fiddling with this since last Thursday, googled and tried ev...

.NET: How to wait correctly until BackgroundWorker completes?

Dear ladies and sirs. Observe the following piece of code: var handler = GetTheRightHandler(); var bw = new BackgroundWorker(); bw.RunWorkerCompleted += OnAsyncOperationCompleted; bw.DoWork += OnDoWorkLoadChildren; bw.RunWorkerAsync(handler); Now suppose I want to wait until bw finishes working. What is the right way to do so? My so...

Test for Optional Field when using .NET Custom Serialization

Given a class like this one: [Serializable] public class MyClass { string name; string address; public MyClass(SerializationInfo info, StreamingContext context){ name = info.GetString("name"); if(/* todo: check if a value for address exists */) address = info.GetString("address"); } publ...

How to prevent a Windows Forms TextBox from flickering on resize?

There are plenty of articles addressing flicker in Windows Forms. The majority recommend setting DoubleBuffered = true or setting a bunch of ControlStyle flags. However, none of these help reduce a TextBox flickering. Here are a couple of related questions: How to double buffer .NET controls on a form? How to eliminate flicker in Wind...

How to prevent controls visually lagging behind on resize inside TableLayoutPanel?

I have a layout of medium complexity based on several nested TableLayoutPanels. Resizing the form causes the controls inside the deeper nested tables to visually lag behind the resize. Firstly, this makes them look like they move around while the form is being resized, but worse, the edges of the controls are visibly clipped when they la...

Calculate hash without having the entire buffer in memory at once

I am doing an operation where I receive some bytes from a component, do some processing, and then send it on to the next component. I need to be able to calculate the hash of all the data I have seen at any given time - and because of data size; I cannot keep it all in a local buffer. How would you calculate the (MD5) hash under these ...