.net

Suppress tlbimp warnings in visual studio

In a visual studio C# project, it is possible to add references to COM libraries. Visual Studio will then use tlbimp.exe to generate the interop assembly when building the project. The reference looks like this in the .csproj file: <ItemGroup> <COMReference Include="TDAPIOLELib"> <Guid>{F645BD06-E1B4-4E6A-82FB-E97D027FD456}<...

Is it possible to "cast" an object to a more specialized object?

The problem is that I need a little extra functionality to an object of a class that I can’t change (I’m trying to add data binding support). The best solution that I can think of is to just write a derived class with this functionality. So I can use objects of this class instate. So now the problem is, how do I initialize the objects o...

How to handle exception when Directory.GetFiles() throws an exception when it finds a file name it does not "like"?

On a Vista machine with the valid path C:\Users\David, calling Directory.GetFiles(@"C:\Users\David") throws the following ArgumentException when run as the David user, who can view the contents of the directory just fine in Windows Explorer: System.ArgumentException message: Illegal characters in path. Argument: "" Stack trace: at Sy...

Can I still target .NET Framework 2.0 in VisualStudio 2010?

Before upgrading to VisualStudio 2010, I want to make sure I can still target version 2.0 of the framework. I couldn't find a statement about this from MS. Does anyone know? ...

Runtime-editable resource file

I've created a custom XML based Error Message framework for .NET. The XML is key-value based and this gets cached. The cache is invalidated when the user edits the XML file. When an error occurs, a call like 'GetError(Password.Toolong,"Default value")' happens which reads the cache. What I want to know is whether a similar framework exi...

template engine implementation

I am currently building this small template engine. It takes a string containing the template in parameter, and a dictionary of "tags,values" to fill in the template. In the engine, I have no idea of the tags that will be in the template and the ones that won't. I am currently iterating (foreach) on the dictionnary, parsing my string t...

.NET + TeamCity: Private Accessors Are Not Compiled

I'm running Team City Pro (v4.0.2 build 8222) for a VS2008 sln file. Right now I'm facing a problem where autogenerated code for private accessors in a test project not being generated and causes compile errors by not being able to find those (autogenerated) classes. The build runner is the default sln2008. Any configuration need to b...

sending inline MHTML

I was wondering if it is possible through the .NET 2.0 MailMessage object to send an inline MHTML file that is created on the fly. By inline I mean: It should be sent in a way that the user can see it, once he opens the email, without having to open/download the attachment. ...

Using XML to create a Windows Form

I am working on a Windows Desktop application that will store a number of documents, there will initially be 4 different types of documents, each as a windows form, each with some common details (document ID, client ID etc), and then different fields based on the document type. I plan on using XML to specify the fields for each form. So...

Declaring arrays with data is easy in C# - how can I do it in VB?

Possible Duplicate: Anonymous class initialization in VB.Net Trying to convert examples like this from C# to VB.Net leaved me scratching my already bald head...: public ActionResult GridData(string sidx, string sord, int page, int rows) { var jsonData = new { total = 1, // we'll implement later page = page, recor...

.IsNotEqualTo doesn't compare Nulls

This query will only return all records where Active=true and Exempt=false. It should be returning any records also where Active=true and Exempt IS NULL. I guess the .IsNotEqualTo doesn't compare to any records with a null value? Is there a way around this without setting a default? UserCollection ActiveUsersNotExempt = new UserColle...

differences between nhibernate 1.2 and 2.0

I can't seem to find any information on what the actual differences are between nhibernate 1.2 and 2.0. I have found information regarding what the potential issues are with upgrading, but nothing on what new features are included, or anything about performance differences. If there are significant differences between the two that coul...

For the View interface in MVP design, how abstract should the IView members be?

I am still learning MVP. I have a IView and a presenter. I have a custom List control that I have written for this application. I'd like to add some items to it, one at a time. Should I expose IView.AddItem(Item) or should I expose a IView.MyCustomList property? Is this a matter of style, or is there a correct answer to this one? ...

Generic methods in non-generic types

When you have a method like: public static T DoSomething<T> ( params T [ ] input ) C# lets you to call it without specifying the T, like: DoClass.DoSomething ( "1", "2", "3" ); Does the compiler figure out T by what's passed to it? Is this a good convention (to leave out T in this case)? ...

Refresh WPF UserControl via XAML

Hello! I'm using WPF within Visual Studio 2008. I have a simple WPF UserControl with the following code: public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); Composite = new Composite(); } protected override void OnRender(DrawingContext drawingContext) { ...

keeping sql database schemas synced between developers

We are a small development team (about 5) doing a dev project from different locations. We use SVN as out code repo. The biggest issue that we are having now is that our DB schema is totally out of sync between all of us. I have though of the following options: 1. Work off a "central" DB. This is a bad idea and will most likely not happ...

Confusion with services and certificates with an anonymous client

I've setup a WCF service that is using transport security over netTcpBinding. The certificate used for the service's security is signed by a CA we created for development. Can someone explain how it works that my anonymous client can connect and communicate with the service without having that same CA installed locally? I'm rather new...

Interface constraint for IComparable

When I want to constraint the type T to be comparable, should I use: where T : IComparable or where T : IComparable<T> I can't get my head around if #2 makes sense. Anyone can explain what the difference would be? ...

Generic .Net Producer/Consumer

I'm toying with the idea of implementing a generic Producer/Consumer pair + processing queue in C# for fun. The idea is you can just create objects that implement appropriate IProducer and IConsumer interfaces (default implementations supplied), which will consist mainly of delegates, pass them to a QueueProcessor class instance, tell i...

Switching data access strategy far into a project?

In a project we have implemented the data access layer (DAL) with a visual designer that auto-generates a lot of code (in our case: strong-typed DataSets and DataSetTableAdapters in .NET). However, using source control I find it troublesome to edit and add new things to the DAL. We have started coding new data access by manually writi...