.net

Get Image Width/Height without using a Drawing.Image

I know it sounds weird. I have a photo gallery that saves image info(url, name, date modified...) from the hard disk into an in memory collection. The thing is i want to have the image width/height stored into that collection. I can get it for each file using the Drawing.Image class. But considering the gallery can get quite big, creati...

A HttpModule that doesn't work in IIS7

I have a HttpModule that redirects certain URL:s in an ASP.NET WebForms application. It works on my machine with the ASP.NET Development Server. But when I upload it to our Win2k8 server with IIS7, it doesn't seem to react at all. I've put the <add name="Test.Web" type="Test.Web.Core.HttpModules.RedirectOldUrls, Test.Web" /> in the syste...

Save JPG in progressive format

<Extension()> _ Public Sub Save(ByVal b As Bitmap, ByVal FileName As String, ByVal Compression As Long, ByVal MimeType As String) Dim Params As EncoderParameters = New EncoderParameters(2) Dim CodecInfo As ImageCodecInfo = GetEncoderInfo(MimeType) Params.Param(0) = New EncoderParameter(Encoder.RenderMethod, EncoderValue.Rend...

What are some common scenarios where delegates should be used?

I understand how delegates and events work. I can also imagine some common scenarios where we should implement events, but I’m having harder times understanding in what situations should delegates be used. thanx REPLYING TO USER KVB'S POST: a) You can basically use delegates wherever you would otherwise use a one-method interfa...

How to redirect a System.Windows.Controls.TextBox input to a stream?

I tried: private void textBox1_KeyDown(object sender, KeyEventArgs e) { streamWriter.Write(e.Key.ToString()); } But I don't know how to convert a Key to string correctly. I also tried: private void textBox1_TextInput(object sender, TextCompositionEventArgs e) { streamWriter.Write(e.Text); } But this event is not called. The...

What is the better approach to compare a collection with another (architecturely speaking) ?

Here's an example of the architecture approach I favorited as for now: public abstract class CollectionComparer { public virtual SetEqual(IEnumerable enum1, IEnumerable enum2) { if(enum1== null && enum2== null) return true; if(enum1== null && !(enum2== null)) return false; if(!(enum1...

Set WinForms RichTextBox as the source of a PrintDocument

I want to print the contents of a RichTextBox, so I am trying make a PrintDocument out of the RichTextBox. But I dont find a way to convert a simple RichTextBox to a PrintDocument. Any ideas? ...

Need to convert an object to XML and getting an error

I have this class: <Serializable()> _ Public Class Bonder ''' <summary> ''' General information ''' </summary> ''' <remarks></remarks> Public BonderName As String Public Serial_Number As String Public System_Type As String Public DM_Version As String Public RTS_Build As String Public RTS_Lab...

Set MaxAllowedContentLength/maxRequestLength value per action.

How do I set maxAllowedContentLength value per action? I have a few actions that used to upload files, each one needs a different maxAllowedContentLength value. It make sense that we don't want to use action filters as we want to filter this request at IIS level. On the other hand, action filter is the best solution from coding perspec...

Getting started working with XML in .NET

I've been given a collection of related xsd files and a spreadsheet with xpath information in it. I need to create an xml file conforming to the schema files and populate it with data from a database.This will be my first time delving into the XML classes in the .NET framework. Which classes will help me get to my destination the quicke...

Visual guide to System.Windows.SystemColors

All throughout the Windows UX Guide it is suggested to use the appropriet SystemColors within an application to ensure that an application's default theme is consistent with teh rest of the system. I totally aggree, the only problem is that there seems to be no guide for how named values within the SystemColors type map to actual common ...

Interface Inheritance: Method does not show up!

I've got an interface inheritance issue that has been vexing me for some time. It doesn't seem to make any sense, and I can only conclude that I'm missing something fundamental. Overview The code below is from part of a fluent interface for our ORM tool. It provides a SQL-like syntax for pulling data from the database. You don't have t...

How to avoid using Enums?

Until asking a question on here I never considered (enums) to be a "bad thing." For those out there that consider them not to be best practice, what are some approachs/patterns for avoiding their use in code? Edit: public Enum SomeStatus Approved = 1 Denied = 2 Pending =3 end Enum ...

Remove another program's frame/window/border (the Aero bit) using VB.NET

Is there a way to remove the border/frame (the Aero bit) of another application's window (say notepad) from a VB.NET program? ...

Domain Driven Design: Domain Service, Application Service

Can someone explain the difference between domain and application services by providing some examples? And, if a service is a domain service, would I put the actual implementation of this service within the domain assembly and if so, would I also inject repositories into that domain service? Some info would be really helpful. ...

.NET: Should executables be strong-name signed? What about private DLLs?

My application consists of three assemblies: a single EXE which references a couple of DLLs. The DLLs are private to my application - they are used only by this executable. Should these assemblies be given a strong name? FxCop suggests that they should - for all of the assemblies it currently produces: CA2210: Sign <assembly> with ...

Developing a new RESTful web service in .NET -- where should I begin? ASP.NET-MVC, WCF?

Exposition (short version at the bottom) The objective is to build a service that I will then consume via jQuery and a standards based web front-end, mobile device "fat-clients," and very likely a WPF desktop application. It seems like WCF would be a good option, but I've never built a RESTful service with WCF, so I'm not sure where to...

What is wrong with this loop

I'm using a loop condition to check if there is null value in the columns, then remove it. -Original author [STart:] For i As Integer = counter To dt1.Columns.Count - 1 For x As Integer = 0 To dt1.Rows.Count - 1 if some condition then something = true else something = false ...

How can I handle an entity with other entities as children over different application layers.

If I detach the context I loose all of the relationships and if I don't I can't save later because the entity's context is disposed... This is an example of my code Public Sub Save() Using ctx As HMIEntities = New HMIEntities ctx.AttachUpdated(Me) //I use this extension method that works fine if I detach in the get method...

DownloadFileCompleted event doesn't fire inside while loop c# .net

Hi Everyone, I'm a bit confused why the event doesn't fire when the file has downloaded. The file it self downloads perfectly fine. I'm assuming there is some error in the way I am using this, in that the event doesn't fire inside a loop. Thanks for any help anyone can give me class DownloadQueue { public List<string[]> Download...