.net

.NET Debugging & Tracking Performance: tricks / hidden features?

What are your opinions about what techniques should I use in the performance analysis and optimization of every application done in .NET technologies? Also what kind of debugging/tracing techniques do you know that can be powerful? Do you think that at large scale projects is necessary to have custom debugging/diagnostic classes? Do you...

Simple menu-like navigation in WinForms

Hello everyone, I am writing a very simple WinForms application with few data-entry forms. But before the user gets to these forms, she has to select which action to take (ie which form to open, possibly after entering a search query). As this application is a rewrite of a legacy custom DOS FoxPro app, the user wants the UI to be as sim...

Make NUnit not stop at first failure

I'm running a NUnit test over a list of numbers. My code goes something like this: numbers = GetListOfNumbers() foreach number in numbers Assert.IsTrue(TestNumber(number)) My problem is that NUnit will stop the test on the first number it encounters that doesn't pass the test. Is there anyway to make NUnit still fail the test ...

Linq Select Certain Properties Into Another Object?

So say I have a collection of Bloops Class Bloop Public FirstName Public LastName Public Address Public Number Public OtherStuff End Class Then I have a class of Razzies Class Razzie Public FirstName Public LastName End Class Is it possible using Linq to select the FirstName and LastName out of all the Bloops in the c...

Reflection and Generic type resulting in null

I need to get the type object for IProcessor via reflection and according to documentation I need to do the following: Type.GetType("IProcessor`1[System.Int32]") However, that returns null. I then tried: Type.GetType(typeof(IProcessor<int>).FullName) and still got a null. I am, however, capable of getting the Type argument with: ...

Is there a way to get a fully executable string of the SQL that is about to be run by a Linq2Sql expression?

I know you can get the SQL, but it's paramterized without the parameters being visible. Can you get the "full" string, so to speak? ...

How to preserve the contents of the clipboard

Hi all, Is there a way to preserve the contents of the clipboard? I tried the following code but it doesn't work. Dim iData As IDataObject = Clipboard.GetDataObject() ...(use clipboard) Clipboard.SetDataObject(iData) Thank you. ...

How do I handle http 302 redirect from .net remoting?

I need to be able to distinguish http 302 redirects from my code that use .net remoting. In order to connect to the appropriate url we try them in order until one works. In most environments the first url correctly fails with a System.Net.WebException with a status of WebExceptionStatus.NameResolutionFailure. For Customers that use Op...

Is there any definitive documentation on writing software installers?

I've read a bunch of documentation on installers and haven't come across anything good that explains the underlying concepts. Most of the installer software I've come across is based on the same "database" like structure that I just don't understand at all. All of the documentation that comes with the various products - i.e. WiX, Ins...

How to fake Foreign Key Collections Properties in Entity Framework and ASP.NET MVC

In Alex James' blog post How to fake Foreign Key Properties in .NET 3.5 SP1, he explains how to add a Foreign Key property to an Entity Object. I've used that to get a reference/navigation property working with a DropDownList in a strongly-typed ASP.NET MVC application as explained here: Strongly-Typed ASP.NET MVC with ADO.NET Entity F...

Sharing assemblies in .NET

Our applications use lot of custom built and third party libraries and right now each application has a private reference to these assemblies which means that the bin folder of each of these applications has the referenced assemblies copied. For e.g. Application A references log4net.dll, CustomLibA.dll, CustomLibB.dll and Application B a...

Is it possible to export a site definition in MOSS/Sharepoint using STSADM?

Is it possible to export a site definition (NOT a site template) using stsadm? I'm looking for a way of getting an export of ONET, WEBTEMP and any required features. ...

output xml with attributes

Hello, How do I get this output? <MSRP currency="USD">10.00</MSRP> writer.WriteElementString("MSRP", Convert.ToString(q.ItemPrice1)); writer.WriteAttributeString("currency", "MSRP", "USD"); this is the error: Token StartAttribute in state Content would result in an invalid XML document. ...

logging and Flush in .net

I have a program that looks something like this: public partial class It { static StreamWriter logging = new StreamWriter(new FileStream(@"C:\log",FileMode.Create)); void someFn() { logging.WriteLine("foo"); logging.Flush(); /// killed here in debugger with Shift+F5 } } The problem it tha...

Remove ClickOnce from a WinForms app

I have a WinForms application that was going to use ClickOnce. But it turns out ClickOnce won't work for my application, so I'd like to remove it. Only...there doesn't seem to be an obvious way to do this. There's no "Un-ClickOnce" button. Does anybody know what steps I need to take to get my app to be like it was before ClickOnce in...

.NET Email Content - Line Breaks

I've got an application that sends nicely formatted processing logs to the user. When I run the application locally (debug mode), using [SMTPServer] to send, the logs arrive neatly formatted and look as I'd expect. When I install the application on a testing server and configure it to use the same [SMTPServer] to send, the logs arrive ...

Reporting Services 2005 Report with Disclaimers page after each section

Details: I am using Reporting Services 2005 in a C# Application with Visual Studio 2008 to generate reports based on a SQL Server 2005 database. The application views the report locally using the .net report viewer and no report server is used. There is a page break in the report after each person. I am currently using just one rep...

Constants in a C# Web Application

Does it make sense to create a constant for the value of a penny? For example, if I needed to decrement an amount by a penny. Do you think it is more readable if the code said: amount -= Constants.StandardAmounts.Penny Or should I not even bother and just use .01. ...

Quickest way to convert a base 10 number to any base in .NET?

I have and old(ish) C# method I wrote that takes a number and converts it to any base: string ConvertToBase(int number, char[] baseChars); It's not all that super speedy and neat. Is there a good, known way of achieving this in .NET? EDIT: I should clarify - I'm looking for something that allows me to use any base with an arbitrary s...

Can I merge two .NET DataTables, without merging null values, without having to loop through the rows myself?

Suppose I have two .NET DataTables populated as follows, where ID is the primary key, and where null means a DBNull.Value (not the string "null"): |Table A | |Table B |ID |Column1 |Column2 | |ID |Column1 |Column2 | |1 |foo |10 | |1 |zzz |null | |2 ...