.net

Getting a specific Time Zone in .net CF 3.5?

I'd like to have a World Clock on my PocketPC. Getting the Local Time is no problem, and getting the UTC Time is even less a Problem. But I seem unable to get a specific Time Zone? Say I want the current Time Zone for New York, not knowing if it's Daylight Saving Time or not (so I do not know if it's Eastern Time (GMT-5) or Eastern Dayli...

Enum Boxing and Equality

Why does this return False public enum Directions { Up, Down, Left, Right } static void Main(string[] args) { bool matches = IsOneOf(Directions.Right, Directions.Left, Directions.Right); Console.WriteLine(matches); Console.Read(); } public static bool IsOneOf(Enum self, params Enum[] values)...

Linq Caveats

Linq is an awesome addition to .NET and I've found it has served me well in many situations even though I'm only beginning to learn about how to use Linq. However, in the reading I've been doing about Linq, I've discovered that there are some subtle things a developer needs to keep an eye out for that can lead to trouble. I've included...

Securing an ASP.Net MVC Site

As a relative newcomer to both web and MVC, I am looking for a good summary of security best practices that I should implement. The site will be public facing with "moderately sensitive data" (meaning we can't get sued, but probably wouldn't make many friends if the data got out!) and will have the following security steps taken: a:...

Would .NET benefit from "named anonymous" types?

Consider this: var me = new { FirstName = "John", LastName = "Smith" }; This is fine as we can then do this: Console.WriteLine("{0} {1}", me.FirstName, me.LastName); However we can't do this: public T GetMe() { return new { FirstName = "John", LastName = "Smith" }; } because we don't know the type of T. We could do this: p...

NHibernate Fluent Automapping Across DLLs

I have a Person class in 1 project/dll and a StandardUser class that derives from Person in another project/dll. I have a Password class that contains a StandardUser (Password and StandardUser are in the same dll). I can't seem to get the fluent automapping to work with this scenario. It tells me: NHibernate.MappingException: An as...

'System.Web.Security.SqlMembershipProvider' requires a databse schema compatible with schema version '1'.

Hi, i want to use profiles and was able to use aspent_regsql -A p to install the tables. I can see them throught SQL management studio. Im actually using SQLExpress 2005, and my dbo.aspnet_SchemaVersions is populated. Does anybody know what could be going wrong? By the way, im preety sure my connection string and app code are allright...

In C#, is there a way to consistently be able to get the selected text contents of currently focused window?

In my c# .Net application, I've been trying to be able to retrieve the currently selected text in the currently focused window. (Note that it can be any window open in windows, such as word, or safari). I'm able to retrieve the handle to the currently focused control. (Using a couple of interop calls to user32.dll, and kernel32.dll). ...

LINQ to SQL pitfalls

What are the major pitfalls that would make you think twice about using LINQ to SQL in an enterprise/non-trivial system? I know it lacks the power and flexibility of NHibernate, but I'm not clear on the major reasons why you wouldn't want to use LINQ to SQL in an enterprise app. ...

When should <%# ... %> and <%= ... %> be used?

I have been doing some work lately with a Pre-compiled .NET3.5 app so i have had to write alot of inline code and i was just wondering about the usage of the # and = and niether when doing inline code? ...

How to get Namespace of an Assembly?

Consider i have an assembly(class library dll) which i have loaded using the following code, Assembly a = Assembly.LoadFrom(@"C:\Documents and Settings\E454935\My Documents\Visual Studio 2005\Projects\nunit_dll_hutt\for_hutt_proj\bin\Debug\asdf.dll"); and i need to get the type of the Assembly. In order to get the type i need the nam...

advantages of .net over java in Intranet

Our company has an intranet with 30,000+ web pages and 160+ web applications. This is being used by 5000+ employees. We also have internet with 150+ Web applications and 100+ websites. Both the internet and Intranet is 7+ years and they run on classic ASP. Recently some "Technical Architects" came up with a wonderful idea of migrating...

Configuring conditional compilation symbol in app.config file

Can we configure conditional compilation symbol in app.config file? If it is possible then let us know how to do it. Thanks, P. Gopalakrishnan ...

Debugging in SSIS

How do I debug .NET code written within a script task in a SSIS package? The development environment allows placing a breakpoint however does not take me to the code like it would in regular .NET programming while debugging. Also, I am at a loss to understand how to add the SSIS package variables to the debug watch window? Currently on...

Why do we use memberless interface ?

What is the point of writing an interface without members ? INamingContainer is one example in .NET Framework. And it's described in MSDN as : Identifies a container control that creates a new ID namespace within a Page object's control hierarchy. This is a marker interface only. Is it used for just this kind of blocks : ...

How do you define a method in a class in its instance?

This is probably very easy, but I'm stumped. I would like to create a general purpose class which will be used multiple times in my program. I want this to be very lightweight and super fast. For a very simple example in C#: public class SystemTest { public TestMethod(string testString) { if(testString == "blue") ...

HTML Parsing Libraries for .NET

I'm looking for libraries to parse HTML to extract links, forms, tags etc. http://www.majestic12.co.uk/projects/html_parser.php http://www.netomatix.com/Products/DocumentManagement/HtmlParserNet.aspx http://www.developer.com/net/csharp/article.php/2230091 LGPL or any other commercial development friendly licenses are preferable. Hav...

Creating shortCut keys with multiple Chars

Hi, I want to design a shortcut keys framework. Such as Alt + CA, Alt + CI such that the second shortcut key option is a combination of multiple characters. Is there any way to achieve this. Regards, Harsh Suman ...

How do I add extra information to XML generated from a dataset Writexml in C#?

ds.WriteXml(strXmlTestCasePath, XmlWriteMode.IgnoreSchema); ds is a dataset. I want to add an extra line or extra information into this XML. How do I do it? ...

How to conditionally remove items from a .NET collection

Hi all, I'm trying to write an extension method in .NET that will operate on a generic collection, and remove all items from the collection that match a given criteria. This was my first attempt: public static void RemoveWhere<T>(this ICollection<T> Coll, Func<T, bool> Criteria){ foreach (T obj in Coll.Where(Criteria)) Col...