.net

GetProperties() to return all properties for an interface inheritance hierarchy

Assuming the following hypothetical inheritance hierarchy: public interface IA { int ID { get; set; } } public interface IB : IA { string Name { get; set; } } Using reflection and making the following call: typeof(IB).GetProperties(BindingFlags.Public | BindingFlags.Instance) will only yield the properties of interface IB, wh...

Unittesting methods that contain using statements

I am wondering if Unittesting and using statements can really go hand in hand as there is no way to mock the disposable object instantiated in the using statement. How would I be able to effectively unittest a method containing the following using statement? public void MyMethod() { using(MyDisposableClass disp = new MyDisposableCla...

Why won't my program run from the Program Files directory but will from anywhere else?

My program run fine from anywhere else on my drive apart from the Program Files directory (windows XP), I am logged on as administrator so I have full permissions to the drive. It runs fine from the root of c: the windows directory basically anywhere else apart from Program Files. I have recreated this problem on 4 different machines 2 X...

.NET Designtime Datasource (for Combobox)

Hi, i'm trying to create a ObjectDataSource which I can use to bind to a BindingSource which on his turn should be bound to a ComboBox. I've created a simple class and a simple list for this class (see below) The Times list class is not showing up at my toolbox, so I cannot drag it to the form so I can select it as the datasource for...

How do I create a Web Service in IronPython?

How do I create a .Net Web Service in IronPython? Preferably dynamically without any pre- or post-processing. ...

Declaring constants in a project

Hi, I have seen these two approaches for constant declaration which are to be used in the project. Constants in a public module. Constants in a NonInheritable(Sealed) class Does anybody uses any other approach for the constant declartion ? Is there any difference between these approaches, any pros and cons ? Thanks. ...

Convert Float that has period instead of comma?

I have data from a table in a database (string) that contain text and price. I extract the price from the data but my problem is that sometime I can Convert it to float and sometime not. I have noticed that : Convert.ToSingle(m.Groups[1].Value); It works but not always because sometime the period is the problem (it requires a comma)....

Access x86 COM from x64 .NET

I have an x64 server which, since my libraries are compiled to AnyCPU, run under x64. We are needing to access a COM component which is registered under x86. I don't know enough about COM and my google searches are leading me nowhere. Question: Can I use a symbolic registry link from x64 back to x86 for the COM component? Do I need t...

Windows service on server wont run without a user logged in

I created a windows service that's basically a file watcher that wont run unless a user is logged into the machine its on. The service is running on a Windows Server 2003 machine. It is designed to move the files that are put into one directory into a different directory based on keywords in the file names, but none of the files move u...

Entlib and interop: does it work, and where does the config file go?

I'm trying to use the EntLib 3.1 within .net code for a dll which is registered for COM interop. Where do I put the config file? Alternatively, is there a way to specify within the dll code where it should get the entlib config from? Since my dll will be called from COM I don't always know what exe will be calling it. I created a simp...

How to make IEnumerable<T> readonly?

Why is list1Instance and p lists in the Main method of the below code pointing to the same collection? class Person { public string FirstName = string.Empty; public string LastName = string.Empty; public Person(string firstName, string lastName) { this.FirstName = firstName; this.Las...

Problem deploying DLLs to the GAC in a Visual Studio Setup Project

"Assembly [AssemblyName] must have a shared name to be installed globally" I am getting this error message when I try to deploy some component DLLs for my application to the Global Assembly Cache. What is a shared name and how do i make sure my DLLs have one? ...

Is there a way to set Tab Order in ASP.net?

I am trying to set up my tab order on the html side of my project. How do I set the tab order. Usually in visual basic, the option is in the menu bar under view/tab Order. How do I do this in asp? ...

.net Dataset Primary-Keys - enforcing uniqueness?

I have a small dataset with a few datatables. I load the datatables from various DBs and have a config file that I read to determine the primary keys I want to enforce on the given datatables. If the config doesn't contain a proper (non unique) primary key, how can I catch this event when applying the primary key to the datatable? Cur...

Identifying active network interface in .NET

In a .NET application, how can I identify which network interface is used to communicate to a given IP address? I am running on workstations with multiple network interfaces, IPv4 and v6, and I need to get the address of the "correct" interface used for traffic to my given database server. ...

master detail binding using wpf/linq to sql

I'm trying to create a master detail view of a linq to sql relationship in wpf. The view will have two comboboxes. One for selecting the master item and another for selecting the detail item. I have achieved this using an ADO.Net Dataset containing two tables and a relationship between the tables. where the first combobox binds to the ...

How can I force the PropertyGrid to show a custom dialog for a specific property?

I have a class with a string property, having both a getter and a setter, that is often so long that the PropertyGrid truncates the string value. How can I force the PropertyGrid to show an ellipsis and then launch a dialog that contains a multiline textbox for easy editing of the property? I know I probably have to set some kind of attr...

Windows Workflow Foundation persistence schema explanation?

I'm trying to debug a workflow project that's using the default WF SQL persistence schema. Does anyone know of a good explanation for what the data in each table represents? ...

.NET WinForms: How to use an API call that requires a window handle?

Short version How do i use an API call when i cannot guarantee that the window handle will remain valid? i can guarantee that i'm holding a reference to my form (so the form is not being disposed). That doesn't guarantee that the form's handle will stay valid all that time. How can a form's window handle become invalid even though ...

DMX example in VB.Net

I have a chunk of MDX that I'd like to throw into a Asp.Net form. Hopefully just bind the results to a gridview. Anyone know of any good links or snippets? I'm using VB.Net, but am able to port from C# if no VB is available. ...