.net

How to avoid screen flickering when showing form with user drawn controls?

So the transparent background problem is solved. Now, every time I show the form (or have to have it repainted), I get a lot of flickering. Is there any way I can not update the screen until the paint event is complete, or any other way to stop the 1/2 second of flickering and flashing while all the objects are being painted? ANSWER: ...

How can a windows service programmatically restart itself?

I need to write robust code in .NET to enable a windows service (server 2003) to restart itself. What it the best way to so this? Is there some .NET API to do it? ...

Can I use the same editor for Control.Anchor property for my own user control's designer support?

I have a simple extender component that draws 3D borders around any Control. In my designer supprot for the component, I'd like to use the same editor that VS uses to select the Anchor property. I know I can use the [Editor()] attribute, but I don't know the class name of the editor that's used. ...

"Thread was being aborted" exception whilst displaying dialog

In my app I've got a thread which displays for some time "please wait" dialog window, sometimes it is a very tiny amout of time and there is some glitch while drawing UI (I guess). I get the exception "Thread was being aborted" and completly have no idea how get rid of it. I mean Catch that exception in some way, or in some other way hi...

Using multiple BindingSources on one DataTable

I have a DataTable that has a boolean column called [Invalid]. I need to divide this data up by this Invalid column - valid rows can be edited, invalid rows cannot. My original plan was to use two BindingSources and set the Filter property ([Invalid] = 'false', for instance), which plays right into my hands because I have two DataGridVie...

Always check parameters and throw exceptions

Should you always check parameters and throw exceptions in .NET when the parameters are not what you expected? E.g. null objects or empty strings? I started doing this, but then thought that this will bloat my code a lot if it’s done on every single method. Should I check parameters for both private and public methods? I end up throwin...

What sort of mathematics do you use in your .Net app?

Excluding everything that's in System.Math. I think that System.Math is woefully inadequate. For example, in several official .Net frameworks, I can count 3 different implementations of matrices. Same goes for vectors. One implementation of a complex number; several different implementations of arbitrary rational numbers, and so on. So...

Is there a .net analogue to the Boost libraries?

As per the title. I think .Net libraries would definitely benifit from some sort of community development; perhaps something like the Java Community Process. This is where an analogue would be very helpful. EDIT: I think people are believing that I need to use some libraries. That's not what I'm talking about. I mean something like a f...

Why would LINQ to SQL perform better than a straight SQL query?

Strange performance outcome, I have a LINQ to SQL query which uses several let statements to get various info it looks like this public IQueryable<SystemNews> GetSystemNews() { using (var t = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.Isolatio...

How to deal with XML in C#

So what is the best way to deal with XML documents, XSD and all that stuff in C# 2.0? What classes to use etc. Like what are the best practices of parsing and making XML documents etc. EDIT: .Net 3.5 suggestions are also welcome. ...

How to put underline for access key for <asp:button> ?

How to put underline for first letter for access key for ? ...

Does .net SqlCommand.ExecuteReader close connection?

In this sentence: myCommand.ExecuteReader(CommandBehavior.CloseConnection) does it close connection in case of exception? ...

Hash character in path throws DirectoryNotFoundException

Consider the following code snippet private void ProcessFile(string fullPath) { XmlTextReader rdr = new XmlTextReader("file:\\\\" + fullPath); while (rdr.Read()) { //Do something } return; } Now, this functions fine when passed a path like: "C:\Work Files\Technical Information\Dummy.xml" But throws an error w...

Sending a message to the Windows GUI Thread

I've noticed that when you create a web service object (inheriting from SoapHttpClientProtocol) and you use the Async method, it makes the callback on the Windows GUI thread. Does anyone know how this works? How can I achieve the same thing. I figure this will save me having to check for InvokeRequired in my GUI forms if I am sure th...

Best way to remove an element at a known location from an XML String using DotNet?

I appreciate that there are now many mechanisms in dotnet to deal with XML in a myriad of ways... Suppose I have a string containing the XML.... <?xml version="1.0" encoding="utf-8" ?> <root> <Element1> <Element1_1> SomeData </Element1_1> </Element1> <Element2> Some More Data </Eleme...

remotely and programatically logoff an active domain user

I need to be able to logoff any user from his windows session from a program. I know I could log in as an admin and force a remote logoff. Is there any other way to force a logoff without logging in? The tool will run as admin so that's not a problem, being able to remote logoff without logging in is. Tool is in .NET, but any other ...

IUsable: controlling resources in a better way than IDisposable

I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate: class Usable : IUsable { public void Use(Action action) // implements IUsable { // acquire resources action(); // release resources } } and in user code: using (new Usable()) { // this code block ...

Most efficient way to check for DBNull and then assign to a variable?

This question comes up occasionally but I haven't seen a satisfactory answer. A typical pattern is (row is a DataRow): if (row["value"] != DBNull.Value) { someObject.Member = row["value"]; } My first question is which is more efficient (I've flipped the condition): row["value"] == DBNull.Value; // Or row["value"] is DBN...

.Net CAD vector graphics library

What is a good .Net vector graphics library that can be used for CAD like applications, and has a reasonable set of features specific for this type of applications, like computational functions (area, lengths, boolean shape operations etc). One good solution would be to use WPF as it's vector graphics based, but it's very much UI orient...

Best ways to deal with UTC and daylight saving times...

What are the best ways of dealing with UTC Conversion and daylight saving times conversion. What are the problems and their solutions. All in C# .Net 2.0. Also any existing problems with this in .Net 2.0. ...