.net

Viewstate invalid when using Safari

Hey guys, just had a bug submitted for a site I maintain which heavily uses the viewstate (not my code). However on certain pages when the viewstate is extra bloated Safari is throwhing the usual "Validation of viewstate MAC failed" error. Any ideas?? Only happens in Safari, Firefox, IE, Opera all fine....

Limit size of Queue<T> in .NET?

I have a Queue<T> object that I have initialised to a capacity of 2, but obviously that is just the capacity and it keeps expanding as I add items. Is there already an object that automatically dequeues an item when the limit is reached, or is the best solution to create my own inherited class?...

Is nAnt still supported and suitable for .net 3.5/VS2008?

I am using MSBuild to build my stuff. I want to use CruiseControl.net as by Build Server. Now, CCNET refers nAnt a lot, but it looks as if ccnet can do most of the stuff nant could do through the project configuration and msbuild. Also, nAnt seems a bit unsupported, with a Beta release that is almost a year old now. In short: I am actu...

How to check For File Lock in C# ?

Is there any way to check whether a file is locked without using a try catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException. ...

Subsonic Vs NHibernate

What is the concensus on when to use one of these tools adversed to the other? I find Subsonic very useful in terms of getting things done quickly, but on large projects it tends not to scale, and its ties your domain model to your database model. That is where Nhibernate comes in as it gives you lightweight POCOs that are unrelated to y...

What are the current best options for parallelizing a CPU-intensive .NET app?

This is an open-ended question. What approaches should I consider?...

What is ALT.NET?

Recently, Scott Hanselman blogged and podcasted about ALT.NET. What is it and how is it a new concept? What can I learn?...

.NET Unit Testing packages?

Getting back into a bit more .NET after a few-years of not using it full-time, and wondering what the good unit testing packages are these days. I'm familiar with NUnit (a few years ago), and have played briefly around with IronRuby, with the goal of getting something like rspec going, but don't know much beyond that. I realise I could...

Are Multiple DataContext classes ever appropriate?

In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary to create DataContext classes (which is usually done using the designer in VS 2008). From the UI perspective, the DataContext is a design of the sections of your database that you would like to expose to through LinqToSql and is integral in setting up the ORM ...

Most Efficient Way to Test Object Type

I have values stored as strings in a DataTable where each value could really represent an int, double, or string (they were all converted to strings during an import process from an external data source). I need to test and see what type each value really is. What is more efficient for the application (or is there no practical differenc...

Do sealed classes really offer performance Benefits?

I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where sealed classes will give better results? Has anyone run tests and seen a di...

LINQ on the .NET 2.0 Runtime

Can a LINQ enabled app run on a machine that only has the .NET 2.0 runtime installed? In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in .NET 2.0. How can I write LINQ without using the .NET 3.5 libraries? Will it run on .NET 2.0?...

How can I change the background of a masterpage from the code behind of a content page?

I specifically want to add the style of background-color to the body tag of a master page from the code behind (C#) of a content page that uses that master page. I have different content pages that need to make the master page have different colors depending on which content page is loaded in such that the master page matches the cont...

What's the best way to implement BDD/TDD in .NET 2.0?

I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for .NET 3.5. Does anyone have a suggestion about good testing frameworks to use?...

How to filter and combine 2 datasets in C#

I am building a web page to show a customer what software they purchased and to give them a link to download said software. Unfortunately, the data on what was purchased and the download information are in separate databases so I can't just take care of it with joins in a query. The common item is SKU. I'll be pulling back a list of S...

Casting: (NewType) vs. Object as NewType

What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject;SomeClass sc2 = SomeObject as SomeClass; Normally, they should both be explicit casts to the specified type?...

Best .NET obfuscation tools/strategy

My product is both ASP.NET, Windows forms app and Windows service. 95% of code is .NET (VB if you must know). For IP reasons, I need to obfuscate the code. I am using an old dotfuscator (over 5 years old) and thinking it is time to move to a new gen. Anyone can recommend from their personal experience (please don't just give me a list ...

Setting Objects to Null/Nothing after use in .NET

Should you set all the objects to null (Nothing in VB.NET) once you have finished with them? I understand that in .NET it is essential to dispose of any instances of objects that implement the Idisposable interface to release some resources. Although the object can still be something after it is disposed (hence the isDisposed property ...

Reading a C/C++ data structure in C# from a byte array

What would be the best way to fill a C# struct from a byte[] array where the data was from a C/C++ struct? The C struct would look something like this (my C is very rusty): typedef OldStuff { CHAR Name[8]; UInt32 User; CHAR Location[8]; UInt32 TimeStamp; UInt32 Sequence; CHAR Tracking[16]; CHAR Filler[12];} And wo...

Possible to "spin off" several GUI threads? (Not halting the system at Application.Run)

My Goal I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even possible with Windows Form...