.net-2.0

log4Net EventlogAppender does not work for Asp.Net 2.0 WebSite?

I have configured log4Net EventLogAppender for Asp.Net 2.0. However it does not log anything. I have following in my Web.Config. <log4net> <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender"> <param name="LogName" value="Test Log" /> <param name="ApplicationName" value="Test-Web" /> <layout t...

Remove duplicates from generic list<T>

Hi, I have came with solution to remove duplicates from generic list<T> in .NET 2.0 as follows: List<CaseStudy> caseStudies = CaseStudyDAO.FindCaseStudiesByDate(DateTime.Now.Date, DateTime.Now.Date.AddDays(1)); caseStudies.RemoveAll( delegate(CaseStudy c) { return caseStudies.IndexOf(c) != caseStudies.FindIn...

how do I feed an rtf string to a richtextbox control

hello, I have a string of richtext characters/tokens that I would like to feed to a richtextbox in code. string rt = @" {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fnil\fprq2\fcharset0 Biondi;}}"+ @"{\colortbl ;\red255\green0\blue0;}"+ @"{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\par...

C# Pass Generics At Runtime

I have a method like the following: public IEnumerable<T> GetControls<T>() : where T : ControlBase { // removed. } I then created a class: public class HandleBase<TOwner> : ControlBase : TOwner { // Removed } I'd like to be able to call GetControls<HandleBase<this.GetType()>>; where it would use the type of THIS class to pa...

Custom property value problem.

My projects involve a number of usercontrols that are actually full blown applications. These usercontrols are designed to be placed onto tab controls. The apps area used by 2 different office locations, so one of the common items found on the controls is a combobox that lists the ID's for each of the 2 offices ('P' and 'G'). I wanted t...

Fastest way to check a List<T> for a date

I have a list of dates that a machine has worked on, but it doesn't include a date that machine was down. I need to create a list of days worked and not worked. I am not sure of the best way to do this. I have started by incrementing through all the days of a range and checking to see if the date is in the list by iterating through the e...

C# app fails to load Matlab DLL when running from a shared drive?

I have a C# .NET 2.0 program that calls a Matlab .dll file that I created using Matlab Builder for .NET. This Matlab .dll file is a wrapper for a m file function that I need to call from my C# program. Everything works fine when I run this app from my local drive. However once I copy the app to a shared drive the Matlab dll fails when...

Passing List (Of ChildClass) as parameter to method expecting List (Of ParentClass)?

Hi, I have implemented inheritance for two parent classes called Table and Field. Each parent class has several child classes. In the Table parent class, I created a method that expects parameter List(Of Field). I get an error when trying to pass in parameter List(Of ChildField) to the method that expects a parameter of List(Of Field). ...

C# myths about best practices?

My colleague keeps telling me of the things listed in comments. I am confused. Can somebody please demystify these things for me? class Bar { private int _a; public int A { get { return _a; } set { _a = value; } } private Foo _objfoo; public Foo OFoo { get { return _objfoo; } ...

how do I create invisible regions on a user control

I would like to make my user control have invisible areas like the areas that surround a circle or an irregular shape. I have seen this done with a system.windows.form but not with a system.windows.form.usercontrol. How is this done? .net 2.0,c#,winform ...

How do I get NHibernate to work with .NET Framework 2.0?

I can not make NHibernate 2.1 work in machines without framework 3.X (basically, windows 2000 SP4, although it happens with XP too). NHibernate doc do not mention this. Maybe you can help? I NEED to make NHibernate 2.1 work in Windows 2000 PCs, do you think this can be done? PD: DataBase is SQL 2000/2005. Error is: NHibernate.Mapping...

If an assembly is in the GAC, do all assemblies that it calls have to be in the GAC too?

The question says it all. ...

Using C# assemblies from VB6 code. Some issues.

I have a C# assembly, which is regasmed, but is not in the GAC. In my VB6 code, I added a reference to the generated type library (the .tlb file). Then I instantiate the C# lib in my VB6 code. If I run it from the VB6 IDE, it does not work. The Set in the code below: Dim obj as MyCSharpNamespace.MyCSharpObject Set obj = New MyC...

Get label height for fixed width

Is there any way I can get the height of a label, if it hypothetically had a certain width? I've been trying with control.GetPreferredSize(size) like so: Dim wantedWidth as Integer = 100 dim ctrlSize as Size = label.GetPreferredSize(new Size(wantedWidth, 0)) because I thought that setting height = 0, would indicate a free height, but ...

How to get DataTable to serialize better?

I have the following code that serializes a DataTable to XML. StringWriter sw = new StringWriter(); myDataTable.WriteXml(sw); And this works, however, the serialized XML looks like this: <NameOfTable> <NameOfTable> <ID>1</ID> <Name>Jack</Name> </NameOfTable> <NameOfTable> <ID>2</ID> <Name>F...

Can .NET 4.0 code interoperate with .NET 2.0 code?

Are there compatibility barriers with a .NET 4.0 assembly calling code in a .NET 2.0 assembly? And vice versa? More specifically, I'm investigating an upgrade to Visual Studio 2010 when using a third party application based on .NET 2.0. The application is extensible by hooks that reference my custom code. And vice versa, my code will...

What happens when .NET 4.0 references a .NET 2.0 assembly?

What exactly does the .NET 4.0 runtime do if a .NET 4.0 executable contains a reference to a .NET 2.0 assembly? Is the .NET 2.0 assembly run with the .NET 4.0 runtime (in other words, .NET 4.0 must be 100% API-compatible to .NET 2.0) or does the process somehow host the .NET 2.0 runtime and some magic happens to make the .NET 2.0 types ...

What version of the .NET framework ahould I target?

I'm a desktop C# developer (that is not ASP) and am wondering about version targeting for small personal projects. These are, of course, trying to reach as wide an audience as possible, and so I've been targeting .NET 3.0 (which is the latest version on a Windows Vista system without any service packs) and 2.0 (which is simply the most ...

What happens in a .Net 4 app when referencing .net 2 assemblies?

I have an application I want to upgrade to .NET 4, but I have a couple 3rd party assemblies that reference the .NET 2 BCL. I seem to remember reading something that says they should play nice, but I can't find any documentation on the subject. ( I think my question posed to Google is just too broad, with not enough .Net 4 material out ...

Converting between 2.0 3.5; Xp to WS 2003

It works on my desktop but when I transfer to the server: Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the...