.net

Elevating process privilege programatically?

I'm trying to install a service using InstallUtil.exe but invoked through Process.Start. Here's the code: ProcessStartInfo startInfo = new ProcessStartInfo (m_strInstallUtil, strExePath); System.Diagnostics.Process.Start (startInfo); where "m_strInstallUtil" is the fully qualified path and exe to InstallUtil.exe and "strExePath" is th...

How do I remove an element that matches a given criteria from a LinkedList in C#?

I have a LinkedList, where Entry has a member called id. I want to remove the Entry from the list where id matches a search value. What's the best way to do this? I don't want to use Remove(), because Entry.Equals will compare other members, and I only want to match on id. I'm hoping to do something kind of like this: entries.Remove...

.NET Windows Integrated Authentication

I'm looking for the best/easiest way to add extensions to an existing protocol (can't change the actual protocol easily) to allow the user to do windows authentication (NTLM?) in .NET. I looked at the AuthenticationManager class already but it requires that I use Web(Http)Request which isn't an option. NegotiateStream is an option either...

How do I use a remote MSMQ transactionally?

I am writing a Windows service that pulls messages from an MSMQ and posts them to a legacy system (Baan). If the post fails or the machine goes down during the post, I don't want to loose the message. I am therefore using MSMQ transactions. I abort on failure, and I commit on success. When working against a local queue, this code works ...

How can I access a mapped network drive with System.IO.DirectoryInfo ?

I need to create a directory on a mapped network drive. I am using a code: DirectoryInfo targetDirectory = new DirectoryInfo(path); if (targetDirectory != null) { targetDirectory.Create(); } If I specify the path like "\\\\ServerName\\Directory", it all goes OK. If I map the "\\ServerName\Directory" as, say drive Z:, and specify t...

How do I deserialize an XML file into a class with a read only property?

I've got a class that I'm using as a settings class that is serialized into an XML file that administrators can then edit to change settings in the application. (The settings are a little more complex than the App.config allows for.) I'm using the XmlSerializer class to deserialize the XML file, and I want it to be able to set the prop...

Do you know of any .NET components for creating Distance Matrices / Routing graphs ?

Based on geographical data in classic GIS formats. These matrices are a basic input for different vehicle routing problems and such. They can usually be produced an best time or shortest distance basis. ...

What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net?

What are the best/most popular ways to do aspect-oriented programming (AOP) in C#/.Net? ...

unlockbits, lockbits, and try-finally

Hello, I'm calling some code that uses the BitmapData class from .NET. I've hit something where I can't find a definitive answer on Googlespace. Because it seems that LockBits and UnlockBits must always be called in a pair, I'm using this: System.Drawing.Imaging.BitmapData tempImageData = tempImage.LockBits( new System.Drawing.R...

Is there .Net replacement for GetAsyncKeyState?

In VB6, I used a call to the Windows API, GetAsyncKeyState, to determine if the user has hit the ESC key to allow them to exit out of a long running loop. Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Is there an equivalent in pure .NET that does require a direct call to the API? ...

Why are 'out' parameters in .Net a bad idea?

I was recently asked this, but had no real answer besides it simply unnecessarily complicating an application. What other reasons are there? ...

"Reuse existing types" is ignored when adding a service reference

I am adding a service reference to one of my projects in Visual Studio 2008. On the "Service Reference Settings" screen I am selecting the default option which says "Reuse types in all referenced assemblies". I have referenced the project for which I want to reuse a type. That type is being passed in as a parameter to a web method. Ho...

What strategies and tools are useful for finding memory leaks in .net?

I wrote C++ for 10 years. I encountered memory problems, but they could be fixed with a reasonable amount of effort. For the last couple of years I've been writing C#. I find I still get lots of memory problems. They're difficult to diagnose and fix due to the non-determinancy, and because the c# philosophy is that you shouldn't have to...

Do assemblies placed in the GAC gain full trust?

I've been hearing conflicting facts about this topic. What is correct? ...

Obtaining a collection of constructed subclassed types using reflection

I want to create a class which implements IEnumerable<T> but, using reflection, generates T's and returns them via IEnumerable<T>, where T' is a entirely constructed subclass of T with some properties hidden and others read-only. Okay., that might not be very clear. Let me explain this via the medium of code - I'd like to have a clas...

Create a method call in .NET based on a string value

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName As String) Select Case reportName Case "Security" Me.ShowSecurityReport() Case "Configuration" Me.ShowConfigurationReport() Case "RoleUsers" Me.ShowRoleUsersReport() Case ...

Why can't you use the keyword 'this' in a static method in .Net?

I guess that's a real noobie question, but I'm new to OO and .Net. I just don't understand why it can't be done. ...

Hiding the header on an Infragistics Winform UltraCombo

I've gone through just about every property I can think of, but haven't found a simple way to hide the header on a winform UltraCombo control from Infragistics. Headers make sense when I have multiple visible columns and whatnot, but sometimes it would be nice to hide it. To give a simple example, let's say I have a combobox that displ...

C#/.net ActiveDirectory Resources

I have recently assumed maintenance of an app that performs a lot of ActiveDirectory-related tasks, both querying and updating. I have the existing code to look at of course, but I was also curious if anyone had any good links for AD manipulation through C# and .Net, or pointers to any good books I can convince my boss to buy. ...

Microsoft.ApplicationBlocks.Data.ODBCHelper ?

I've found mention of a data application block existing for ODBC, but can't seem to find it anywhere. If i didn't have a copy of the Access DB application block I wouldn't believe it ever existed either. Anyone know where to download either the DLL or the code-base from? --UPDATE: It is NOT included in either the v1, v2, or Enterpris...