.net

Is this a bug in DirectoryInfo.GetDirectories(string searchPattern)?

When calling DirectoryInfo.GetDirectories(".") on an instance of a DirectoryInfo class which points to a valid folder (excluding drive roots), the result is a DirectoryInfo array whose first (and only) element points to a invalid directory named the same as itself, below itself. For example: static void Main(string[] args) { Direct...

"Most popular" GROUP BY in LINQ?

Assuming a table of tags like the stackoverflow question tags: TagID (bigint), QuestionID (bigint), Tag (varchar) What is the most efficient way to get the 25 most used tags using LINQ? In SQL, a simple GROUP BY will do: SELECT Tag, COUNT(Tag) FROM Tags GROUP BY Tag I've written some LINQ that works: var groups = from t in Dat...

Testing Functions for ASP.net (The Object Test Bench)

Edit I noticed that the Object Test Bench is a good example of what I'm looking for, but it doesn't seem to work with ASP.net. I always get an error that an instance could not be created. Is there a way to test your functions in ASP.net without needing to create a web page and click on a button. For example, if I create a controller...

Insert Function Name during PreBuild

I wanted to write a Visual Studio Macro or something similar which can fetch function name and insert into preset location in the error report part. It's clearer if you look at the example Class SampleClass { public void FunctionA() { try { //Do some work here } catch (Exception ex) ...

Is it possible to execute SQL commands and send MSMQ messages in a TransactionScope?

I'm investigating using MSMQ for my team's new project but I need to know if I can send MSMQ messages and execute SQL commands within a System.Transactions.TransactionScope and have them commit or rollback together. I can't find a reliable source online that says "yes" with code examples. I need to send some messages to a single queue ...

Best way to search large file for data in .net

I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example, this is the token 9,999,999.99 So here's is how I am approaching this problem. After a little analysis...

Benefits of DataBinding over Manually Querying / Adding to Control

I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this: What is the benefit to use databinding from sql queries directly to a control over querying and manually adding items to the contr...

Do any .NET DLLs exist that implement luac's functionality?

Does anyone know of any DLLs (preferably .net) that encapsulate the lua 5.1 compiler? I'm working on a .net project where part of it needs to compile lua scripts, and i would rather have a DLL that i could send script code to instead of sending the script to a temporary file and running luac.exe. Edit: I'd need a .NET library that impl...

WYSIWIG Editor Not Working with Update Panels (AJAX) in .NET

We're testing WYSIWYG editors, and we cannot see to make them work with asynchronous postbacks. We put the TextBox(/textarea) in the UpdatePanel and call a simple save to the DB, and all of our WYSIWYG toolbars disappear, leaving us with a bunch of HTML in textboxes. This is the one we've been working to implement: nicedit.com/ We have...

Add columns to an Access (Jet) table from .NET

Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't. Can someone provide a quick code sample, link, or nudge in the right direction? (I'm using c#, but a VB.NE...

passing DB Connection object to methods

Was wondering if it is recomended to pass a database connection object around(to other modules) or let the method (in the other module) take care of setting it up. I am leaning toward letting the method set it up as to not have to check the state of the connection before using it, and just having the caller pass any needed data to the c...

Silverlight, Wpf Web App (xbap) or Click Once? Pros and Cons

We are starting a new project and I'm trying to decide which of the Wpf-esque develop/deploy strategies we should go with. In our case we are looking at quite a complex business app that will be used by 100s (not 1000s) of people, So I'm leaning towards a click-once app. My boss likes the idea of a Silverlight app as it means easier depl...

Why don't you source control your references directly?

I'm in the process of establishing some new source control best practices for my organization, so I've been immersing myself in things like TreeSurgeon for the past few days. One thing I see a lot is that it's a best practice to include your references in your source control tree, but in a seperate directory (lib/ in tree surgeon) rathe...

What is your "Watch out" list regarding avoiding memory leaks when you write .NET code?

What do you keep on mind to avoid memory leaks when you write thousands lines of .NET code? I'm a big fan of prevention over inspection , there is a famous example regarding this point which is using a "StringBuilder" to combine strings instead of "String1+String2", so what is else out there from your coding experience? thanks in advan...

Sharing .NET session/authentication with Flex

I have a .NET 1.1 application (VB.NET 1.1 shopping cart) into which a user authenticates. I want to 'bolt on' a Flex application but dont want to have to have the user reauthenticate. They shouldn't know it is a separate application. I want to use WebServices (C# 3.5) over some kind of secure channel. My main question here is how do I...

Databinding DropDown Control in .Net

I am binding the dropdown with db entity. ddlCustomer.DataSource = Customer.GetAll(); ddlCustomer.DataTextField = "CustomerName"; ddlCustomer.DataBind(); I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this? ...

Cross Resolution Applications in .NET

We are developing a little in house application that will run on monitor having multi resolutions. Now we want that the application should adjust itself and remain consistant over all monitors. I came from Java background too where we used different layouts to accomplish the task. I experimented in .NET with different layouts like UniGri...

Using .Net how do I use the Sort method to sort an Array in reverse i.e. Z to A?

Using .Net how do I use the Sort method to sort an Array in reverse i.e. Z to A? ...

[.NET] How do I disable a system device?

Is there any way to disable a system device from C#.NET. Basically emulating when you go to Device Manager and disable a device that way? I am assuming there is a WinAPI function that I can invoke, but I don't know which one it is? The reason I need to do this is that I need to disable and straight after enable the device again. I ne...

Should I use enum or query a table in my database?

In my database I have tables that define types for example Table: Publication Types ID | Type ---------- 1 | Article 2 | Abstract 3 | Book .... Which is related through the ID key to a publication tables which has the field TypeID. I then create a PublicationTable data table my .NET application which I want to filter based on ...