.net-2.0

How to use Reflection to Invoke an Overloaded Method in .NET

Is there a way to Invoke an overloaded method using reflection in .NET (2.0). I have an application that dynamically instantiates classes that have been derived from a common base class. For compatibility purposes, this base class contains 2 methods of the same name, one with parameters, and one without. I need to call the parameterle...

How to create a simple proxy in C#?

I have downloaded Privoxy few weeks ago and for the fun I was curious to know how a simple version of it can be done. I understand that I need to configure the browser (client) to send request to the proxy. The proxy send the request to the web (let say it's a http proxy). The proxy will receive the answer... but how can the proxy send ...

What is the best way to sort an IList<T> in .Net 2.0?

I have an IList<T> that I need to sort, and I would rather not copy the list if possible. I've noticed that ArrayList has an Adapter static method that wraps the passed list without copying it, but this takes an IList and I have an IList<T>. Is it safe to cast from a System.Collections.Generic.IList<T> to a System.Collections.IList and...

UAC need for console application

I have a console application that require to use some code that need administrator level. I have read that I need to add a Manifest file myprogram.exe.manifest that look like that : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:sc...

Is there a way to know, programatically, how much space an object is taking in memory? (.Net 2.0)

I would like to be able to know, in run-time in my code, how much memory a certain object is taking (a Dataset in this case, but i'm looking for a "general" solution). Is this possible through reflection? This is for .Net 2.0. Thanks! ...

Best way to reverse a string in C# 2.0

I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this: public string Reverse(string text) { char[] cArray = text.ToCharArray(); string reverse = String.Empty; for (int i = cArray.Length - 1; i > -1; i--) { reverse += cArray[i]; } return reverse; } Per...

Error "MSB3176: Specified minimum required version is greater than the current publish version"

I've got build server running CruiseControl.NET and recently it started throwing this error on one of my projects (.NET 2.0, C#): MSB3176: Specified minimum required version is greater than the current publish version. Please specify a version less than or equal to the current publish version. in Microsoft.Common.targets(2238, 9) I...

How can I sort a DataSet before doing a DataBind?

I have data coming from the database in the form of a DataSet. I then set it as the DataSource of a grid control before doing a DataBind(). I want to sort the DataSet/DataTable on one column. The column is to complex to sort in the database but I was hoping I could sort it like I would sort a generic list i.e. using a deligate. Is this ...

ASP.NET - Invalid postback or callback argument. Event validation is enabled using '<pages enableEventValidation="true"/>'...

I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side. How do we fix this? Error details below: Server Error in '/XXX' Application. -------------------------------------------------------------------------------- Invalid postback or callba...

Membership and Role Providers in ASP.NET 2.0 with non SQL Server provider?

I have quickly read (and will read with more care soon) the article of Scott Allen concerning the possibility to use an other provider of the default SQL Express or SQL Server database to use the "Membership and Role Providers" for ASP.NET. We will soon need to open a part of our project to some client via the web and I thought about us...

How can I manipulate the DOM from a string of HTML in C#?

For the moment the best way that I have found to be able to manipulate DOM from a string that contain HTML is: WebBrowser webControl = new WebBrowser(); webControl.DocumentText = html; HtmlDocument doc = webControl.Document; There are two problems: Requires the WebBrowser object! This can't be used with multiple threads; I need som...

How to configure security when calling WCF Service from .Net 2.0 Client

I have a WCF service up and running and am able to communicate between the service and a .Net 2.0 Client using basicHttpBinding. I now need to lock down the WCF service so that it can only be called by authenticated clients. I have control over the clients that will be calling my service. The clients are part of a product that will b...

Overriding Controls property of a panel in C#

I have to override Add method of "Controls" property of myControl that is extended from a Panel control of windows. For that i extended ControlCollection class into MyControlCollection where i overriden its Add method. Now i declared a Controls property of MyControlCollection type to hide panel's Controls property. When i am accessing th...

ASP.NET 2.0 Application on IIS 5 Resulting in Error (aspnet_wp.exe (PID: XXXX) stopped unexpectedly.)

After hosting an ASP.NET 2.0 web application on a windows 2000 server(IIS 5). I was unable to browse the web site. The following error message was displayed on the browser and three Event Log entries were added... Error Message on Browser Server Application Unavailable The web application you are attempting to access on this web se...

Is basicHttpBinding the only option for connecting a .Net 2.0 client to a WCF Service?

This is a follow on to this question. I am trying to avoid using the x509 certificate method as that makes my client installs more complex. If basicHttpBinding is not the only option, where are some samples of other binding methods. My clients are on .Net 2.0, I don't have access to System.ServiceModel namespace as that didn't come ...

Is there a Windows Forms native way to flash a form's title bar?

Is there a correct way in Windows Forms to flash a titlebar without having to drop to P/Invoking FlashWindow? I'm using .NET 2.0 for compatibility and size reasons, so maybe I just missed the method because it's in newer versions of the .NET framework. ...

How to unit test if my object is really serializable?

I am using C# 2.0 with Nunit Test. I have some object that needs to be serialized. These objects are quite complex (inheritance at different levels and contains a lot of objects, events and delegates). How can I create a Unit Test to be sure that my object is safely serializable? ...

Will the GAC fix an ASP.NET/IIS6.0 System.OutOfMemoryException?

I have many instances of an application installed on an IIS 6.0, Windows Server 2003 box under the same application pool. They share many of the same assemblies and can not be joined in to a single application. I recently added a new instance of the application and obtained a System.OutOfMemoryException when I tried to load the ASP.NET...

How to get xpath from an XmlNode instance. C#

Could someone supply some code that would get the xpath of a System.Xml.XmlNode instance? Thanks! ...

XmlReader - Self-closing element does not fire a EndElement event?

I am using XmlReader in .NET to parse an XML file using a loop: while (xml.Read()) { switch xml.NodeType { case XmlNodeType.Element: //Do something case XmlNodeType.Text: //Do something case XmlNodeType.EndElement: //Do something } } I was wondering if it was normal that the following XML code ...