.net

Associate attribute with code generated property in .net

I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file. I have this field: public virtual string Name { get; set; } I wish to set this: [ValidateNonEmpty("Name is required", ExecutionOrder = 1)] public virtual string Name ...

.NET Remoting: how to access server application objects from remotable object?

Hello! I'm writing a windows service application, which will be accessed through .NET Remoting. The problem is I can't figure out how to access service objects from remotable class. For example, I've a handler class: class Service_console_handler { public int something_more = 20; //some code... TcpChannel serv...

C# Application - Should I Use Stored Procedures or ADO.NET with C# Programming Techniques?

I have a C# Application I am creating that stores all data in SQL Server. Sometimes it's easier for me to make data changes programmatically and sometimes it's easier to have stored procedures and functions in the SQL Server database and call them. I am rather new to programming and I don't know what the subtle advantages and/or disa...

How does LINQ defer execution when in a using statement

Imagine I have the following: private IEnumerable MyFunc(parameter a) { using(MyDataContext dc = new MyDataContext) { return dc.tablename.Select(row => row.parameter == a); } } private void UsingFunc() { var result = MyFunc(new a()); foreach(var row in result) { //Do something } } According to the do...

TypeLoadException on x64 but is fine on x86 with structlayouts

Youll need a 64bit machine if you want to see the actuall exception. I've created some dummy classes that repro's the problem. [StructLayout(LayoutKind.Sequential, Pack = 1)] public class InnerType { char make; char model; UInt16 series; } [StructLayout(LayoutKind.Explicit)] public class OutterT...

I would like to use PostrgeSQL with .NET. How do I go about it?

I am working on a small practice project in .NET with Sql Server 2005. I want to learn PostgreSQL and implement my project in PostgreSQL in the final version. Please advise on all the things I need to do, to setup PostgreSQL with .NET and run it successfully. Sincere thanks fsck. ...

WebClient vs. Proxy Settings - or fun with Download Accelerators

I have a relatively simple feature that uses the WebClient class to perform an HTTPS POST to a web server. This code works reliably but encounters problems when using the EarthLink or AT&T download accelerator feature. The download accelerator works by changing the dial-up connection's proxy settings to specify localhost:8080 for th...

What conventions/idioms/patterns are you using configuring IOC Containers using the new Fluent Interfaces

I am in the middle of moving over a large body of code to Castle Trunk which includes the new fluent interface for configuring the container. Since the project has a huge windsorConfig xml file that is beyond maintainable, I thought I would start to take advantage of this new feature. I know other containers (e.g. StructureMap 2.0) also ...

How do I set the time out of a socket.connect() call?

I have an app that connects to a host that might be down. If the host is down I don't want to wait for the 30 or so seconds it takes to time out. I'm using blocking sockets at the moment. I've been looking at socket.poll() and socket.select() but I'd rather just have a time setting on the socket. I don't mind if it's a setting I have to...

Howto undo ChangeSet in LINQtoSQL

Hi, in my data layer class I have created a function to manually refresh the data source. Public Sub DiscardAllChanges() _Context.Refresh(RefreshMode.OverwriteCurrentValues) End Sub The problem is that the context ChangeSet after this operation still trace the previous operation of Insertion, Deletion and Update that I made call...

How do I get the correct ClientID for my ASP.NET TextBox?

I have created a a subclass of Table in my ASP.NET project which creates. The table uses a class that formats and creates TableRows and TableCells which we can call RowCreator. So MyTable calls rowCreator.CreateRow() and gets back a TableRow with a lot of goodies in it. In this TableRow there is a TextBox which is supposed to trigger a ...

How to inherit a class from an assembly without forcing users to reference two assemblies

I have two classes A and B in two different .NET assemblies: AssemblyA and AssemblyB. I want class B to inherit class A but I want that however uses class B to only need to reference AssemblyB (and not both AssemblyA and AssemblyB). Due to the project constraints I need to keep the two assemblies separate so I cannot use merge tool to ...

Strange behaviour of .NET binary serialization on Dictionary<Key, Value>

I encountered a, at least to my expectations, strange behavior in the binary serialization of .NET. All items of a Dictionary that are loaded are added to their parent AFTER the OnDeserialization callback. In contrast List does the other way. This can be really annoying in real world repository code, for example when you need to add som...

C#: How to convert BITMAP byte array to JPEG format?

How can I convert a BITMAP in byte array format to JPEG format using .net 2.0? ...

Async Method Call

How can I call a method asynchronously ? ...

.NET 1.1 and .NET 2 config files working together

I have inherited a rather large project consisting of an application written in VB6 and several DLL's and ActiveX controls written in VB6, VB.NET 1.1 and VB.NET 2. I want to change one of the settings for one of the DLL's written in VB.NET 2 that is in its application.dll.config file, but it seems to be having no effect. My main VB6 app...

Best Peer Code Review Software

Following on from my query Here, does anyone know of any good Peer code review software? I am aware of Smart Bear's Code Collaborator (albeit a very expensive option) but can anyone recommend any tools that they use? ...

What is wrong with my custom thread pool?

I've created a custom thread pool utility, but there seems to be a problem that I cannot find. using System; using System.Collections; using System.Collections.Generic; using System.Threading; namespace iWallpaper.S3Uploader { public class QueueManager<T> { private readonly Queue queue = Queue.Synchronized(new Queue()); private...

How to measure code performance in .NET?

I'm doing some real quick and dirty benchmarking on a single line of C# code using DateTime: long lStart = DateTime.Now.Ticks; // do something long lFinish = DateTime.Now.Ticks; The problem is in the results: Start Time [633679466564559902] Finish Time [633679466564559902] Start Time [633679466564569917] Finish Time [63367946656456...

A Visual Studio 2008 automated tests project can read a configuration file like app.config? (C# .NET)

I have an app.config file inside my TestProject, but when I try to read it using ConfigurationManager it reads from somewhere else and it's none of my app.config's. How to correct this? Current config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="Production" connectionString="Server=127.0...