.net

Use Microsoft Scripting Control to evaluate 'If' expressions (via c#)

I have some c# code that uses the Microsoft Scripting Control to evaluate some expressions: using MSScriptControl; // references msscript.ocx ScriptControlClass sc = new ScriptControlClass(); sc.Language = "VBScript"; sc.AllowUI = true; try { Console.WriteLine(sc.Eval(txtEx.Text).ToString()); } catch (Exception ex) { Conso...

Strange Pager behaviour in ListView

Hi everybody, I have a standart Page within my ListView control on the page, And the Pager is work, however in order to move to next list of items i required to click on pager link twice before it actually moves to next set of items. The code for the pager is: <asp:ListView ID="lv_LostCard" runat="server" DataKeyNames="request_id" En...

How to Scrape websites, client side or server side?

I am creating a bookmarklet button that, when the user clicks on this button in his browser, will scrape the current page and get some values from this page, such as price, item name and item image. These fields will be variable, means that the logic of getting these values will be different for each domain "amazon, ebay" for example. ...

Is there an async version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet?

Is there an asynchronous version of DirectoryInfo.GetFiles / Directory.GetDirectories in dotNet? I'd like to use them in an F# async block, and it'd be nice to have a version that can be called with AsyncCallbacks. Problem is I'm trying to suck in a bunch of directories, probably on SMB mounts over slow network connections, and I don...

wpf in-page dialog.

When I worked on web pages I used these a lot. While building a page out for WPF project the other day I ended up building a page that looked like it had an in-page dialog on it but it was the only thing on the page. My question here is. Has any one created such component that allows for easy creation of these kinds of dialogs. ...

How can I tell that a stream has been read to the end?

I'm just writing an simple method witch reading data from a general stream - which means it could be possibly a FileStream or a NetworkStream without knowing the length of it. I repeatly read the stream into a byte[] and push the data to another stream or whatever. My question is, how can I notice the stream is finished? I tried to retur...

How can I make class into an array?

I was searcing for some information, and I found a method like this: public partial class Customer { private string customerIDField; private string companyNameField; private string contactNameField; private string contactTitleField; private string addressField; private string cityField; private...

Using Ninject (or some other container) How can I find out the type that is requesting the service?

Suppose I have an interface for a service: public interface IFooService { void DoSomething(); } And a concrete implementation of that service that is a generic: public class FooService<TRequestingClass> : IFooService { public virtual void DoSomething() { } } And I have some other class that needs an instance of IFooService: ...

Converting a string to a double

I'm trying to convert a string to a double value but it's not returning me what I expect... double dbl; Double.TryParse("20.0", out dbl); That piece of code is returning 200.0 (instead of 20.0) as a double value. Any idea why? ...

How can I use listitemCollection like placeholder

I used ListItemCollection in Web User Control. And I like it! sample.asx public ListItemCollection Items { get { return this.ListBox1.Items; } } TestForSampleascx.aspx void Add(WebUserControls.Control3 ctrl1, WebUserControls.Control3 ctrl2) { ListBox listbox = ctrl1.FindControl("ListBox1") as ListBox; if (ctrl1.Items.Cou...

Is there an updated version of "Writing Faster Managed Code: Know What Things Cost"?

The MSDN "Writing Faster Managed Code: Know What Things Cost" is pretty nice, but it was written for CLR v1 in 2003. Is there an updated version of this somewhere? ...

Purity of methods in C#, evaulation and custom compiler?

Have you ever been frustrated by Visual Studio not re-evaluating certain watch expressions when stepping through code with the debugger? I have and does anyone here care about pure methods? Methods with no side-effects? There's so many great things about C# that I love, but I can't write pure functions, that is, static methods with no s...

.NET JIT'ed assemblies in sharable pages

When running a .NET 2.0 WinForms app in a Terminal Services environment, I'm seeing some unexpected results that I can't quite explain. Everything I have read has indicated that JIT'ed assemblies (i.e., not using NGen to create native images) result in all code space being stored in private pages, increasing working set size / memory pr...

What is the best Free/Open-Source image conversion library in .NET?

System.Drawing has supports for very limited number of image formats What I am trying to do is, given an image of some format(JPG, TIFF, GIF, or PDF), conver them to other formats. I am specifically looking for a free or an open-source versions of library for .NET. Google and Stack Overflow gave me results libraries such as LeadTools (...

Silverlight Form Generation

I am working on a typical data entry system in Silverlight. Most of my screens are basically view/edit screens. I am using a DDD approach and have domain objects for everything. A typical scenario is something like a User object with a user edit and entry page. After working on this for a few types of objects, I am seeing a pattern...

Something faster than MS Access 2007, Fast Portable Database Recommendations?

I'm using MS Access 2007 for insert and read data in my application but it's really slow. I've got a long running application and if I run it from the memory it takes about 5 minutes, with MS Access 2007 it takes about 13 minutes! I'm looking for a faster yet portable database option, I'm using .NET . I'm not looking for advanced rela...

Is this an appropriate use of the ThreadPool? Can I be sure it'll start a thread for each task?

protected override void OnStart(String[] args) { ResultManager.PrepareCache(); ThreadPool.QueueUserWorkItem(ResultQueue.Process); ThreadPool.QueueUserWorkItem(StatusUpdater.UpdateStatus); ThreadPool.QueueUserWorkItem(GeneralQueue.RestartHungTests); ThreadPool.QueueUserWorkItem(ResultManager...

Drag/Size Handle implementation

I'm looking for drag/size handle implementations or explanations. Perhaps I'm using the wrong nomenclature, but I mean the "handles" that appear around an object (mostly in drawing programs) when you select it and want to perform an operation on that object such as rotate, size, scale, etc... Can anyone point me to an OSS implementatio...

Finding all classes with a particular attribute

I've got a .NET library in which I need to find all the classes which have a custom attribute I've defined on them, and I want to be able to find them on-the-fly when an application is using my library (ie - I don't want a config file somewhere which I state the assembly to look in and/ or the class names). I was looking at AppDomain.Cu...

Default implementation for Object.GetHashCode()

Does anyone know or have an idea on how the default implementation for GetHashCode() works? And does it handle structures, classes, arrays, etc efficiently and well enough? Trying to decide under what cases I should pack my own and what cases I can safely rely on the default implementation to do well. Don't want to reinvent the wheel if...