.net

Disadvantage of HttpUtility.HtmlAttributeEncode

I have to encode a field so to make it secure of script injection. I know I can use HttpUtility.HtmlEncode and Decode, but this method for HI-ASCII characters goes out of the range of the field size in database and I dont want to change the size of data field column. Instead if I use HttpUtility.HtmlAttributeEncode, it works fine beca...

Need events to execute on timer events, metronome precision.

I setup a timer to call an event in my application. The problme is the event execution is being skewed by other windows operations. Ex. openning and window, loading a webpage. I need the event to excute exactly on time, every time. When i first set up the app, used a sound file, like a metronome to listen to the even firing, in a stead...

Excel 2003 VSTO convert to PDF

I have an excel workbook vsto solution that needs to generate a pdf copy of one of its sheets as output. I have a license for abcdpdf .net and tried outputting to html, then using abcpdf to convert the html to pdf, but the excel html markup tries to emulate excel with all 4 worksheets with horrible markup. It also messes up the colors ...

Managed modules and platform independence

The .Net model is something like this : C# Code -> C# Compiler -> Managed Module (Win PE) -> CLR -> "Hello, world" The code is compiled to a managed module which invokes CLR which in turn does the necessary work to run the code (assuming it's an exe). My initial understanding was that .Net is the Microsoft equivalent of Java Framework ...

Wrap a LINQ datacontext and non linq stored procedure into a transaction?

Is it possible to wrap some "external" API code AND a LINQ data context into a transaction? In my case, I want to wrap the ASP.NET 2.0 Membership API calls AND my own LINQ operations into a transaction. ...

Should I dispose GDI+ object before its creation?

Should I dispose GDI+ object before its creation? Is recommended to always Dispose GDI+ object after using it. by e.g. Pen p = new Pen(Color.Green); // use 'p' p.Dispose(); now, if I have this situation: Pen p = new Pen(Color.Green); // use green 'p' p = new Pen(Color.Red); // Should I Dispose my 'p' first? // use red 'p' p.Disp...

NUnit GUI Runner and Apartment State

how do you set the apartment state in the NUnit GUI runner? I'm trying to run a single NUnit test with WatiN and I'm getting the message. MyNamespace.LoginTests.CanLogin: System.Threading.ThreadStateException : The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer. ...

On the search for my next great .Net Read

Just got done with "The art of unit testing". It was a great read and i think everyone should go buy a copy. With that said i think the next book I'm like to read would be a architecture / Design type book that would focus heavily on building your objects / software in such a way that it would be: Low Coupling High Cohesion Easily Ma...

Is the .NET 4 Framework going to change?

Is the .Net 4 Framework going to change before the "go-live" or can we safely assume that the framework will stay the same as it currently is in the Release Candidate? ...

Why is _AppDomain prefixed with an underscore? Seriously, it bugs me that it is always in my field intellisense...

Whenever I write a new class and add some internal fields, I use an underscore prefix like so: private readonly int _foo; Why did the .NET team decide to create an AppDomain interface with the name _AppDomain? It just bugs me to see it whenever I type an underscore to get my class level fields in intellisense. Why isn't it IAppDomain ...

.net equivalent of htmlunit?

Does anybody know if there is a .net equivalent of htmlunit or similar library? I've heard that people have used IKVM to convert the htmlunit library. But I have also heard that the converted code is slow. Requirements: Headless browser Support javascript Handle cookies .Net ...

Update panels don't work after converting from VS 2005 to VS 2008

I've updated to the latest version of the AjaxControlToolkit, but it still doesn't seem to work. UpdatePanel for example works the first time, but it never hits my endrequesthandler. ...

Should enumerations be placed in a separate file or within another class?

I currently have a class file with the following enumeration: using System; namespace Helper { public enum ProcessType { Word = 0, Adobe = 1, } } Or should I include the enumeration in the class where it's being used? I noticed Microsoft creates a new class file for DockStyle: using System; using System....

StyleCop XML Documentation Header - Using 3 /// instead of 2 //

I am using XML documentation headers on my c# files to pass the StyleCop rule SA1633. Currently, I have to use the 2 slash commenting rule to allow StyleCop to recognize the header. for example: // <copyright file="abc.ascx.cs" company="MyCompany.com"> // MyCompany.com. All rights reserved. // </copyright> // <author>Me</author> ...

MS Exam 70-536 - How to throw and handle exception from thread?

Hello! In MS Exam 70-536 .Net Foundation, Chapter 7 "Threading" in Lesson 1 Creating Threads there is a text: Be aware that because the WorkWithParameter method takes an object, Thread.Start could be called with any object instead of the string it expects. Being careful in choosing your starting method for a thread to deal with...

Extensions methods and forward compatibilty of source code.

Hi, I would like solve the problem (now hypothetical but propably real in future) of using extension methods and maginification of class interface in future development. Example: /* the code written in 17. March 2010 */ public class MySpecialList : IList<MySpecialClass> { // ... implementation } // ... somewhere elsewhere ... MySp...

Custom Online Backup Solution Advice

I have to implement a way so our customers can backup their SQL 2000/5/8 databasase online. The application they use is a C#/.NET35 Winforms application that connects to a SQL Server (can be 2000/2005/2008, sometimes express editions). The SQL Server is on the same LAN. Our application has a very specific UI and we must code each for...

What is the list of trace sources supplied by the .Net framework?

.Net defines a "Trace Source" concept, allowing configuration files to specify which trace sources to listen for messages on. WCF provides several trace sources, and I would presume that other portions of the .Net Framework BCL publish other trace sources as well. What is the list of trace source names published to by the BCL? ...

How to dynamically modify NHibernate load queries at runtime? EventListeners? Interceptors?

I need to modify the query used to load many-to-one references in my model. It needs to work with lazily loaded entities as well. Specifically, I need to be able to further filter this data. Unfortunately, NH will not allow me to filter many-to-one relationships using the built in filtering system (?). I could just be doing something i...

Databind listbox

I'm pretty new to asp net 2.0 programming and I was wondering how can I add an "all" item to a listbox, so I can filter my results by a specific criteria ( from a database ) or display all the results. Thanks in advance ...