.net

How does Subsonic handle connections?

In Nhibernate you start a session by creating it during a BeginRequest and close at EndRequest public class Global: System.Web.HttpApplication { public static ISessionFactory SessionFactory = CreateSessionFactory(); protected static ISessionFactory CreateSessionFactory() { return new Configuration() .Configure...

f# whole number float modulus 1.0 = 1.0?

Ok I have two functions the first of which looks like so: let dlth x = float (x.ToString().Length) which takes a float and returns the number of digits, that part works fine. The second function looks like this: let droot x = ((x ** (1./(dlth x))) % 1.) which takes a float and raises it to a power equal to 1.0/(number of digits), ...

C# - Programmer Challenge for Interviews - Programming to an Interface & Patterns

What is a good simple problem to throw at Jr. and Mid level developers to to find out given the opportunity to Program to an Interface (like a simple Factory pattern) if they will do it? ...

Is there a difference between the following ways to register to event

I would like to register to some event. The following ways works: public void AddOptionAsListner(OptionElement option) { option.Selected += onOptionSelectedChanged; } public void AddOptionAsListner(OptionElement option) { option.Selected += new EventHandler(onOptionSelectedChanged); } Is there a differ...

Proper place for db connection in SOAP web service (.net)

I have an asp.net web site and a database. The web site has a web service for storing feedback from my software. As far as I know, IIS will reuse the created object for sequential requests. This gives a reason to connect to the DB in web service's constructor, properly implement Dispose() method, and use the connection for serving each...

Achieving State like pattern without having +3 entities? C#

Here is the design problem in pseudo example: It is ASP.NET User control (UC) which uses the "Food" object as data source and this object has property FoodType - "Veg" || "Nonveg". The user control changes UI display depending upon FoodType property. In code-behind class of User Control, some methods have same if/then/else condition: ...

Using a alternate XML DTD with a ASP.NET Web Service Application

I'm new to the .NET framework (and actually consider myself more of a sysadmin) but am creating a web service that needs to return data to another system. I was using the defaults from the ASP.NET Web Service Application project. The problem that I am having is I can't find a setting to use an alternate DTD. So by default the project...

ASP.NET 2.0 calling .NET 3.5 component

I have an ASP.NET 2.0 web site. I am building new functionality that is based on some features from .NET 3.5 (specifically Linq to Sql). Provided I have .NET 3.5 installed on web server (but keep my IIS Application as .NET 2.0) will I have any "issues" calling into the 3.5 assembly? Can anyone explain what happens under the covers whe...

very strange string unique issue in C#

Hello everyone, I am using VSTS2008 + C# + .Net 3.0. Here is my code and related exception from ADO.Net. Here is my input two strings in both binary form and text form, any ideas what is wrong? Why the two different strings will be treated as the same by ADO.Net? Exception message: An unhandled exception of type 'System.Data.Constrain...

.net Window Order

I have a project with multiple forms and when, for example, Form A opens Form B which opens Form C, then Form C is closed, Form B and Form A have gone to the back of the window order, so that whatever other programs are open are shown in front of these other forms in the project. Why is this happening and how would I go about making sur...

determine if blob is an image without loading entire field?

is there a way to read only a few bytes out of a BLOB type field in a database (for this question it doesn't matter the DB brand) and determine if the binary content is an image (assume it is one of: JPG, GIF, PNG)? I have a webapp that stores files in the database, and if it is an image, I want to show a thumbnail, otherwise I want to ...

Choosing Sharepoint save location for an InfoPath form

I have an InfoPath form template hosted as a Sharepoint content type. I want the user to be able to choose where in the Sharepoint site folder structure the form gets saved when they click submit. Is this possible, either by rules or custom .NET code? Thanks. ...

log4net initialisation

I've looked hard for duplicates but have to ask the following, no matter how basic it may seem, to get it clear once and for all! In a fresh Console app using log4net version 1.2.10.0 on VS28KSP1 on 64 bit W7, I have the following code:- using log4net; using log4net.Config; namespace ConsoleApplication1 { class Program { ...

Why is a const variable available within a static method?

I have been writing code without realizing WHY I can access constant values within static methods. Why is it possible to access const values without declaring it as static? E.g.) It's legal to call IMAGE_FILE_EXTENSION within AddImageToDocument(...) public abstract class ImageDocumentReplacer : DocumentReplacer { private const ...

Share data types between silverlight and other applications

If I want to define a class in a common assembly, to be utilized by both a silverlight application and an asp.net web application or other type of app, can I define the data type in a standard class library or should I use a silverlight class library? ...

WPF thread and GUI how to access object from different thread?

I have a thread that call an object that get some stuff from Internet. When this object is filled up with all information required, it raises an event with an object will all the information. The event is consumed by the controller that has started the thread. The returned object from the event is than added into a collection that is bi...

What are valid SQL functions for OLEDB provider for querying a text file?

Does anyone know of any documentation out there that lays out what SQL functions are supported for the .NET Microsoft.Jet.OLEDB.4.0 provider when querying a text file? For instance, the TRIM() function. However, there doesn't appear to be a CASE function like in SQL Server. ...

How to prevent multiple background repaint .NET winforms

Hi all, I have a background image stored in the database so instead of setting BackgroundImage property of the form I handle OnPaint event to draw the image on the background for each form. The problem is that each control on the form invalidates parent control - the form, so the OnPaint fires multiple times (12x). Even though the image ...

What is the best way to communicate between programs in .NET and why?

Our company keeps debating on whether we should be using custom API DLLs or creating a web service farm to have our programs to communicate data between themselves. To me web services make the most sense in regards to compatibility and flexibility of upgrading, but I have heard some good reasons to use DLLs as well. Is there an emerging...

UTC and Daylight savings scenario.

I am using UTC to store data and time values in the DB. The values are converted to localtime on the client or per client timezone. I stepped on these scenarios from the MSDN article, where displaying the time from UTC seems to pose issues during daylight savings. Someone living on the east coast of the United States types in a val...