.net

NetLocalGroupGetMembers vs AccountManagement (performance)

I find that NetLocalGroupGetMembers is many times faster than using the AccountManagement name space. How can I optimally rewrite the following code to approach the speed of accountmaangement (assume recursive = false)? Or is there a better approach? public List<Principal> GetMembersOfGroup(string groupName, bool recursive) { ...

Changing the value of a node in an asynchronous TreeView

I have a treeview using BackGround worker to add nodes when you expand any. I display a "Loading.." message after the expand and remove it after the nodes are loaded. It works fine and all. Now I want to change the loading message to "Loading...node n/n". I was able to do it but the problem is this message is not displayed(updated to) wh...

.net n-Tiered/Distributed Programming Technologies

If want to learn how to program n-Tiered/Distributed applications in .net, what technology should I start my learning with COM+/Remoting/Web Services/WCF? Are these technologies complementary or exclusive and to what degree? ...

Getting an assembly's Product property only having an AssemblyName

I'm getting the Product attribute from all the loaded assemblies in my application using: AssemblyProductAttribute product = (AssemblyProductAttribute)Attribute.GetCustomAttribute( assembly, typeof(AssemblyProductAttribute)); I would like to get this attribute for all the assemblies that the currently loaded assemblies ref...

How can I effectively perform advanced processing on my DB?

I'm developing a timesheet application using SQL Server as my backend and I am trying to figure out the best way to handle implementing relatively complex processing logic in my DB for reporting purposes. I have a table (timesheet_entries) that is composed of the following fields: entry_id employee_id job_id job_state pto_code (this s...

Thoughts on the use of readonly for any/all instance members of a class?

Preface For some time now I've been using the readonly modifier for nearly all class fields. I use it for List<T> members, IDisposeable members, ints, strings, etc... everything but value types I intend to change. I tend to do this even when I would normally like to null a member on Dispose(). IMHO The advantages of not needing the i...

.Net Source Debugging on Windows 7

We are trying to debug through a Sql Server CE issue on a Windows 7 Enterprise RTM (64-bit) desktop running the .Net Framework 3.5, SP1. The application is crashing consistently and we are trying to set up .Net Framework debugging for Visual Studio 2008, SP1. Using the scattered resoures around the internet, we set the options: Symbol...

Constructing Dynamic Properties at Runtime in VB .NET

Is there a way to dynamically create properties at runtime in VB .NET using introspection? e.g. Suppose I had a class Public Class Foo Public Property Bar() As String get ... end get set(ByVal value As String) ... end set End Class Is there a way to create property Bar at runtime? T...

Why does .NET use so much CPU, is this a problem?

(This was meant to be a general hypothetical question, me whining that .NET was a pig and begging for reasons. It was not really meant to be a question about my specific app.) Currently I am rewriting some old C++ code in C#. We are porting over all legacy applications. I have C++ applications that take MAX 3% CPU. Mostly they use none....

C# GDI+ - Remove just above bottom half of ellipse on gloss method

Hello all, I have a gloss method and I'm trying to get a inverted half moon like effect. On the below code I'd like to remove just above bottom half of this ellipse and then draw it. Does anyone know how I might begin to do that? PS. The gloss is also turning out too white. I've tried messing with the alpha to no avail, does anyone know...

Hierarchical (Multi-column) Sorting for the .net GridView?

Is there a simple ".Net" way to do hierarchical sorting Table... A|B|C ----- 1|2|5 2|8|4 2|4|3 3|7|2 4|4|1 clicking on A, then B would get you.. A|B|C ----- 1|2|5 2|4|3 2|8|4 3|7|2 4|4|1 The change being that I'm sorting (B) in context of (A) and so forth. Obviously this could be managed in the datasource, but was wondering if s...

"Search" the members of an object in .NET's JIT debugger

I'm a relatively new employee at my current company, so I'm still "drinking from the fire hose" in terms of learning my way around the software and architecture. I've found myself dealing with some very large objects while writing unit tests, let's say for discussion a "SavedOrder", and I need to find where to find a particular piece of ...

Windsor AddComponentInstance problem

I have successfully setup castle windsor using an xml configuration file and everything works fine. The only problem is that on a method I need Windsor to pass an existing instance to the constructor so I used container.Kernel.AddComponentInstance<IMyClass>(MyClassInstance); before the Resolve method but that does not work because Win...

Blindly converting structs to classes to hide the default constructor?

I read all the questions related to this topic, and they all give reasons why a default constructor on a struct is not available in C#, but I have not yet found anyone who suggests a general course of action when confronted with this situation. The obvious solution is to simply convert the struct to a class and deal with the consequence...

How to get type of COM object

I am referencing a COM library in Visual Studio, so it has automatically created the corresponding Interop assembly for me. I would like to do a GetType() on these com objects, but they always return System.__ComObject. Querying them for an interface works though: bool isOfType = someComeObject is ISomeComObject; //this works But what...

Panel.Enabled works inside UpdatePanel. Panel.Visible does not.

I have a Panel control inside of an UpdatePanel. When I set Panel.Enabled = false; on postback, all controls inside the Panel become disabled. However, when I call Panel.Visible = false; on postback, the Panel still displays. This code does as expected: protected void rdoPayment_CheckedChanged(object sender, EventArgs e) { pnlBilli...

Verifying event registration using Moq.net

I'm developing an asp.net (classic) application trying to implement the MVP pattern using this example. In trying to unit test my presenter and using the following pattern, the psuedocode for which looks like so //base view interface public interface IView { event EventHandler Init; event EventHandler Load; bool IsPostBack...

How do I control the <?xml ?> part of xml serialization with .NET?

I am using this method to serialize my object: public static string XmlSerialize(object o) { var stringWriter = new StringWriter(); var xmlSerializer = new XmlSerializer(o.GetType()); xmlSerializer.Serialize(stringWriter, o); string xml = stringWriter.ToString(); stringWriter.Close(); return xml; } It makes XML...

How do I find a file that may not be fully-qualified by using the environment path?

I have an executable name, like "cmd.exe" and need to resolve it's fully-qualified path. I know the exe appears in one of the directories listed in the PATH environment variable. Is there a way to resolve the full path without parsing and testing each directory in the PATH variable? basically I don't want to do this: foreach (string ...

WPF Mixing Bound and Fixed text in a TextBox

I have the following code to display a clients age. <TextBox x:Name="txtClientAge" Text="{Binding Path=ClientAge}" /> However, instead of just displaying just the number, I want to prefix it with the text "Age " and suffix it with the text " yrs" so it is effectively becomes "Age 36 yrs" I can achieve this with a horizontal StackPane...