.net

How to load a .NET assembly for reflection operations and subsequently unload it?

I'm writing a tool to report information about .NET applications deployed across environments and regions within my client's systems. I'd like to read the values of assembly attributes in these assemblies. This can be achieved using Assembly.ReflectionOnlyLoad, however even this approach keeps the assembly loaded. The issue here is th...

How can you work out the ID of a users MySite

In a Sharepoint WebPart written in c# I need to find out either the ID of the current users MySite, or check if the current site is the users MySite. Ideas? ...

Dynamically add items to a Context Menu & set Click action

Hi, I have a List of strings that is regenerated every 5 seconds. I want to create a Context Menu and set its items dynamically using this list. The problem is that I don't have even a clue how to do that and manage the Click action for every item generated (which should use the same method with different parameter DoSomething("item_nam...

.NET DateTime picker flat style

In .NET 3.0, most controls have a "flat" style. Apparently, the date picker doesn't have such a style but all the other controls in the form are set as flat. How can I make the date picker flat? ...

How do I sanitize CSV input with the CsvReader?

I'm using the CsvReader library in my Windows Forms application, which is coded in horribly messy VB (I've recently taken over the project.) I'm currently capable of reading semi-colon separated files without quoting, but I'm having a problem: most of the input has quoted fields, but includes unescaped quote characters within the field...

What is the best way to distribute .Net binaries and PDBs?

We altready have a similar question here but the discussion do not cover all the aspect, so I'm asking again: What is the best way to distribute a .Net application considering build mode (release vs. debug) and distribution of PDB files? Having a good reference to an article covering these aspects would be great. Consider also the dist...

Detecting running in Main Thread in C# library

Hi! I'm creating a C# dll, which is going to be used by others developers in WinForms. For some reasons, I want to detect, if methods from this library, are called from Main (GUI) Thread and warn developer he has done such a thing (ie. in log file). Is there any reasonable way to detect calling method from main thread? Remember I have no...

How to close a .Net Form from its PreFilterMessage() ?

Hi, I'm filtering the messages that come to a form with PreFilterMessage like this: print("code sample"); public bool PreFilterMessage(ref Message m) { if (m.Msg == WM_KEYDOWN && (int)m.WParam == VK_ESCAPE) { this.Close(); return true; } return false; } print("code sample"); but the matter...

Disposable singleton in C#

I have a singleton that uses the "static readonly T Instance = new T();" pattern. However, I ran into a case where T is disposable, and actually needs to be disposed for unit tests. How can I modify this pattern to support a disposable singleton? The interface I would like is something like: var x = Foo.Instance; var y = Foo.Instance; ...

How do you set the StartPostion of a Windows Forms form using code?

Is there a way to set the StartPosition of a Windows Forms form using code? It seems whatever I try results in the StartPostion being the default. Here is what I am doing in the form to display: public DealsForm() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; } Here is what...

Should I include dependencies for my releases?

Should I include dependencies when I do releases for my common projects such as CommonUtils or should I simply specify which dependencies should be referenced when they are to be used? ...

How to deal with multiple versions of dependencies?

Hi I have a problem with a dependency hierarchy I am unsure how to solve: http://img525.imageshack.us/my.php?image=56330713it2.jpg The problem is with how I should reference these dependencies from MyProject project. I have built BaseProject and the CommonUtil(version 1.0) it was built with into assemblies. Now in MyProject I am using...

Validating and Extracting XML record by record into Database

Here's the deal. I have an XML document with a lot of records. Something like this: print("<?xml version="1.0" encoding="utf-8" ?> <Orders> <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> <Order> <Phone>98764321</Phone> <City>City2</City> ...

foreach vs someList.Foreach(){}

There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you'd use one way over the other. First type: List<string> someList = <some way to init> foreach(string s in someList) { <process the string> } Other Way: List<string> someList = <some way to init> someList.ForEach(delegate(s...

how do I host a control in a DataGridViewCell for displaying as well as editing?

I've seen How to: Host Controls in Windows Forms DataGridView Cells which explains how to host a control for editing a cell in a DataGridView. But how can I host a control for displaying a cell? I need to display a file name and a button in the same cell. Our UI designer is a graphic designer not a programmer, so I have to match the c...

Best Practices: Persisting data throughout multiple web method calls.

I have a web service that has 8 web methods. These methods are called synchronously, the first call authenticates the user, and the rest of the methods perform a unit of work, these methods are called upon until the work is done. I need to store the state of the work (e.g. what actions to perform next, and what work has been done and is...

What are good references for .Net development with Office Communications Server?

Is is possible to intergrate VOIP capabilities, particularly phone dialing, with Office Communications Server 2007 and .Net? If so, are there any good references for this? I would be especially interested if this could be hosted within an ASP.Net or Silverlight application. ...

Printing in VB.Net/C# Forms Application -- Layout Designer?

I maintain a vb.net forms application that prints various labels to label printers. (Label printers are just like any printer, just smaller print area/lower resolution) The system uses a legacy printing method that's supported in the printer hardware, but has been out of general use for over a decade. I'm adding logic to print from ...

LINQ to SQL concurrency conflict - Looks like a clean attach with proper row versioning

I am trying to get LINQ to SQL to persist changes to an attached object wherein the backing table has a DateTime column that I think should function for row versioning, as described here. The table looks like this: CREATE TABLE [dbo].[client]( [client_id] [int] IDENTITY(1,1) NOT NULL, [client_address1] varchar(100) NULL, /* snip */ [mo...

How can I get the minimum required password length value from Active Directory in .NET

I'm implementing a plugin architecture to implement authentication an external authentication mechanism for a web site. One of the plugins I plan to provide is an ActiveDirectory plugin. I'd like to implement some of the features of a MembershipProvider, including MinRequiredPasswordLength, but don't want to fully implement or configur...