.net

What's the difference between using the thread pool and a normal thread?

I Was reading random questions and answers here on SO and came across this question: C#, IAsyncResult and the thread pool The question is asked is X method using the thread pool or using normal threads. What's the difference between using the thread pool and a normal thread? ...

.NET SqlConnection class, connection pooling and reconnection logic

We have some client code which is using the SqlConnection class in .NET to talk to a SQLServer database. It is intermittently failing with this error: "ExecuteReader requires an open and available Connection. The connection's current state is Closed" The "temporary" solution is to reboot the process, after which everything works - howe...

What's the best .Net technical thing you've learned over the past 3 years?

What 1 thing in programming has had the largest payoff that you've learned over the past 3 years. Yes, 3 years is an eternity it IT. I'm trying to decide what to learn next and want to see what you've learned that has the most payoff and why. This could be anything like (but not limited to) coding to an interface, unit testing, TDD, moc...

How to get streetaddress property of an organizational unit in windows active directory with LDAP in C#.Net

Each of our users is assigned to a primary organizational unit (OU) based on which global office they are in. So the "Chicago" OU contains all the associates in our Chicago office. Using c# and .net 3.5, my task is to extract all of these users. Unless the users are in a satellite or home office, their street address, city, state, etc....

Can C++/CLI be used to call .Net code from native C++ applications?

I've done the other way around (Calling pure C++ code from .Net) with C++/CLI and it worked (for the most part). How is the native->c++/cli direction done? I really don't want to use COM interop... ...

Settings class architecture.

Just wondering what the best practise advice would be on the architecture for a settings class. We've a number of tables which will be used to populate the class, I'm guessing a Hashtable is the best way to go? It also would be nice to have a strongly typed collection available through the scope of the app in Intellisense. e.g. Settin...

Share a web service among projects

In one Visual Studio solution, I have several projects. A couple of them access a certain web service. How can I add a service reference once, and have it used by both projects? I do not want to create an extra assembly for the sole purpose of providing access to the web service. ...

"Layout Shapes" in Windows Workflow

I've been looking for hours. Its possible it doesn't exist and I should just get over it.... But I have a state machine I'm designing and it isn't humanly possible to layout the shapes in some sort of clear manner. Not that a program could do better but it would be a good starting point. Does anyone know of a automated shape layout util...

Is it possible to have too many anonymous delegates?

Lately, I have taken to the pattern of having a lot of diagnostic logging in parts of my code, that makes use of lambda expressions/anonymous delegates like so: MyEventManager.LogVerbose( LogCategory.SomeCategory, () => String.Format(msg_string, GetParam1(), GetParam2(), GetParam3() ); Notice that the second argument to LogVerbose is ...

How can I check if a directory can be renamed in VB.NET?

My thought is to use CreateFile from kernel32 and check for sharing violations. I believe this will work because I watched the file system activity with Process Monitor while issuing a rename command from CMD that I knew would fail and the last activity was a failed CreateFile call that resulted in a sharing violation. This is the Proce...

Can I detach an object from an NHibernate session?

If I've gotten a persistent object from the database via NHibernate's Get() or Load() methods, is there a way for me to detach that object from its NHibernate session so that changes to it will not automatically be persisted? ...

jqGrid - How does one configure jsonreader (for use with Jayrock)?

Hi, I wondered if someone might have some insight into this. jqGrid is quite happy with this JSON string: {'page':'1','total':1,'records':'4','rows':[{'id':1,'title':'Story Manager','assigned':'2009-06-22T10:52:28.0687738-05:00','due':'2009-07-29T10:52:28.0687738-05:00','completed':'2009-07-14T10:52:28.0687738-05:00'},{'id':2,'title':'...

How to Determine pixels available for Text in System.Windows.Forms.Button

I have a series of buttons that display filenames. If I set the Text property when the filename is wider than the number of pixels available the text "wraps" and instead if the text being displayed LeftMiddle it is displayed LeftTop. Therefore I only display as many characters as can be shown (using the PathCompactPathEx() method). Howe...

Clickonce error: missing files. Need to get missing filename

My ClickOnce app gives an error for a user: "Cannot download the application. The application is missing required files. Contact the application vendor or your system administrator for assistance." How can I pinpoit which file is missing? Do I manually need to put files on the publishing server? I thought when I click on the prerequisi...

What clustering solutions are available in .NET?

As a kind of follow on to this question, what specific services are available for .NET that allow clustering in .NET similar to what is available in (Session) EJBs. The answer to the other question focused on the remote method invocation and transaction management of EJBs, but what about clustering for fail over and scalability purposes?...

Linq to XML performance - Standalone test vs Very large web application

So I took a specific hot-spot from a very large web application, that does lot of XML processing (adding nodes, adding attributes to nodes based on some logic), then created a standalone test to mock the same situation using Linq to XML (as opposed to XmlDocument) There was 2 to 10 times performance improvement in the standalone test co...

Best way to split an address line into two fields

We are developing a c# application that imports address-data into a CRM-system. The CSV-file contains an address-column like 'Somethingstreet 34'. Our CRM however uses two different fields for the streetname and the housenumber. Of course, in the given example this poses no problem. But our Dutch addressing-system can be a bit of a pain....

Get IPv4 addresses from Dns.GetHostEntry()

I've got some code here that works great on IPv4 machines, but on our build server (an IPv6) it fails. In a nutshell: IPHostEntry ipHostEntry = Dns.GetHostEntry(string.Empty); The documentation for GetHostEntry says that passing in string.Empty will get you the IPv4 address of the localhost. This is what I want. The problem is that...

CA1062: ValidateArgumentsOfPublicMethods on co-constructor calls

I have a class with two constructors that look like this: public MyClass(SomeOtherClass source) : this(source, source.Name) { } public MyClass(SomeOtherClass source, string name) { /* ... */ } When I run FxCop, it correctly reports a violation of CA1062: ValidateArgumentsOfPublicMethods, because if source is null in the first construc...

Multiple representations of the same entity

Thinking about avoiding code replication, I got a question that catches me every time I start developing a new system: Let's say we have a system where I have a customer, have to CRUD it in a repository and show it as a resource in a webservice. Thinking about the classes related to the customer, we would have (Okay, I will never use ...