.net

Format a date in XML via XSLT

When I use the XML serializer to serialize a DateTime, it is written in the following format: 2007-11-14T12:01:00 When passing this through an XSLT stylesheet to output HTML, how can I format this? In most cases I just need the date, and when I need the time I of course don't want the "funny T" in there. ...

Creating a derived object from an existing base object in .net

Dumb question. Lets say I have a bunch of person objects with their fields all filled in with data and I have an employee type that derives from the person class and has extra fields related to being an employee. How do I get a employee object for a particular existing person object? i.e. How do I pass in the person object to the empl...

C# How do I convert a decimal to an int?

How do I convert a decimal to an int? Ta ...

How do I use ASP.NET MVC RC with Visual Studio Web Developer 2008 SP1?

When I go to File > New Website there isn't a template for MVC. I googled "how to use MVC with vwd?" and these links came up http://geekswithblogs.net/jwhitehorn/archive/2007/12/10/117569.aspx http://jerusahat.wordpress.com/2007/12/12/aspnet-mvc-template-for-visual-web-developer-2008-express/ http://www.lazycoder.com/weblog/2007/12/10/...

Schedule delegate calls

I want a way to be able to schedule callbacks, I want to be able register lots of different callbacks at various times to a "Scheduler"-object. Something like this. public class Foo { public void Bar() { Scheduler s = new Scheduler(); s.Schedule(() => Debug.WriteLine("Hello in an hour!"), DateTime.Now.AddHours(1)...

How do you map a component that is also a primary key in NHibernate hbm xml (or in a fluent-nhibernate class map)?

I'm trying to figure out how to map a component as a primary key in nhibernate and if possible in fluent nhibernate as well. The component in question is a unique set of 3d coordinates, here's the object: public class SpaceLocation { public virtual SpaceCoordinate Coordinates { get; set; } public virtual SpaceObject AtLocation...

[C#] Deallocate resources on process termination

Hi all, I'm sorry for the trivial question. How I can deallocate resources when the process gets killed by, for example, the Task Manager? Is there a way to call a function before the process gets closed? Thanks in advance Thanks to all for your answers. I think I will implement a watchdog process as suggested. ...

How to send value with onclick event?

I have the following button <asp:ImageButton ID="button1" runat="server" ImageUrl="~/image.jpg" CommandName = "id" CommandArgument = "1" onclick="button1_Click" /> and in code behind protected void button1_Click(object sender, ImageClickEventArgs e) { Response.Write(e.commandName); } this does not work!!, So ...

Configuration strategy for multiple modules

Are there different strategies for configuration when you have multiple modules in the same application? I have an application that uses a CommonLib library which is maintained by some other in-house group, then we are using some 3rd party tools as well that need to be configured. Everything seems to depend on configuration settings bein...

NUnit crashes when cc3270mt.dll is loaded

I have a problem where NUnit Assert.IsTrue crashes with an "access denied" (0xc0000005) access violation. Since managed applications are not supposed to cause such errors, I started looking at any unmanaged code loaded by the NUnit tests. And sure enough, after a process of elimination the simplest way to reproduce the problem turned out...

Do any OR Mappers provide Asynchronous Methods?

Do any .Net O/R (object/Relational) Mappers provide Asynchronous methods out of the box? I don't want to have to write the boiler plate for the asynchronous method if possible I have rolled my own DAL with Asynchronous methods using the CCR framework. The CCR basically demands that I don't block any of it's threads waiting for IO respo...

Cool PostSharp aspects

I'm looking for interesting PostSharp aspects - anything that you found useful and wouldn't mind sharing. ...

How do I best obfuscate my C# product license verification code?

How do I best obfuscate my C#.net app Product Key verification code? Is it enough to place it in a "INTERNAL SEALED CLASS CLASSNAME { };" or do I need to do more? Thanks! ...

What is the best way to automate the encryption of my c#.net application configuration file without interfering with the normal operations of the application?

What is the best way to automate the encryption of my c#.net application configuration file without interfering with the normal operations of the application? ...

How do I round a decimal to a specific fraction in C#?

In C# rounding a number is easy: Math.Round(1.23456, 4); // returns 1.2346 However, I want to round a number such that the fractional part of the number rounds to the closest fractional part of a predefined fraction (e.g. 1/8th) and I'm trying to find out if the .NET library already has this built in. So, for example, if I want to ro...

C# Index Search Like AVA Find

You may be known about ava find, it first indexe the entire harddisk, then u can search a file very fast, can find a file very fast (within a second even in a low end cpu). If do the same using sql server, First index the file names in an sql server db , then search, it will take a long time. How can we create one like avafind in c# or d...

Can I use the command line, or run a batch file from managed code? (.NET)

Just like the subject states. I want to be able to run iisreset, batch files, etc. from the a console application. Can I/How do I do it? Thanks, Kyle ...

How to open a web page from my application?

I want to make my WPF application open the default browser and go to a certain web page. How do I do that? ...

LINQ to SQL: Self-referencing entity - ParentID/ChildID association

I have a Task entity in my Linq to SQL dbml. It's self referencing with ID and ParentID columns. I have an Association that associates the two IDs together. it seems like everything works fine in the intellisense. It'll let me type out Task.Parent.ID and even Task.Parent.Parent.ID, etc. However, it gives me the ol' "Object referen...

Bind to a method in WPF?

How do you bind to an objects method in this scenario in WPF? public class RootObject { public string Name { get; } public ObservableCollection<ChildObject> GetChildren() {...} } public class ChildObject { public string Name { get; } } XAML: <TreeView ItemsSource="some list of RootObjects"> <TreeView.Resources> ...