.net

What exactly is the point of Expression Trees?

Ok, I just don't get it. I've read about as much as I can on the subject without knowing what it's all about: Why use Expression Trees? What's a real-world example of when and how I'd use them? What overall benefit(s) are there in using them? ...

Connecting to SQL Server Database C#-WinForms

I have a desktop app that I'm making and I want users to have to login before the program can be used to its fullest extent. I have created a database on www.winhost.com (where my site's hosted), but now I don't know what to do. I've been on google and msdn and I would like to know how to programmatically add new rows/colums to this new ...

DRY LINQ Predicate Filters for Multiple Tables

Suppose I have two tables, TableA and TableB. Each record in A has one or more related records in B. Say I want a reusable filter using predicates. I might do something like this (Linq-to-SQL by the way): private Expression<Func<ARecord, bool>> FilterPredicate() { return x => x.Name == "Test"; } private IQueryable<ARecord> GetRecor...

Difference between SafeProcessHandle and IntPtr for an API call

While working with WinAPI, I decided to implement a call to GetProcessAfinityMask in my C# application. However, I've seen two different signatures for this function. One of them uses SafeProcessHandle for the handle: [DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)] public static extern bool GetProcessAffinityMask(...

Connect to IBM DB2 with .Net using only .dll reference

I would like to connect to a DB2 database, specifically an iSeries version, using .Net and C# by referencing a .dll and NOT installing any software on the server. Currently we use the IBM.Data.DB2.iSeries.dll, which is installed as part of iSeries access for windows. I don't want to have to install all of that. But apparently I don't hav...

How can I restrict the file type in the file browse menu of an AsyncFileUpload in the ASP.NET AJAX Control Toolkit

I would like to restrict what they see in the file upload dialog, which is set to "All Files" by default. I understand how to validate that they only uploaded a certain file type, that is not the question here. I would just like to know how to default the file type in the file selection dialog. Is there any way to change this to "PNG on...

how to make an instance of an unknown class to use as a parameter for a method invocation using reflection?

ok heres the deal, im grabbing all the methods from a webservice and providing a way to test them. so far we are displaying their methods and some of the methods only deal with ints and strings. that part is taken care of. (we can invoke methods correctly and parse results) the problem is that some of these parameters needed for the met...

In a Microsoft Visual Studio solution is there a way to set up conditional start-up projects based on configuration?

Background: I have a set-up where I have two .csproj in a solution that use different reference .dlls. Both projects are directed toward the same source code. To avoid any segments of code where methods have changed, I created a custom configuration (in addition to the default Debug and Release configurations) and swapped between code ...

Linq to RSS feed?

What I'm trying to do is take an RSS feel URL and, using LINQ, be able to write a query that will let me sort the subject line of the feed or sort the author line of the feed or even do 'WHERE' clauses that will let me filter by keywords for example. I know I can read the RSS feed, parse each element, put them into some sort of class ob...

Calling web service through .NET class library from excel

I have an Excel 2003 "application" that at this time the users refuse to part with. I am updating it to use a .NET class library for some of the calculation, to try to minimize the risk of using excel. This .NET Class Library calls a .NET WCF Web Service. When trying to call a function that utilizes the web service, the class library th...

Printing RTF file that is an Embedded Resource in the assembly

I have an RTF File as an embdded resource in the assembly. What is the easiest way to Print that file ? ...

Interview Question

I was recently asked a weird question in an interview here it is; Private Function sorttable (ByVal dt As DataTable, ByVal sorttype$, ByVal sort_direction$) As DataTable Dim dv As DataView Dim dt2 As DataTable dt2 = dt.Clone dt2.Merge(dt) dv = dt2.DefaultView dv.Sort = so...

ConfigurationManager - How to use connection strings with .NET 3.5?

Hi All, I see a very good post here about what I am wanting to do, http://stackoverflow.com/questions/1831291/net-3-5-to-read-connectionstring-from-app-config It says to use the ConfigurationManager class. I cannot reference the ConfigurationManager class. If I look at the system.dll that I am using (which is v2.0.50727) there is no ...

CLR: System.InvalidOperationException: The context connection is already in use.

I keep getting this error when trying to perform a delete in the middle of my DataReader: System.InvalidOperationException: The context connection is already in use. I get all the rows that need to be deleted and then iterate through the data reader as there are a lot of rows returned. SqlConnection conn = new SqlConnection("context c...

Generic Classes (T) - Specifying from a Range of Types VB.Net

This is the code I'm trying to develop: Public Structure Statistic(Of t) Dim maxStat As t Dim curStat As t Public Sub New(ByVal pValue As t) maxStat = pValue curStat = pValue End Sub Public Property Level() As t Get Return curStat ...

How can I specify a large number of files for an NCOVER merge operation?

I have a large acceptance test suite that runs the source application many thousands of times, creating an NCOVER report for each run. After each test, it merges the generated code coverage report into a large "master" coverage report for the whole application. My worry here is that I'm running into a Shlemiel the Painter problem, as th...

Writing Exif GPS meta data without re-inventing the wheel?

I am working on with .net 2.0 compact framework on a pocket pc device and the camera doesn't automatically tag the image with GPS exif data (unlike iPhone). I have looked around for already existing open source libraries that i can use in order to write GPS Exif data to a JPEG image but i haven't come across much. I did find a few examp...

Existing Fine-grained access control library/framework?

Let's say I have these kind of requirements: User A in Role AA needs to be able to update all entities of type A1. User B in Role BB needs to be able to update only the entities of type A1 with the primary identifier of "2", which I'll call A1("2"), and can not update any other entities of type A1, but can add or delete any number of c...

IPC: WM_COPYDATA + serialization/deserialization

Hello, I am currently working on 2 .NET apps which must communicate with each other. Simple Windows Messaging was chosen and this works nicely at the moment. The data that is sent in the messages is a simple string, but now I have created a message class which contains a command (enum) and a data (string) member, and later possible othe...

In .NET development, what is the breakdown of WinForms/desktop developers versus ASP.NET developers?

What is the proportion of .NET developers who do WinForms/desktop development vs ASP.NET development? Is there very much overlap? Are they very different skill-sets? ...