.net

Can I pass constructor parameters to Unity's Resolve() method?

I am using Microsoft's Unity for dependency injection and I want to do something like this: IDataContext context = _unityContainer.Resolve<IDataContext>(); var repositoryA = _unityContainer.Resolve<IRepositoryA>(context); //Same instance of context var repositoryB = _unityContainer.Resolve<IRepositoryB>(context); //Same instance...

Getting handle of control with minimum TabIndex

I need to get a handle to whichever control has the minimum TabIndex. I've tried using GetNextDlgTabItem() and passing a 0 pointer for the second argument, but the returned handle isn't always the first one in the screen's tab order. Thoughts? ...

Linq to SQL - Return top n rows

I want to return the TOP 100 records using Linq. ...

When do you use extension methods, ext. methods vs. inheritance?

We started using C# (.NET 3.0) and I wonder how you guys are using extension methods? When do you use them? Also, I would appreciate if you also list all dark prerequisites for using them. ...

Injecting a CLR host into a running process - possible?

This way lies madness, I know. I have an executable (the source code to which I do not have access) that I would like to extend via .NET. It's a native executable, so I would need to inject a CLR host in order to do this. My basic idea is to provide scripting-like functionality via a .NET language (C#, for example) and provide hooks in ...

PGP Library for C#?

I'm looking for an easy to use PGP Library for C#. Does anyone know of any, preferably for free? ...

WCF right for all cases?

I'm building an application that will distribute its processing over a farm. In my basic design I have two services: A "controller" which watches for new work, queues it up, and manages the results. A "worker" which binds to a particular controller. The worker will check out work from its controller, and push the results back. In the...

Why can't I share types with an assembly loaded dynamically at runtime into the same load context?

I have a problem that is not uncommon when building a plug-in architecture. Assembly A is the core code -- the framework. Assembly B is a plugin to that code, expected to load dynamically at runtime and make code available for Assembly A to use. In Visual Studio, Project B (which generates Assembly B) has a reference to Project A (wh...

Is there a Java 1.5 equivalent to the Predicate<T> methods in .Net?

Specifically, I'm looking for similarly clean notation to the Collection<T>.TrueForAll / Exists, etc. It feels smelly to have to write a foreach loop to inspect the return of a method on each object, so I'm hoping there's a better Java idiom for it. ...

How do I decipher the Select method docs on MSDN?

I'm struggling to get my head around LINQ and have come to the conclusion that searching through dozens of examples until I find one that is near to my own application in C# is not teaching me how to fish. So back to the docs where I immediately hit a brick wall. Can someone please help me decipher the Enumerable.Select method as prese...

C# and Interfaces - Explicit vs. Implicit

In C#, if a class has all the correct methods/signatures for an Interface, but doesn't explicitly implement it like: class foo : IDoo {} Can the class still be cast as that interface? ...

XML validation with Schematron/XSD in C#

I've been looking around for at a way to make some more advanced business rule validation of XML documents. So far Schematron seems to be able to do, what I need. I've been looking around, and the few libraries I've found was very old and seemingly not supported any longer. Was Schematron only "hot" in 2002? Are there any libraries th...

Most efficient internal database for a media player

I'm currently learning C# and .NET (coming from a UNIX background), and have just started writing a media player. I was hoping for some suggestions on the best way to store the internal database of songs. SQL? Some kind of text file? I don't really have any experience in this area so all points will be really appreciated. Cheers! ...

ASP.NET Page Authorization... How do you do it?

I'm currently investigating alternative solutions to the standard page authorization configuration in asp.net. The location tag works ok if you have directories of files that need the same access policy but if you have lots of individual access policies the location tag is a pain. I could roll my own custom auth system but if it can be ...

SSIS reading registry keys with default values

I have a script task in an SSIS package that is supposed to retrieve a string value from the registry. If the registry value exists and has a value in it it appears to return the value fine. If the registry key does not exist or the value is blank, I can not get it to default a value for some reason. I've tried three different ways of...

how to lump up a IEnumerable<IDisposable>

I have an IEnumerable<IDisposable> collection that I need to dispose of at a given point. The issue is that for some cases all the object will be of one type and disposing of the objects needs to be done by collecting some data from them and making a single RPC call. In other cases, the objects will be of another type and I just need to ...

Default column values in Linq2Sql

Let's assume I have a table with a CreatedBy Datetime column with a default value of GETDATE()... Enter LinqToSql From what I understand so far, I have two options: Insert DateTime.Now manually in the linkToSql "insert" statement Set the "Auto Generated Value" to True, and now Linq2Sql will ignore a value I supply for CreatedDate ...

Socket seems to give problem on external network

I have a Windows Service that communicates with a server and acts as a proxy between clients and the real server. The client data is sent to the server and server's data back to the client. The above two are totally independent as they run on separate thread. Following are the steps:- Socket accepted by listener Thread 1 - Receives da...

Identify Field Control properties Dynamically

I have an app in which the user's actions such as "minimizing a window","closing a window","clicking a button" ... has to be captured. And those Field Controls ( like buttons, close icon , minimise icon ... ) can be in any application and have to be dynamically identified Is there a way to do this in C# ??? Any useful pointers are mu...

.Net Certification ebook

Hello, I am looking for ebooks for MS.NET certification. Please let me know from where I can get them, or if any one can have the same. I'm searching for ebooks for following paper codes: Exam 70-536: .NET framework 3.5 Exam 70-562: ASP.NET application development Exam 70-561: ADO.NET Exam 70-503: WCF Thanks & best regards, Adity...