.net

How to find GridItem from click on PropertyGrid?

I'm trying to do some custom UI behavior on a Windows Forms PropertyGrid control. I'd like to be able to respond to clicks and double-clicks on the GridItems to change the state. For example, to flip a binary or ternary variable through its states. I can get at the underlying view by looking up a child of typename "PropertyGridView" and...

How can I mock/fake/stub sealed OracleException with no public constructor?

In my tests I need to test what happens when an OracleException is thrown (due to a stored procedure failure). I am trying to setup Rhino Mocks to Expect.Call(....).Throw(new OracleException()); For whatever reason however, OracleException seems to be sealed with no public constructor. What can I do to test this? Edit: Here is exa...

Constructor parameters for controllers without a DI container for ASP.NET MVC

Does anyone have any code examples on how to create controllers that have parameters other than using a Dependency Injection Container? I see plenty of samples with using containers like StructureMap, but nothing if you wanted to pass in the dependency class yourself. ...

How to empty/flush Windows READ disk cache in C#?

If I am trying to determine the read speed of a drive, I can code a routine to write files to a filesystem and then read those files back. Unfortunately, this doesn't give an accurate read speed because Windows does disk read caching. Is there a way to flush the disk read cache of a drive in C# / .Net (or perhaps with Win32 API calls) ...

How would you implement MVC in a WindowsForms application?

I don't develop too many desktop / Windows Forms applications, but it had occurred to me that there may be some benefit to using the MVC (Model View Controller) pattern for Windows Forms .NET development. Has anyone implemented MVC in Windows Forms? If so, do you have any tips on the design? ...

Why is a SQL float different from a C# float

Howdy, I have a DataRow pulled out of a DataTable from a DataSet. I am accessing a column that is defined in SQL as a float datatype. I am trying to assign that value to a local variable (c# float datatype) but am getting an InvalidCastExecption DataRow exercise = _exerciseDataSet.Exercise.FindByExerciseID(65); _AccelLimit = (float...

How can you add additional logic to type resolution at runtime?

Is there a generic way, without creating and managing your own CLR host, to take over locating and loading a type if that type is not found? The following is just an example. In your rush to be the first answer, don't suggest the new add-in framework or the MEF as a solution to my question. An example would be a sample with add-ins. ...

Is there a .NET equivalent of Perl's LWP / WWW::Mechanize?

After working with .NET's HttpWebRequest/Response objects, I'd rather shoot myself than use this to crawl through web sites. I'm looking for an existing .NET library that can fetch URLs, and give you the ability to follow links, extract/fill in/submit forms on the page, etc. Perl's LWP and WWW::Mechanize modules do this very well, but ...

What is the LINQ way to implode/join a string array?

I have the following string array: var sa = new string[] {"yabba","dabba","doo"}; I can convert it to "yabba, dabba, doo" it using string.Join() but what is the super-cool LINQ way of doing it? The Join extension method seems promising but for a novice like me very confusing. ...

Working with client certificates for an ASP.NET MVC site on IIS 6

Wanting to implement authentication by client certificates I am experiencing some issues. First some facts The whole site is using SSL. I am using IIS 6 (on Windows Server 2003) and have configured the site to accept client certificates, not requiring them. Most browsers are however implemented in a way so that they will only ask the u...

Is there a Java equivalent for .Net System.Data?

Is there a Java package providing funcionality like the .Net System.Data namespace ? Specificaly the DataSet and Adaptor classes ? ...

Regex - Repeating Header in a group

I am parsing text that has a heading and then data that applies to that heading. I need to break each data field into groups, and have the heading also apply to those groups. Here's an example: (Update: The text below has been updated to better reflect it's current layout, and to indicate an annotation.) Heading 1 Heading 2 H...

Hidden .NET Base Class Library Classes?

What are your favorite lesser-known .NET Base Class Library classes and methods? ...

Has anbody used Boo and can you comment on your experiences?

I'm looking for a groovy equivalent on .NET http://boo.codehaus.org/ So far Boo looks interesting, but it is statically typed, yet does include some of the metaprogramming features I'd be looking for. Can anyone comment on the experience of using Boo and is it worth looking into for more than hobby purposes at a 1.0 Version? Edit: C...

ClickOnce app not working with Office 2007

I am a developer for a .net application that uses ClickOnce for deployment. I have deployed it over 60 times and computers have not had any issues downloading the latest release. However, when I deployed this morning, the following error occurs when computers with Office 2007 installed tries to start the application: Unable to instal...

Parse HTML links using C#

Is there a built in dll that will give me a list of links from a string. I want to send in a string with valid html and have it parse all the links. I seem to remember there being something built into either .net or an unmanaged library. I found a couple open source projects that looked promising but I thought there was a built in modul...

.NET: How to have background thread signal main thread data is available?

What is the proper technique to have ThreadA signal ThreadB of some event, without having ThreadB sit blocked waiting for an event to happen? i have a background thread that will be filling a shared List<T>. i'm trying to find a way to asynchronously signal the "main" thread that there is data available to be picked up. i considered ...

Naming a "core" Assembly

I know that this is somewhat subjective, but I wonder if there is a generally accepted standard for naming assemblies which contain some "core" functions. Let's say you got a larger Projects, with Assemblies like Company.Product.WebControls.dll Company.Product.Net.dll Company.Product.UserPages.dll and you have a Bunch of "Core" clas...

Visual Studio window Manager

Hi, I was wondering if anyone knows of a window manager for visual studio 2008 like this one. I really liked it, thats all i used in vs2005, and saw somewhere it supposed to work in vs2008 but it doesnt. I have tried it on many installations of vs2008 and it doesnt remember any settings. I really liked being able to easily change window ...

how do you organize your namespaces?

So I have logical entities (person, country, etc.), gui elements / controls, data and navigation controllers / managers, then things like quadtrees and timers and I always struggle with cleanly separating these things into logical namespaces I usually have something like this: Leviathan.GUI.Controls Leviathan.GUI.Views Leviathan.Entit...