.net

Get a Unique ID for a Hard disk attached to a PC in .net

As the question states I need some way of getting a unique ID for each of the drives attached to my PC. The reason behind this is that if i store the location of a file in a DB and I want to retrieve it at a later stage I wont always get the file since the drive letters change depending on the number of drives plugged in. ...

new static fields and hiding the public inherited members

Curious situation: public class MyTextBox : TextBox { // I want use the same height for all MyTextBoxes public new static int Height; } public Form1() { InitializeComponent(); MyTextBox mtb1 = new MyTextBox(); MyTextBox mtb2 = new MyTextBox(); mtb1.Multiline = true; m...

.Net Assembly Binding Redirect with Differing Public Key Tokens

Is it possible to perform an assembly binding redirect between different versions of a referenced assembly if the public key token is null on the older version and set on the newer version? For example, I have two assemblies... System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null and System.Web.Mvc, Version=2.0.0.0, ...

Releasing temporary COM objects

Consider the following C# code using a COM object. MyComObject o = new MyComObject; try { try { var baz = o.Foo.Bar.Baz; // do something with baz } finally { Marshal.ReleaseComObject(baz); } } finally { Marshal.ReleaseComObject(o); } This will release the COM objects o and baz, but not the temporary objects returnd by...

Does the CLR garbage collection methodology mean it's safe to throw circular object references around?

I have a theory that the CLR garbage collection mechanism means that I can get away with circular references in my object hierarchy without creating deadlocks for teardown and garbage collection. Is this a safe assumption to make? (Target language VB.NET) ...

Anonymous methods with return type in .Net

Hi All, This is a question for my curiosity really, as i know there are other ways to work around the problem. I have a property on my "Item" class - "MyProperty" - that I want to evaluate. I want to iterate through the collection - "MyItemCollection" - , and if there is an "Item" class whos property "MyProperty" is not nothing i...

.NET - Verify and Install .NET Framework 3.5 before running application

PLEASE READ THE FULL QUESTION BEFORE POST YOUR ANSWER Hello guys! I'm currently developing a "Extremelly customized Installer Application" in C# for installing a old classic ASP application. It'll be used during the 2.0 version is developed (ASP.NET MVC with C#). As its so different from the efault install packages, I've made it as nor...

Managing resources via compilation flags

Any idea how i can do that ? Now days it is done in Resources.Designer.vb we have there following lines: Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then #If WizardVersion Then ...

How do I paint the same area with different set of controls?

I'm using Winforms/ C# .NET. In the ToolStrip I've different buttons, each should take us to a different page. (I don't know what term should I use for this.) I'm unable to express it clearly. The closely related software that depicts what I want is ccleaner see image here: http://i.imagehost.org/0569/cc.gif on selection, of each ta...

Preventing an Active Directory user from changing his/her password using DirectoryServices

When creating Active Directory users from a script, I also need to set the option that they can't change their passwords. Via the administrative GUI this is easily accomplished, by checking "User cannot change password". Programmatically however, it's another story. I've found a recipe which involves interacting with the ADSI COM API, bu...

Parsing values from a formatted string in C#

How can I parse multiple values from a formatted string in C#? The string is in this format: "blah blah blah (foo:this, bar:that)" I need to parse out the foo and the bar value. The parentheses are always at the end of the line. Edit: Sorry... that wasn't very clear. What I meant was I need to know the "foo" value and the "bar" v...

Detailed Changelog for .NET Framework 4.0

Is there a detailed list of changes in .NET 4.0? Please add any changes you know about. ...

Is it possible to "inject" a .NET dll into another .NET application, by way of app.config perhaps?

I have made a .NET class library in C# that initializes some logging, sent to an external tool. The library is altogether separate from any application, but in order to initialize it, I need to make at least one method call to it. Is there a way for me to put something into app.config that will auto-load that dll, and call something in ...

Where should I store error logs?

Hi, I'm building a C#/Asp.Net (FW 2.0) web application and I was wondering where I should store my error logs entry. I could write it on a file on the server, but that doesn't seems right to me. It would be insconsistent with the idea of a database. The other obivous answer is on the database, but what happened if I do not have any con...

Visual Studio 2008 Form Inheritance and Generics Failure to load

Given the following inheritance tree: I have a public class BaseForm : Form This is the base form for all WinForms in the project (or most) and contains some basic stuff. Later in time, when Generics came, I created a public abstract partial class GenericObjectListBase<T> : BaseForm And finally, I specialized that one with a: ...

Garbagecollection of eventhandlers

I have a Windows.Forms app with a ListBox populated with Account objects. When the user selects an Account from the list I attach an EventHandler responsible for updating the selected Account transactions in the event that there's any new ones while the user is looking. private void listBox1_SelectedIndexChanged(object sender, EventArg...

Simple Delegate (delegate) VS Multicast delegates

I have gone through many articles but I am still not clear about the difference between the normal delegates that we usually create and multicast delegates. public delegate void MyMethodHandler(object sender); MyMethodHandler handler = new MyMethodHandler(Method1); handler += Method2; handler(SOMEOBJECT); The above delegate MyMethodHa...

clientscript.registerclientscriptblock or include not adding to the page head?

hi i am using the clientscript.registerclientscriptblock with (typeof(page),this,that) to bung in my scripts.. ie. jquery and validate etc.. and i also have some hand scripted stuff in the head (where scripts are supposed to be .. right?) doing bits and bobs.. but it seems that as the registerclientscript doesnt put the scripts in the...

Does anyone know of a way to easily convert a PDF to a docx format programmatically

We have a couple 3rd party systems that give us PDFs. We would like to convert those PDFs for display on the web without using an Adobe product. Ideally we would like to use Silverlight to render the PDFs but are having trouble converting from a PDF to Xaml or using docx format as a middle man. There are lots of libraries that give PD...

Display inherited methods and properties in Visual Studio

Are there any options or plugins that display inherited members (methods/properties) inline when editing a class file in Visual Studio? The inherited code would probably be disabled/grayed out, but it seems like it could be useful and interesting to have the option to view an entire composed class at once. ...