.net

How do I hide a process in Task Manager in C#?

I have a requirement to hide a process in Task Manager. It is for Intranet scenario. So, everything is legitimate. :) Please feel free to share any code you have (preferably in C#) or any other techniques or any issues in going with this route. Update1: Most of the users have admin privileges in order to run some legacy apps. So, one ...

How do I get the version of an assembly without loading it?

One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process. ...

Creating an asp:button programatically

Hi, I'm using my code-behind page to create a save button programatically: Button btnSave = new Button(); btnSave.ID = "btnSave"; btnSave.Text = "Save"; However I think this must create an html button or perhaps needs something else as I cannot seem to set the OnClick attribute in the following line, I can specify OnClien...

Changing target framework in Visual Studio 2008

Hi, What's the deal with VS?...I tried importing the Caching App Block and got the message...the assembly or one of it's dependencies your are trying to import requires a later version of .NET Framework...... I went to the properties of my app in VS, but I can't find the dropdown to switch....what's the deal? Thanks ...

Can I specify my explicit type comparator inline?

So .NET 3.0/3.5 provides us with lots of new ways to query, sort, and manipulate data, thanks to all the neat functions supplied with LINQ. Sometimes, I need to compare user-defined types that don't have a built-in comparison operator. In many cases, the comparison is really simple -- something like foo1.key ?= foo2.key. Rather than c...

How to convert ArrayList to an array of structure?

Here I have: Public Structure MyStruct Public Name as String Public Content as String End Structure Dim oStruct as MyStruct = New MyStruct() oStruct.Name = ... oStruct.Content = ... Dim alList as ArrayList = new ArrayList() alList.Add(oStruct) I'd like to convert the ArrayList to a static strongly-typed Array of type MyStruct....

Upgrading a ASP.NET 1.1 Web Service using the WSE 2.0 to .NET 3.5

We recently upgraded an application that that contained web services using the WSE 2.0 to .NET 3.5. When we converted the project in Visual Studio 2008, It did not mention anything about the removing and/or modifying the WSE 2.0 namespaces. Here is the basic architecture of the web services in the .NET 1.1 project. Web Service Source ...

Which Version of StringComparer to use

If I want to have a case-insensitive string-keyed dictionary, which version of StringComparer should I use given these constraints: The keys in the dictionary come from either C# code or config files written in english locale only (either US, or UK) The software is internationalized and will run in different locales I normally use St...

How do you execute a stored procedure using Castle ActiveRecord?

I believe there is a discussion on this very topic somewhere on the net but I lost the url and I am unable to find it via googling. What I might try right now would be: ISessionFactoryHolder factoryHolder = ActiveRecordMediator<EntityClass>.GetSessionFactoryHolder(); ISession session = factoryHolder.CreateSession(typeof(EntityClass)); ...

Simple animation using C#/Windows Forms

I need to knock out a quick animation in C#/Windows Forms for a Halloween display. Just some 2D shapes moving about on a solid background. Since this is just a quick one-off project I really don't want to install and learn an entire new set of tools for this. (DirectX dev kits, Silverlight, Flash, etc..) I also have to install this o...

DataGridView Mouse Selection

I am using a DataGridView control in a Windows Forms application. When a user holds down control to select multiple items, it works fine. Now when the user releases control and clicks (and holds down the left mouse button) to start a drag operation, the selection changes. How can I stop the selection from clearing when the user holds dow...

Detecting the number of processors

How do you detect the number of physical processors/cores in .net? ...

What interface or method should my class implement to print what I want in Console.WriteLine?

I have an object of class F. I want to output the contents of the object using Console.WriteLine for quick and dirty status updates like this: Console.WriteLine(objectF); This prints out only the name of the class to the console: F I want to overload this somehow so that I can instead print out some useful information about the obj...

Problem with System.IO.Directory.Exists

I’m getting an intermittent false negative on the call “if (!System.IO.Directory.Exists(folder))” in code in an ASP.NET 2 web site [1]. The folder clearly exists, and even contains a log file that is written to when the CLR doesn’t lie about the folder’s existence. Any help would be appreciated. [1] BugTracker.NET ...

Is there a way to cast generic lists to lists of interface/base class types?

I'm trying to show someone a use for interfaces in a crazy situation they've created. They have several unrelated objects in lists, and need to perform an operation on two string properties in each object. I'm pointing out that if they define the properties as part of an interface, they can use the interface object as the type for a me...

Why does Word freeze when I'm debugging?

Whenever I'm at a break point in a certain C#.NET application in Visual Studio 2008 and I fire up Microsoft Word 2007, word will fail to open until I restart the C# application. I have a few theories about why, but does anyone know for sure? ...

C# : Textbox multiple line and blank line disappear

I have a Winform application build with C# and .Net 2.0. I have a textbox set with MultiLine. The problem is when someone write text with multiple line (press few enters) and press my save button than close and load the form again. All the new line disappear (the text is there at least). Example: Line1 Line3 This will be if I save ...

glob pattern matching in .NET

Is there a built-in mechanism in .NET to match patterns other than Regular Expressions? I'd like to match using UNIX style (glob) wildcards (* = any number of any character). I'd like to use this for a end-user facing control. I fear that permitting all RegEx capabilities will be very confusing. ...

Phone Number Formatting, OnBlur

I have a .NET WinForms textbox for a phone number field. After allowing free-form text, I'd like to format the text as a "more readable" phone number after the user leaves the textbox. (Outlook has this feature for phone fields when you create/edit a contact) 1234567 becomes 123-4567 1234567890 becomes (123) 456-7890 (123)456.7890 bec...

catching exceptions from another thread

I have a method running in a seperate thread. The thread is created and started from a form in a windows application. If an exception is thrown from inside the thread, what is the best way to pass it back to the main application. Right now, I'm passing a reference to the main form into the thread, then invoking the method from the thr...