.net

Read date using system locale and convert it to a new format

I need to deploy an ASP.NET application written in C# to multiple servers and cannot be sure what the regional settings are. How can I read the current date (DateTime.Today) into a DateTime variable using the server's locale and specify the format that I wish it to be in. This way giving me a consistently formatted date that I can then...

How to store delegates in a List

How can I store delegates (named, anonymous, lambda) in a generic list? Basically I am trying to build a delegate dictionary from where I can access a stored delegate using a key and execute it and return the value on demand. Is it possible to do in C# 4? Any idea to accomplish it? Note : Heterogeneous list is preferable where I can stor...

Mimicking Validation Behaviour without Validation

We have several data objects in our application that wind up bound to grids. We have them implementing the IDataErrorInfo interface, so that by adding error messages to the properties, we see the rowheader change style and the DataGridCells gain a red border. All well and good. We now have an additional requirement that rather than...

VB to C# rewriting question

I have a following method declaration in VB and need to translate it into C#: <DllImport("winspool.Drv", EntryPoint:="OpenPrinterW", _ SetLastError:=True, CharSet:=CharSet.Unicode, _ ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _ Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPt...

Internal vs. Private Access Modifiers

What is the difference between the internal and private access modifiers in C#? ...

need help with regular expressions

i have a string value that needs to be parsed with a regular expression...it may contain words, numbers and special chars in any order...what is the easiest expression for that... ...

DataServiceContext in WPF ViewModels

Hi, So I have a WPF application accessing entities through WCF Data Services. At the moment, I am accessing the proxy class that implements the DataServiceContext directly in my ViewModel. For example: this.context = new MyOwnDataServiceContext(new Uri("http://localhost/myowndataservice")); I then populate entities on the ViewModel f...

Why do I receive a "The .Net Framing mode being used is not supported by" error upon consuming WCF service?

I am trying to consume one of my WCF services using a net.tcp binding and I am receiving the following error: "The .Net Framing mode being used is not supported by 'net.tcp://myWCFService:8050/MyService'." The research I have done states this is caused by having an improper "transfermode" in the binding configuration, but in my service...

Apache log4net: How to set CC and BCC addresses to SmtpAppender from config file

I've been trying to add cc and bcc addresses to log4net's SmtpAppender but I'm getting no flair: <appender name="Mail" type="log4net.Appender.SmtpAppender"> <to value="[email protected]" /> <cc value="[email protected]" /> <bcc value="[email protected]" /> <from value="[email protected]" /> <subject ...

Loop issue on treeview

Hi, This maybe something really simple but I got a really strange issue where a loop i have written to populate menu items to a treeview is not displaying childnode id. The data it is pulling is in the following format on the sql. OptionID OptionText displayOrder parentOptionID optionDeleted 226 test me...

How do I make a XAML GridView display one of several images, depending on a DisplayMemberBinding?

Hi, I've got an Enum called "DoYouKnow", containing Yes, No and Unknown. I have a column in a GridView which currently displays "Yes", "No" or "Unknown" in each row, based on a DoYouKnow value I've attached it to using DisplayMemberBinding. Instead of displaying I would like to have this column display a tick, a cross or a question ma...

Handling Postback within a Webpart in Sharepoint

I am initializing a GridView, text box and a button via code to a Webpart in CreateChildControls() The above controls are declared as class variables but initialized only later. Next, I've given the handler for button click. The handler function is supposed to work as a search - perform some operations on the content entered in the tex...

Search for interface in all assemblies of bin

How can I scan all assemblies located in the bin directory and retrieve all types implementing an interface? ...

Iterate through saved values of Bitwise Enumeration

Hi, I'm using a Bitwise Enum as a Datasource for a repeater control in which each line has a checkbox. When the user saves data, enum values corresponding to the checked boxes are saved into a single database field. However, when the user comes to edit the data, obviously I need to pre-populate the repeater with the existing values. I...

layout Direction

how i cane change tablix layout Direction by custom code in SSRS 2008? ...

Create a file from a path, creating subdirectories if they not exists

Hi all! A newbie question perhaps... :-S In config of my app I've a path, for example "logs\updater\updater.log" Starting the app, I wanna create the file updater.log, creating all subfolders if they not exists. So, if tomorrow my user changes the path in config to "logs\mypathisbetter\updater.log", my app continues to work, writing lo...

.Net DrawString font reference changes after calling, is this a potential problem

Given the following code. Is there any potential for the first DrawString method to draw in Arial rather than Times New Roman? protected override void OnPaint(PaintEventArgs pe) { Font f = new Font("Times New Roman", this.TextSize); pe.Graphics.DrawString("Test 1", f, Brushes.Black, loc); f = new Font("Arial", this.TextSiz...

Async email from .Net

I'm trying to send an email async so it doesn't slow down my front end (Asp.Net MVC). SmtpClient smtp = new SmtpClient(_mailServer, 25); smtp.UseDefaultCredentials = true; MailMessage message = new MailMessage(); // ...etc smtp.SendA(message); // this works fine smtp.SendAsync(message, null); // if i change it to this, it doesn't wor...

exception when incoming message modified for a method with "not blank" Uri template

I get the following exception when i modify the incoming Message for a web service method with URItemplate which is not blank. System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.Servi...

representative diagram of .net framework Bace class library for better understanding of Types and Members Cooperations

is it possible to get any representative diagram(such as object diagram or class diagram) from .net types of a name space . the diagram could represent the relations and dependecies between the .net types and members. and we could understand better the structure of portion of a namespace. instead of looking at Msdn texts . for example i...