.net

How do I find the type of the object instance of the caller of the current function?

Currently I have the function CreateLog() for creating a a log4net Log with name after the constructing instance's class. Typically used as in: class MessageReceiver { protected ILog Log = Util.CreateLog(); ... } If we remove lots of error handling the implementation boils down to: [EDIT: Please read the longer version of C...

Should controllers in an ASP.NET MVC web app call repositories, services, or both?

The controllers in my ASP.NET MVC web app are starting to get a bit bloated with business logic. The examples on the web all show simple controller actions that simply pull data out of a repository and pass it to the view. But what if you also need to support business logic on top of that? Say, for instance, an action that fulfills ...

Is it possible to use ODP 11 xcopy deployment and not change the PATH?

I have an application that's using Oracle.DataAccess to connect. I've already discovered that the footprint can be lessened by using ODAC 11 with xcopy deployment. That's already a big win. Ideally, though, we would like to not have to alter any path variables and have all the ODAC files in a subdirectory underneath the application's ...

Monitor .NET Threads

Is there any way to monitor/log thread interactions in the .NET runtime much like VisualVM does for Java? I don't have a specific need at the moment but I think it would be nice to see how all the threads in my application interact. ...

Binding to DataGridView - Is there a way to "bind" the background color of a cell?

I am binding a List to a DataGridView. One property of the SomeObject class will be a status code (ex. Red, Yellow, Green). Can I "bind" the status to the background color of a cell easily? How about binding to a tooltip also? ...

What is the Managed C++ equivalent to the C# using statement

How would one code the following C# code in Managed C++ void Foo() { using (SqlConnection con = new SqlConnection("connectionStringGoesHere")) { //do stuff } } Clarificaton: For managed objects. ...

What is the difference between using IDisposable vs a destructor in C#?

When would I implement IDispose on a class as opposed to a destructor? I read this article, but I'm still missing the point. My assumption is that if I implement IDispose on an object, I can explicitly 'destruct' it as opposed to waiting for the garbage collector to do it. Is this correct? Does that mean I should always explicitly ...

Is there a way to programmatically concatenate excel files?

The scenario: we have a web system that automatically generates office 2003 excel files "on the fly" (using the 2003 XML file format, not the binary format.) These files do get kept on the web server for various things. Now, we're in a situation where the client would really like us to take the xls files generated by this process and g...

Silverlight web page architecture

New to silverlight. Traditionally if I were to design a wizard-like process where a user had to go through 3 or 4 steps, I'd have each step as a separate aspx page. Using silverlight, would you do it all in one component, or would you have 3 separate pages each with a different silverlight component? What kind of advantages/disadvant...

C# Syntax - Example of a Lambda Expression - ForEach() over Generic List

First, I know there are methods off of the generic List<> class already in the framework do iterate over the List<>. But as an example, what is the correct syntax to write a ForEach method to iterate over each object of a List<>, and do a Console.WriteLine(object.ToString()) on each object. Something that takes the List<> as the first a...

Expression trees in .NET - Libraries?

I have recently written a dynamic querying tool using expression trees and as I went the power of expression trees began to dawn on me. My querying tool could also form the basis of a reporting tool, a dynamic decision engine and maybe other cases where you need to work with dynamic objects in abstract ways. The process has been painfu...

TransactionScope not rolling back transaction

Here is the current architecture of my transaction scope source code. The third insert throws an .NET exception (Not a SQL Exception) and it is not rolling back the two previous insert statements. What I am doing wrong? EDIT: I removed the try/catch from insert2 and insert3. I also removed the exception handling utility from the ins...

Is there a .Net equivalent to Apache Hadoop?

So, I've been looking at Hadoop with keen interest, and to be honest I'm fascinated, things don't get much cooler. My only minor issue is I'm a C# developer and it's in Java. It's not that I don't understand the Java as much as I'm looking for the Hadoop.net or NHadoop or the .net project that embraces the Google MapReduce approach. Do...

VB.NET and type inference using "Dim"

I'm coming from a C# background and I really like the type inference that C# 3.0 has. I'm trying to do similar things in VB.NET (some of which appear possible), but in some cases the compiler seems to be not nearly as good at inferring the type. For example, I have a method that returns an object of type System.Guid. In C# I'd do thi...

Resolving Configuration Error in WCF AddressFilter Mismatch

I am getting the following error and could use some help resolving it. Anyone have any ideas? The message with To 'http://localhost:60078/BidService.svc/Query' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree. The client config...

.Net FileIOPermission & ApplicationData

I'm getting a FileIOPermssion exception thrown when trying to create a folder in Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) on some computers. I've established that there is some form of antivirus running on the computer in question, but I haven't been able to get in contact with their IT department to find out ...

Why was the C# mascot 'Andy' retired?

In the early days of C# there was a mascot for C# called 'Andy' and Microsoft retired it. Why did they do this? Does anyone have a picture of him? ...

What is the best approach for applying styles to massive amounts of items?

In my LOB apps I usually wind up with containers that contain a bunch of different textblocks and textboxes for users to enter data. Normally I need to apply a certain margin or vertical/horizontal alignment to each control. Let's say I have Grid on my form that looks like this (a lot of markup was eliminated for brevity): <Grid> <G...

Provide version to only the Prerequisites in clickonce

Hi, I am deploying an application, where I need to add two prerequisites. My problme is that I need someway to provide version to the prerequisites so that in the future may be I could only update the prerequisites without updating the entire application. Thank You Sunil Chaudhary ...

Does RegularExpressionValidator use other flavor than Regex?

I want to do preliminary check if entered string looks like Vehicle Identification Number (VIN). I know what it consists of 17 letters and digits, but letters I, O and Q are not allowed inside VIN, so I use this regular expression: ^[0-9A-Z-[IOQ]]{17}$ Now if I check a string like 1G1FP22PXS2100001 with RegularExpressionValidator it f...