.net

size of char type in c#

Just wondering why do we have 'char' type of size=2Bytes in c#(.net) unlike 1Byte in other programming languages? ...

Compile for 64bit or 32bit platforms in visual studio, depending on the host Operating system?

On a project we are working on there is an SQLite.DLL file that we are linking which we need to link the correct version (32 or 64 bit) depending on the host operating system. If we link to the 32 bit version it will not run on a 64 bit system, and vice versa. Thus, how can we create a configuration that will cause the system to build th...

C++/CLI : Interop window is not properly configured

Hi, I'm trying to load a WPF control in a C++/CLI application, using the HwndSource class. Here is my code : UBOOL MyWindowWrapper::Init(const HWND InParentWindowHandle) { Interop::HwndSourceParameters sourceParams( "WindowName" ); sourceParams.PositionX = 0; sourceParams.PositionY = 0; sourceParams.ParentWindow = (Int...

Dude, where's my thread?? (or: rename a .NET thread pool thread - is it possible?)

Sometimes I find myself stepping through an application in Debug mode, until I hit 'step' on some particular line and it takes way too much time doing something, eating up 100% CPU. At this point, I hit the 'Break' button and try to find what's running that's taking so long. The problem is, this app has a hefty amount of threads runnin...

Multiple ways to define C# Enums with [Flags] attribute?

I understand how Enums work in C#, and I get what the Flags attribute brings to the table. I saw this question, here. Which recommends the first flavor, but doesn't provide any reason/justification for it. Is there a difference in the way in which these two are defined, is one better than the other? What are the advantages to using the...

Create an interactive logon session

I'm trying to create a utility similar to Microsoft's abandoned Super Fast User Switcher (download), which allows fast user switching without going through the Welcome screen. I have a working implementation using the undocumented WinStationConnectW API (along with WTSEnumerateSessions), but it can only switch to a user who is already l...

How to create multiple directories from a single full path in C#?

If you have a full path like: "C:\dir0\dir1\dir2\dir3\dir4\" how would you best implement it so that all directories are present? Is there a method for this in the BCL? If not, what's the most elegant way to do this? ...

C# instead of IronRuby as an embedded "scripting" language in .NET 3.5

What is the best practice for using C# as an embedded internal scripting application for a .NET 3.5 application? I have an app with a few small IronRuby scripts in it. None of which is really exploiting the dynamic nature of IronRuby. Apparently its against our corporate standard to be using IronRuby or IronPython right now. Ooopps. Wha...

Mutiple rdlc files in one report viewer control -- can it be done with subreports?

Hi, I have multiple reports that take the same parameters. Need to create a master report with all the reports merged together. I dont want to copy paste the rdlc files into one large file. found a control by Telerik called ReportBook but it costs money!! http://www.telerik.com/help/reporting/designing-reports-general-explanation.ht...

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console?

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console? I'm using MsSqlConfiguration.MsSql2008.ShowSql() but it has no parameters and I can't find anything on Google. ...

Fitnesse- Should tests talk to the database?

We are trying to use Fitnesse for our Functional test. Should i be mocking dependencies or should it be testing against the database? What are the Pros/Cons of either of the approach? The whole issue of testing against the DB is setting up data which is huge dependency. If we mock then is it real functional test? Thanks ...

What's a good data structure for a multiple-value primary key object?

This question can best be asked by example. Say I have a database table called "Car" with the following columns: (Make*, Model*, NumberOfDoors*, Description, Price, Mileage, Color) The 3-tuple of Make, Model, and NumberOfDoors makes up the unique primary key in the database. What I've done is made a "Car" class for each line item, bu...

Having an issue with CoverterParameter Binding in silverlight

Hi everyone, I am having an issue with the xaml parser not liking my binding statement but i cannot see anything wrong with the statement. Invalid attribute value {Binding VehicleSpeed, ConverterParameter={Binding InMiles}, Converter={StaticResource SpeedConverter}, Mode=TwoWay} for property DataMemberBinding VehicleSpeed and InMi...

App unable to connect to share after a period of time...

Hi, I've got a .NET app monitoring a network share and periodically it loses the connection. The app itself does not send any login info, it runs under the current (Windows) user. When this happens I can't connect to the network share in Explorer either, I need to reboot the machine. Is there any way programmatically in .NET I could ...

Why is IDisposable implementation designed the way it is

Let's take a look at the infamous IDisposable interface: [ComVisible(true)] public interface IDisposable { void Dispose(); } and a typical implementation, as recommended by MSDN (I omitted the check if current object has already been disposed): public class Base : IDisposable { protected virtual void Dispose(bool disposing) ...

How can I replace < and > in the content of xml file using regex?

How can i replace a "<" and a ">" (in the content of xml file) with a matching "&lt;" and "&gt;" (with a pre known set of tags) using a regex? example: <abc>fd<jkh</abc><def>e>e</def> should result with: <abc>fd&lt;jkh</abc><def>e&lt;e</def> it must be done with a regex! (no xml load and such...) ...

TM symbol not displaying correctly on redirected URL

I have a url that redirects to a page on my main site. For some reason, when I access through the rewritten URL, a TM symbol is showing up as â¢, but when I access through the main site, it shows up correctly. The urls are http://waterlessmilkwarmer.com/ and http://www.medelabreastfeedingus.com/milk-warmer so you can see what's happenin...

System.Speech.Recognition Choosing Recognition Profile

Does anyone know how to change recognition profiles from within a .NET application? I am writing a .NET application that does speech recognition using the capabilities found in the System.Speech.Recognition namespace. The audio that I am feeding into the system comes from multiple different users. I would like to be able to train the ...

.NET Regex Not working as it should

I have the following regex pattern: (.NET 1.1 Regex Validator) ^(?=.*[A-Za-z])[a-zA-Z0-9@\\-_\\+\\.]{6,32}$ I need to meet the following requirements: 6 to 32 characters must contain at least one letter. Allowed characters are letters (a-z, A-Z), numbers (0-9), @ ("at" symbol), . (period), _ (underscore), + (plus), - (minus)...

Is This a Good Design for Creating Thread-Safe Classes in C#?

Often, when I want a class which is thread-safe, I do something like the following: public class ThreadSafeClass { private readonly object theLock = new object(); private double propertyA; public double PropertyA { get { lock (theLock) { return propertyA; ...