.net

What pros/cons come from using a server OS for your main .NET development machine?

I was considering using Windows Server as the OS for my main .NET development workstation. It includes the version of IIS to which I'm most often deploying, manages FIPS compliance differently, etc. I certainly don't use any of the multimedia or gaming advantages (if there are any?) of a workstation OS. What pros/cons come with using ...

Does adding return statements for C# methods improve performance?

This blog says 12) Include Return Statements with in the Function/Method. How it improves performance Explicitly using return allows the JIT to perform slightly more optimizations. Without a return statement, each function/method is given several local variables on stack to transparently support returning values without the keyw...

Finding property differences between two C# objects

The project I'm working on needs some simple audit logging for when a user changes their email, billing address, etc. The objects we're working with are coming from different sources, one a WCF service, the other a web service. I've implemented the following method using reflection to find changes to the properties on two different obj...

Case insensitive string compare with linq-to-sql and linq-to-objects

see also Differences between LINQ to Objects and LINQ to SQL queries We are using the some queries over our database and our in memory objects. What is the best way of doing an insensitive string compare with linq-to-sql so that? It runs fast on SQL Server The same query expression can be used with linq-to-objects to get the same res...

Rhino Mocks stubs and mocks are only good for interfaces?

Is it correct that Rhino Mocks stubs and mocks are only good for interfaces, not concrete classes? I spent quite a time trying to make this piece of code working. What I did not expected is that stabbed pubSubClient will always call Send method from the class. That method has some dependencies and throws exception. [Test] public void Te...

.NET - preview Excel files (XP)

Is there any method to preview Excel files on XP besides WebBrowser control? How does the WebBrowser itself preview them? ...

Using C# what is the most reliable way to calculate network bandwidth speed?

Using C# what is the most reliable way to calculate network bandwidth speed? I've found a few examples using NetworkInterface, Performance Counters, native Win32 code, etc. but they all provide different results and none seem to match what other, already existing, tools are showing. Any advice on the most reliable method to calculate n...

ASP.NET Requests... what do to with a Linq DataContext?

Sorry, if this is a duplicate. Please point me to the appropriate question if this is but I could not find exactly what I am looking for. So I am using a Linq to SQL datacontext for entity tracking and persistence in an ASP.NET web application. It is for an Intranet application that does not have a ton of users at a time. Right now I ca...

Worksheet.Unprotect - Office Interop - Difference between 2003 and 2007

I have a .NET winforms app that automates Excel and checks for a worksheet password. The requirements are to be able to detect 1) that the protection is turned off 2) that the password is removed (protected but there is no password) 3) that the password matches the correct password from a database To meet the second requirement the prog...

Unit test for Web Forms MVP presenter has a null Model

I am using Web Forms MVP to write an DotNetNuke user control. When the 'SubmitContactUs' event is raised in my unit test the presenter attempts to set the 'Message' property on the Modal. However the View.Modal is null in the presenter. Shouldn't the Web Forms MVP framework automatically build a new View.Model object in the presente...

case insensitive string search csharp

Hi There, What is the quickest most efficient way to search text for words using non-casesensitive search. E.g here is my text to be searched : string textTosearch = "Here is a paragraph or Some text. Here is some more text". If i wanted to find the indexes of "Some" and "some", is there a .Net class string that does this or would i nee...

LinqToSql - change table name attribue at runtime?

When you create a model using LinqToSql, the designer puts an attribute for each table class that looks like [Table(Name=@"dbo.Project")] At design time this is easy to change either manually or using T4 templates. Can this table attribute be changed at runtime? ...

Help, why have my Equals methods have all started thowing Invalid Cast Exceptions?

Several of my overriden Equals methods have started throwing Invalid Cast Exceptions - Unable to cast object of type 'System.DBNull' to type Common.ResolveUser'. This occurs when binding List (of T) (where T is of type ResolveUser in this case) to a combo. Equals Method: Public Overrides Function Equals(ByVal obj As Object) ...

Relative Path with Response.AddHeader

I am running a timer and performing a redirect after a user changes his or her password (AKA, notify them that the password was changed and then send them back to the home page). However, I can't seem to do a relative path in the code below. Listed below is what I'd like to do: Response.AddHeader("REFRESH", "2;URL="~/pages/home.aspx")...

Where to store Regex?

When you are using a Regex instance, that is used in a method where that method is called a couple thousand times to parse things in a certain way, should that method include the Regex instance, or should the Regex instance be part of the class as a static member? I get the feeling that initializing the same Regex thousands of times mig...

Oracle Stored Procedures - Returning a Cursor From a Procedure that Opens the Cursor...

Using .Net and Oracle 11g - I've been returning dataTables from a procedure inside of a package by opening a Cursor. IE - 'OPEN TABLEREF FOR SOMESQL; Where TableRef is an 'OUT' Param. It's been working great. What I'm struggling to do is have that first Proc call another Proc and let that second Proc open the cursor. Inside Proc1 (w...

Launch a .NET DLL from an ASP.NET page

I'm working with a intranet website written in ASP.NET and need to be able to access a DLL that is installed on the user's computer. I can get it working if I'm hosting the site locally but when I try to access it from another machine it does not work. I realize this could be a dangerous tool to use but if you have a valid business purpo...

XSD.exe and "Circular Group references"

I am attempting to build some classes so that I can deserialise an XML file created by a third party application. Luckily the developer of the 3rd party application included a schema file with their code so that the XML file can be understood. When I use the XSD.exe tool from Visual Studio the process fails reporting the following error...

AllocHGlobal equivalent in VB6

All, I have to write some share permission code in a legacy VB6 application. I know I will have to use API calls, and found a good example here. But I'm not clear on how to achieve some of the same functionality from VB6, mostly with memory allocation. For example: pTrustee = Marshal.AllocHGlobal(Marshal.SizeOf(t)) BuildTrusteeWithSid(...

how to permit only letters in a textbox in windows forms application?

to permit letters from A to Z what is the source code in C#? ...