.net

How to unify/simplify this code - event handling/delegating?

I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually a derived class) and a Graph Viewer (based on Microsoft Research's Automatic Graphing Layout). Each has a context menu which can have similar events activated. While the list view can have multiple selections, I don't allow it on th...

What's a .duo file?

In a .NET/C# project, one of my *.exe files has a corresponding *.duo file. (I didn't set up the build system.) What is it? Somebody suggested it was something like a user preferences file for the debugger, possibly? ...

How should I declare this C struct for interop?

I have to use a legacy C routine in the application I am developing. The code in here works, but I have to convert almost all the fields to char arrays in order to use it. There is a better way to do it? I have tried some version using strings, all to no avail. This is the code found in the original header file... typedef struct PXUCAM...

Properly handling exceptions thrown in a thread or via the WPF dispatcher.

When a thread throws an exception that is unhandled, it terminates. What is the proper way to handle exceptions thrown on threads and how to propogate relevant exception data to other parts of the code that would need to subscribe to notifications? Is there an INotifyThreadPoorlyDesigned interface that I missed somewhere? Same applies ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I'm trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I'm not getting all of the matches that I see when I do the same thing in C# using the Regex object. Can someone explain what I am doing wrong...

Reliable/easy way to replace Windows.Forms control with a derived control?

I didn't follow my own best practices (use only derived controls), and I dragged a regular Windows Forms control to my form, wired it up and used it on my form ;-( Now I need to change the control to a derived control (derived from the same control), preserving all the settings from the designer. Is there a reliable/easy way to do this...

What's the best way to implement a search?

I've got a requirement where a user enters a few terms into a search box and clicks "go". Does anyone have any good resources on how to implement a dynamic search that spans a few database tables? Thanks, Mike ...

Basic MEF workflow/usage

I'm looking to a framework which will allow me to have a simple plugin system in my .NET application. It seems MEF is the framework which Microsoft is endorsing, and will become part of .NET 4 (it also seems to work with older .NET versions as a separate library, as well as Mono). I'm previously used Mono.Addins as for a plugin system f...

Access WCF service on same server

I have a .NET website with a WCF service. How do I access the current operations context of my service? One possible work around is to just make a call to the service within the app...but that seems sloppy and redundant; especially when the service and website are the same application. -- update The goal is to create a notification syst...

What should I load into memory when my app loads?

I have objects I am saving to the file system using serialization. When I load the app, should I load all the objects into memory or just stubs (for searching capabilities)? If I load just stubs, then I would load them from the file system when they are needed and keep them in memory after that for quick access. The order of magnitude...

Get the correct capitialisation of a filename in dot-net

I've got a section of a ClearCase VOB which has been copied to another VOB for testing scripts to move a mass of interlinked XML files into separate VOBs for each team which is working on them. For some reason, in the copy the paths have all become lower case, but the capitalisation of the references in the XML is still as it was. When ...

Performance overhead of using attributes in .NET

1.. Is there any performance overhead caused by the usage of attributes? Think for a class like: public class MyClass { int Count {get;set;} } where it has 10 attibutes (attributes being classes, where the attribute classes themselves are way larger than MyClass itself like: public class FirstAttribute : Attribute ...

Building Excel Files with C#

I need to create an excel file via C#. I have read a few places that creating an XML document is the easiest way to do this? I need to have multiple named tabs and be able to specify that particular cells are text, date time, numeric, etc... Any suggestions or good examples? ...

C# regex and html, end at the first "

I want to get a url from a string. Heres my code to extract an img url. var imgReg = new Regex("img\\s*src\\s*=\\s*\"(.*)\""); string imgLink = imgReg.Match(page, l, r - l).Groups[1].Value; The result was http://url.com/file.png" border="0" alt=" How do i fix this so it ends at the first "? I tried something like ...

Why does Dictionary[index] throws a KeyNotFoundException but Hashtable[index] doesn't?

Any idea why this behaviour is different? ...

Possible to get return url back from javascript/jquery?

Hi I have a problem that when a user times out on my site they are still logged in. So they can still do an ajax request. If they do an ajax request on my site my asp.net mvc authorization tag will stop this. The authorization normally then redirects the user back to the signin page if they fail authorization. Now since this is an aja...

How can I ignore a field when marshalling a structure with P/Invoke

Hi, I want to marshal a structure for use with P/Invoke, but this struct contains a field that is only relevant to my managed code, so I don't want it to be marshaled since it doesn't belong in the native structure. Is it even possible ? I was looking for an attribute similar to NonSerialized for serialization, but it doesn't seem to ex...

TimeZone by Coordinate

As the title infers I need to find a time zone (or perhaps just the UTC offset) based on a pair of coordinates. I've been searching for different solutions, and there is a couple of web services out there but I need to be able to access the application offline. As the timezones isn't completely based on longitude it doesn't seem that eas...

What's new in WPF 3D in .NET 4.0 ?

Did anyone find something? Even a little thing? Does anyone know if anything has been quietly announced in the blogosphere or anywhere else? ...

Why is loading FromFile and new Bitmap different? Its breaking my code :(

I am using tessnet2 to extract the sentence in this img file. When i call the tessnet2 func using bmp it fails (it returns "~" as my sentence) and when i use bmp2 instead it works. WTF, why? The reason why i am am doing FromFile is because i am grabbing the image from my server and using Image.FromStream to directly load instead of savi...