.net

Dynamically changing the title of a SiteMapNode

We have a website that uses a bog-standard default sitemap with security trimming as follows: <siteMap defaultProvider="default" enabled="true"> <providers> <add siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true" name="default" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToke...

GUI as a finite state machine

To implement application's GUI I would like to have all the logic to go from one form to another centralized. This GUI manager will behave as a finite state machine. Although I think I have seen this kind of implementation somewhere, I can't find a design pattern that matches with this kind of solution. A form will look like this: publ...

How to set root node name when XmlSerializing an array?

I have an array of objects which I want to serialize as XML. These objects are annotated to set XML node names but I was wondering how to set the name of the XML root node. The code looks like this: // create list of items List<ListItem> list = new List<ListItem>(); list.Add(new ListItem("A1", new Location(1, 2))); list.Add(new ListIte...

How to generate a winform application with delphi and .Net respectively?

I need to make a choice between the two languages,both of which are new to me. I want to choose the simpler one. Also,please mention about the setups needed to run the programme. ...

Is "Jint - Javascript Interpreter for .NET" reliable?

I've seen jint in Codeplex. It looks very interesting. Have you used it? Is 0.8.4 stable and usable in your opinion? (production quality?) ...

JSON in non-Javascript applications

I'm looking to persist and retrieve a large amount of key-value pair(s) type data over the wire. Is it appropriate for me to use JSON for this purpose against XML? Is JSON used in non-Javascript applications? Are there advantages using JSON for this purpose over good old XML? ...

How to process SqlCommand result (rows) as they come?

How to process SqlCommand result (rows) as they come? In other words, I am trying to do exactly what Sql Management Studio 2005 does when executing a query with many thousand rows. To me, it looks like as soon as Sql has found the first result, it notify the UI and display the rows as they come... I suppose that it can be done asynchron...

Maximum Timer interval

The maximum interval of timer is 2,147,483,647. it's about 25 days. But in my requirements I need that the timer will wait 30 days. How can I resolve it? Please help. ...

How to get MethodInfo of a generic method on a non generic .NET type?

Dear ladies and sirs. I have this little problem, that I cannot figure out which arguments to pass to Type.GetMethod in order to get back the MethodInfo of a generic method on a non generic type. Specifically, I have this type definition: public static class A { public static B F<T>(bool dummy) { } public static B F<T>(IEnumera...

Find all variables that point to the same memory in Visual Studio

In Visual Studio 2008, is there a way of finding all the variables that point to the same object as another variable? So in the example below I would want to find out that ref1 and ref2 both point to the same object as original. var original = new List<string>() { "Some Data" }; var ref1 = original; var ref2 = ref1; Essentially I wan...

How to realize a multi channel audio pre-mixer in .net

I'd like to use C# to implement an application that can play multiple audio streams at the same time. Peanuts - now the interesting part: assuming every stream is single channel (mono) I want to adjust the volume for every speaker (5.1 or even 7.1) for every stream separately. I can use the windows mixer to do this, but the problem is, t...

How do I make an object's variable name editable in the designer?

I've written a custom control which mimics the appearance of a table header. The columns it draws are given by a collection of objects with a Text string property and a Width int property. Both have Browsable, Category, DefaultValue and Description attributes added. In the designer, the collection is editable and the user can set the ...

How to debug "Safe handle has been closed" error

Code which I have inherited keeps crashing out rather powerfully with the following error (not changed at all): System.ObjectDisposedException: Safe handle has been closed at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(SafeFileHandle hFile, NativeOverlapped* lpOverlapped, Int32& lpNumberOfBytesTransferred, Boolean bWait) ...

Why is there no Dictionary.TrimExcess()?

In .NET, there is a constructor for Dictionary<TKey, TValue> that takes one parameter, int capacity. This is the same as with many other collections such as List<T>, Queue<T>, and Stack<T>; furthermore, according to the MSDN documentation: The capacity of a Dictionary is the number of elements that can be added to the Dictionary befo...

Serializing a .NET EventLogEntry instance to XML

When using the Event Viewer in Windows 7, there is a separate 'XML View' of an event that can be accessed from the Event Properties dialog. This XML refers to the http://schemas.microsoft.com/win/2004/08/events/event namespace. When I subscribe to Windows Events using the .NET framework classes in the System.Diagnosticsnamespace and ret...

Handling .NET object-relational impedence mismatch in a special case

I would like to abstract out pure SQL calls in my code as much as possible. I'd like to research nHibernate or LINQ-to-SQL, but I'm wondering how the scenario I'm dealing with affects my decisions. The database I'm reading from is a legacy database, and I can't change its schema or anything - I'm stuck with what's there. The bigger prob...

Saving Inserted and Deleted tables into variables for use in .NET code (via sp_oamethod) [SQL Server 2000]

I am trying to create a SQL Trigger in SQL Server that will somehow serialize the Inserted and Deleted tables for use in .NET code (via sp_oamethod). I would like this to be generic enough to use for any table. My first attempt involved using "for xml" to serialize it into XML, and pass it to .NET code. However, I have been unable to ...

itext positioning text absolutely

In itext I have a chunk/phrase/paragraph (I dont mind which) and I want to position some where else on the page e.g. at 300 x 200. How would I do this? ...

JsonConvert.DeserializeObject and "d" wrapper in WCF

By default WCF service wrap JSON response in "d" wrapper and there I found a problem with parsing it. If I parse with JsonConvert.DeserializeObject(response) where response is "{\"d\":\"{\"a0b70d2f-7fe4-4aa2-b600-066201eab82d\":\"Thelma\",\"d56d4d4f-6029-40df-a23b-de27617a1e43\":\"Louise\"}\"}" I gor an Error: After parsing a value ...

Best way to generate a hash signature (HMAC) for XMLSerialized objects in .NET?

I need to generate a HMAC for objects that I am serializing using the XMLSerializer found in the .NET framework. Each object will contain a property called "HMAC" that will contain a hash of the object's values itself but excluding the "HMAC" field. I've found this question that mentions a built-in solution within the CLR but doesn't ela...