.net

Select a node with XPathNodeIterator without indenting xml

Is it possible to select a node using an XPathNodeIterator and get the Outer Or InnerXML without indentation? Since the results are used in XHTML output the indentation (using spaces) will result in layout differences. Sample code snippet: xmlDoc = New XPathDocument(fileIn, xmlSpace.Preserve) xmlNav = xmlDoc.CreateNavigator() Dim xmlN...

How do I find the current executable filename?

An executable file loads an external library. Is there a way for the library to know the calling executable file? (I would have sworn I saw the answer to this elsewhere, but I can't seem to find it anymore) ...

How to know if the code is inside TransactionScope?

What is the best way to know if the code block is inside TransactionScope? Is Transaction.Current a realiable way to do it or there are any subtleties? Is it possible to access internal ContextData.CurrentData.CurrentScope (in System.Transactions) with reflection? If yes, how? Thank you in advance. ...

Access Violation probem with unhandled managed Exceptions in managed C++ .NET application

This is actually a solved problem, but it's so esoteric I thought I'd share it for other users. Also perhaps others might suggest reasons? Anyway, I'm working on a "mixed mode" .NET application written in managed C++, but with heavy links into existing native libraries. The problem was, unhandled managed exceptions ended up as Win32 A...

RemotingServices.IsObjectOutOfAppDomain when it will return false?

As per Remote Object definition -Any object outside the application domain of the caller should be considered remote. RemotingServices.IsObjectOutOfAppDomain -returns false if remote object resides in the same app domain. In the MSDN article "Microsoft .NET Remoting: A Technical Overview" I found the following statement (in the paragr...

Multiple where for generic type

I need to specify that a generic type for my class implements an interface, and is also a reference type. I tried both the code snippets below but neither work public abstract class MyClass<TMyType> where TMyType : IMyInterface where TMyType : class public abstract class MyClass<TMyType> where TMyType : class, IMyInterfa...

Why is Object.GetType() a method instead of a property?

From a design perspective, I wonder why the .NET creators chose System.Object.GetType() instead of a System.Object.Type read-only property. Is it just a (very minor) design flaw or is there rationale behind there? Any lights welcome. ...

Update app.config system.net setting at runtime

I need to update a setting in the system.net SectionGroup of a .Net exe app.config file at runtime. I don't have write access to the original config file at runtime (I am developing a .Net dll add-in which is hosted in an exe provided by the app which I have no control over) so I was hoping to save a copy of the file and replace the conf...

Creating a transparent corner PNG in .net

As part of a UI .net library I need to create corner PNG images to align to the corners of a DIV in order to give it rounded corners. I thought I could create a dynamic corner by doing the following: Create a bitmap (Let's say 25 x 25) Fill the background Green (The colour outside of the DIV we are creating these for) Call FillEllipse...

Is it possilbe to use attributes to automatically raise an event on a property change

I find myself writing this code a lot: private int _operationalPlan; public int OperationalPlan { get { return _operationalPlan; } set { _operationalPlan = value; RaisePropertyChanged(); } } private void RaisePropertyChanged() { ...

How to compile a C# DLL from command prompt that references additional assemblies?

I have created a C# console application that contains the namespaces System and System.Data Additionally, I have added Microsoft.SqlServer.Smo. When I try to compile from command prompt it shows the error as: SqlSmoDiscovery.cs(3,27): error CS0234: The type or namespace name 'Management' does not exist in the namespac...

How to add a default email publisher to all projects in CruiseControl.NET?

I've got multiple projects configured in CC.Net. I'd like to use the email publisher for all of the projects, Currently I've only managed to configure the email publisher per project and not globally. Which means that If any of the project fails I'd like an e-mail dispatched. Thanks. ...

How do I find a color that is between two other colors?

I am assigning each color a numeric value. For example: Color.red: 12 Color.Blue: 6 I need to find a color between two colors (for example, red and blue). But how? I have tried this, (Color.red+color.blue)/2=> (12 + 6)/2 = 9 9 corresponds to Color.yellow ...

Change assembly version for multiple projects

How can I change the assembly version in the file AssemblyInfo.cs for multiple projects. We have around 75 project in our solution and we need to change the version almost every week. What is the fastest way to do this. ...

WPF bug or am I going crazy?

I am seeing the weirdest bug with the following code. I have a PathGeometry to which I added a PathFigure so that I can add LineSegments to it. This is what I do: _pathGeometry.Figures.Add(_pathFigure); _pathFigure.StartPoint = new Point(4, 0); LineSegment lineSegment1 = new LineSegment(new Point(4, -10), true); LineSegment lineSegme...

How to use c# Dll in vc++??

I have created a dll using command line (csc). Suppose that dll contains Add(int,int) method. Now I want to use that add function in vc++?? How to do this? Your Help will be Greatly Appreciated. Here is what I am doing. vcproj; for this project i have right click and linker section add additional dependencies.added the path where d...

Convert RGB method?

How can I do this? int blue = Color.Blue.ToArgb(); int yellow = Color.Yellow.ToArgb(); blue = (blue + yellow) / 2; Color Blue = ConvertFromRGB(blue); ...

.NET Dictionary as a Property

Can someone point me out to some C# code examples or provide some code, where a Dictionary has been used as a property for a Class. The examples I have seen so far don't cover all the aspects viz how to declare the dictionary as property, add, remove, and retrieve the elements from the dictionary. ...

How do I get a particular derived object in a List<T>?

Let's say I have a generic list of Fruit (List<Fruit> fruits = new List<Fruit>()). I then add a couple of objects (all derived from Fruit) - Banana, Apple, Orange but with different properties on the derived objects (such as Banana.IsYellow). List<Fruit> fruits = new List<Fruit>(); Banana banana1 = new Banana(); Banana banana2 = new Ban...

Reporting Services Object Reference Error

...