.net

ASP.NET application only partially reading external configuration

I have an ASP.NET web app and am attempting to reference an external config (using enterprise application blocks configuration) for some of the configuration but it is not entirely working. I previously had all of the configuration info in the web.config (and it was working), but we are wanting to share some of this configuration inform...

Do your admins modify your web.config files?

I'm wondering how other developers are handling source code conflicts for config files when system admins modify them in production. For example, if a system admin updates a appsettings key on the production server and then my team publishes out a project, it will overwrite that key. How do you handle config file updates in your organiz...

How do I Change SQL Server column names in T-SQL?

I have a table with 600+ columns imported from a csv with special chars % _ - in the column names, is there a way to change the column names to remove these special chars ? The code can be in T-SQL. ...

asp .net MVC 2.0 Validation

Hi I’m trying to do some validation in asp .net MVC 2.0 for my application. I want to have some nice client side validation. Validation should be done most time on model side with DataAnnotations with custom attributes( like CompareTo, StringLenght, MinPasswordLenght (from Membership.MinimumumpassworkdLenght value). For that purpose I t...

creating a category list using linq

I have the following List which contains the following collection. How i can transform this with linq so that i get nested items. var categories = new List<Category>(); // id, parentId, name categories.Add(1, 0, "Sport"); categories.Add(2, 0, "Pets"); categories.Add(3, 1, "Foot ball"); categories.Add(...

Limit only one session per user in ASP.NET

Is there anyway to detect when a user logins if there is already another session with the same username, and block him from logging in again or send him a message? ...

How to write ASCII special characters in a .Net string

Suppose I want to use the ASCII special character FS(0x1C) in a .Net string, and then be able to format a byte array from that same string with the special character properly represented as a single byte, how would I do that? I can't seem to get my head around it. Thanks for any help you can give. ...

Best Practices of fault toleration and reliability for scheduled tasks or services

I have been working on many applications which run as windows service or scheduled tasks. Now, i want to make sure that these applications will be fault tolerant and reliable. For example; i have a service that runs every hour. if the service crashes while its operating or running, i d like the application to run again for the same peri...

SQL CLR and nullable datetime parameter

I'm trying to write a SQLCLR function that takes a DateTime2 as input and returns another DateTime2. Based on this post I altered the parameter to be the C# type DateTime giving me the level of precision I require. However because the input can be null I would like it to be DateTime?; the return type as well. using System; using Micros...

Which one is faster in processing and conversion int.Parse(), int.TryParse(), Convert.Int32()

Which one is faster, powerfull and reliable. And why ? int.Parse() int.TryParse() Convert.ToInt32() ...

How can you speed up the display of WinForms in C#?

How can you speed up the display of WinForms in C#? I am finding that forms are being painted quite slowly, even if the window is being 'reactivated' (ie. switched to) after having been already loaded. Other languages seem to be render forms a lot quicker. Is there a way to speed things up? Using C# in VS2005. ...

Replace {tag} with a value or completely remove {any-tag}

I've designed a multilingual web site and some values in database have a tag which will be replaced with it's language value, remove tags brackets ( in case {} ) or removed completely. There are two cases: Remove brackets: value {mm} >> value mm Remove completely: value {mm} >> value Also {tag} could be any length and can contain...

How do I convert the Cookies collection to a generic list? Easily

Anyone know how I can convert Request.Cookies into a List<HttpCookie>? The following didn't work as it throws an exception. List<HttpCookie> lstCookies = new List<HttpCookie>( Request.Cookies.Cast<HttpCookie>()); Exception: Unable to cast object of type 'System.String' to type 'System.Web.HttpCookie' ...

Read assembly Guid without locking the DLL in an appdomain in medium trust ASP.Net

Is it possible to read the GUID from the Assembly without actually loading it in the current App Domain. Normally Assembly.Load loads the DLL into the app domain. I just want to read the value. The description of the GUID is 'The following GUID is for the ID of the typelib ' if this project is exposed to COM <Assembly: Guid("DEDDE...

Location of WPF control in window?

Is there a way to get the current rendered location of a WPF control its window after all of the current RenderTransforms have been applied? I may just be blind, but I'm not seeing an obvious method. ...

onclosing form return value

Is there a way tha a form returns a value? something like ... sub main() Dim task as new TaskForm() dim res as integer=0 res = task.opendialog() end sub ...

WinForms and ShowDialog problem.

I have a borderless WinForms app. The main window creates other forms (simple dialogs where I can click yes or no) with ShowDialog(). Every created dialog is not visible in the taskbar, my app has only one taskbar entry that focuses my app (and if a dialog is open that one is focused). If I use ALT+TAB to cycle to all open windows I onl...

Simple example of a custom .net installer using the path of the installed app

I simply want to create a custom installer to run code after installation which requires the path of the installed application. I read about how to create a custom installer and Custom Actions, as well as what properties are available in the installer, but I don't quite get how to access those properties from inside the custom installer...

Entity Framework Custom Query Function

I have an Entity Framework 4.0 Entity Object called Revision w/ Nullable DateEffectiveFrom and DateEffectiveTo dates. I was wondering if there was a short-hand way of querying an object's RevisionHistory based on a particular QueryDate date instead of having to use the following query structure: var results = EntityObject.Revisions.Wher...

Intelligent serial port mocks with Moq

I have to write a lot of code that deals with serial ports. Usually there will be a device connected at the other end of the wire and I usually create my own mocks to simulate their behavior. I'm starting to look at Moq to help with my unit tests. It's pretty simple to use it when you need just a stub, but I want to know if it is possib...