.net

How can I determine programmatically whether on multi-core, hyperthreading or multi-processor?

I know how to get the processor type, perhaps that's the only way, but I'm actually looking for a way to determine from an application whether it's running on a multi-core processor or on a hyper-threading single-core processor. (background: the hosting providers of some of my clients are very vague about what resources they make availa...

Access Violation On Vista Startup

I occasionally get a strange unhandled access violation when my .NET application is started automatically on startup (using a shortcut in the "Startup" folder) by Windows Vista. I have not seen this error when I start the executable manually. It happens randomly and I have yet to be able to reproduce the issue reliably. Here's the mes...

How to distribute a folder as a reference?

I am making a C# app and I am using GeckoFX to embed Firefox into my app. For anyone interested, I got it here: http://geckofx.org/. The problem is, I want to deploy GeckoFX with my app and I don't know how to do it. The line of code I use to initialize GeckoFX is this: Skybound.Gecko.Xpcom.Initialize("C:\\xulrunner"); This assumes t...

How to set an autoproperty in the constructor of a struct?

Why is this valid public struct MyStruct { public MyStruct(double value) { myField = value; } private double myField; public double MyProperty { get { return myField; } set { myField = value; } } } and this is not public stru...

Execute a shell command from a .net application

I need to execute a shell command from my .NET app, not unlike os.execute(a little ways down on that page) in Lua. However with a cursory search i couldn't find anything, how do i do it? ...

Why context menu swallow my click event?

I have a user control, which handles mouse click event, when mouse clicked, the control highlight an contained item. it worked smoothly until i attach a context menu to it-the right mouse click opens the context menu, but the item that is supposed to be highlighted by right click doesn't work as usual. So the right-click event is swallo...

A better design? Same object, different possible states

Hello, I have a very simple application which consists of an ASP.NET front end site, with a WCF Windows Service doing the heavy lifting back-end logic. The user has one simple page where he selects some parameters and pushes a 'submit' button. The page calls the WCF service and passes it the parameters. The service instantiated an inst...

How could I disable daylight saving adjustment by w32tm?

What I need to achieve is to sync the client laptop time with a specific NTP server and display a standard time (without DST). I did try NTP Client, but if the auto-sync is enabled on system, then it will be pointless. Now I am using w32tm and manually set my NTP server as default NTP server in registry. All worked but DST, I changed v...

How can I listen for monitors being added or removed?

On Windows, how can I find out when monitors (physical display devices) are added/removed/detached/resolution changed/etc.? I'd prefer not to poll EnumDisplayDevices(). ...

How do I find the calling PropertyGrid instance from a UITypeEditor?

I need a reference to the PropertyGrid instance which has called my UITypeEditor. If you care to know why: I have a Control which needs to receive a delegate from a property being edited, so that the next action performed in said Control will fire the delegate with some Control-specific information. I don't want to add a reference to ...

Regex for non-alphabets, non-numerals and non-DOT

Please provide a solution to write a regular expression as following in C#.NET: I would require a RegEx as below: Non-Alphabets(a to z;A to Z) and Non-Numerals(0 to 9) and also non-DOT (.). Mean to say as otherthan the mentioned above i want to handle reverse way for getting regular expression as other than alphabets, otherthan numerals...

WPF: Accessing two DataContexts in the same control

Hi, I am using an MVVM approach, and I have an object from my ViewModel called DatabasesSubFrame which is DataTemplated to show a ListBox. I want to display a Button below the ListBox, which binds to both the currently selected item, and a property on the DatabasesSubFrame object which is being DataTemplated. I know how to refer to the...

Getting a Process to terminate

I have a process object setup like the following: Process p = new Process(); p.StartInfo.FileName = command; p.StartInfo.UseShellExecute = true; p.StartInfo.Arguments = String.Format( commandArguments, destinationLocation, sourceLocation, sourceDirName, (string.IsNullOrEmpty(revisionNotes.Text)) ? "" : revisionNotes....

Use .net object as data source in Crystal Report 2008

HI all, I created a .net object (ex: A) which contain data have been collected from tables. Next, i create a List<A>() and pass to SetDataSource() method of ReportDocument object. When i run then an Exception have been throwed : "CrystalDecisions.CrystalReports.Engine.DataSourceException: The data source object is invalid" I don't kn...

Easy way to order WPF tag attributes

Hi All, I've started to do some WPF development and I'm switching between xaml and the designer. This causes the attributes for each element to be ordered differently, which makes things hard to read unless I go though and order everything manually. Is there an easier way to do this? eg. ...

UrlEncodeUnicode and browser navigation errors

I want to redirect a request to some URL that may or may not contain non-ascii characters (e.g. german umlauts). Doing this with the relevant part of the URL: var url = HttpUtility.UrlEncodeUnicode("öäü.pdf"); // -> "%u00f6%u00e4%u00fc.pdf" and then issuing the redirect: Response.Redirect(url, ...); will not produce the desired be...

Assert statements in .NET code

Hi All, I'm wondering if people use the Trace.Assert and Debug.Assert statements in code that is "stable" and moved into Test and Prod environments? If so, how does this help? I would have thought that Guard classes etc would check for exception conditions and raise exceptions as approperiate. ...

Firefox support for Script# and Implementation of Generics

I've used Script# for a while and have had problems getting projects to work out of the box with Fireox. I had to change a couple of lines in the sscorlib.js files. Will Script# be cross-browser compatible in the future? Will it use generics in a future release? ...

Tests under TestDriven.NET not picking up updated fuslogvw settings

If there's a dup of this, I'll be upvoting it but until someone finds it for me.... This is a Things I've Learned Today [that nobody seems to have blogged about] entry... With TestDriven.NET, I was continually getting the following output from an Assembly.Load : WRN: Assembly binding logging is turned OFF. To enable assembly b...

Is it important to dispose SolidBrush and Pen?

I recently came across this VerticalLabel control on CodeProject. I notice that the OnPaint method creates but doesn't dispose Pen and SolidBrush objects. Does this matter, and if so how can I demonstrate whatever problems it can cause? EDIT This isn't a question about the IDisposable pattern in general. I understand that callers s...