.net

Can I develop a .NET application in Windows and deploy versions for Linux and Mac?

Is this possible with, e.g., MonoDevelop perhaps? ...

Creating read-only versions of classes in a complex object structure

In my current project I need to be able to have both editable and read-only versions of classes. So that when the classes are displayed in a List or PropertGrid the user is not able to edit objects they should not be allowed to. To do this I'm following the design pattern shown in the diagram below. I start with a read-only interface (I...

Mono WCF InstanceContextMode not working

I have a service that looks like this: [ServiceContract(SessionMode = SessionMode.Required)] public interface ILabListener { [OperationContract] byte[] GetChallenge(); ... ... [ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerSession)] class LabListener : ILabListener { ...

How to effectively manage/host many WCF services for an SOA

My current architecture is a nice fit for SOA. The services are written using WCF, and everything is .NET (no interoperability required). To start off with I was hosting the WCF services inside a Windows Service with ServiceHost. But now the number of services is growing and I am reconsidering the choice to have them as separate Windo...

What isn't my TimeSpan.Add() working?

There has to be an easy answer: var totalTime = TimeSpan.Zero; foreach (var timesheet in timeSheets) { //assume "time" is a correct, positive TimeSpan var time = timesheet.EndTime - timesheet.StartTime; totalTime.Add(time); } There's only o...

My T-SQL query needs additional SUM's from an additional table...

The following is my current query. It works the way i want it to. However, it needs some improvements so that i can 1) retrieve the SUM's of the money columns in my 'expenses' table and 2) add a WHERE clause (or HAVING?) so that all of the SUM's are year-to-date values, e.g. any amounts prior to Jan. 1, 2010 will not be totaled by the SU...

How can one get a ContextMenuStrip to show on left click of a NotifyIcon?

I have a ContextMenuStrip assigned to a NotifyIcon and this works with the right click fine. How may I wire up the mouse-click event to tell the NotifyIcon to show its ContextMenuStrip? private void taskbarIcon_MouseClick(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: // What ...

how to load text as html using Html Agility Pack

<table class="\"matches \"> <thead> <tr class="\"sub-head\"> <th class="\"day\"> Day<\/th><th class="\"date\"> Date<\/th><th class="\"team team-a\"> Home team<\/th><th class="\"score-time\"> Score\/Time<\/th><th class="\"team team-b\"> ...

Why is PadLeft not working?

I have the following code: string foo = "blah".PadLeft(4, ' '); But when I check it, instead of foo being "____blah" (with 4 spaces at the start), it's just "blah". Why doesn't PadLeft do what I expect? ...

Dynamically Invoke Web Service At Runtime

I am using the sample code to dynamically invoke a web service from this site: http://www.crowsprogramming.com/archives/66 The issue that I am facing is when I use the Class to call a web service from a web application I get the following error: "The remote host cannot be found" and the error happens at the following line of code: if (!...

Would it make sense to have two GUI threads for two independent forms?

At work we've got a very CPU-intensive Windows Forms application. It's running on a server with 24 cores. As the Windows Forms model involves a single GUI thread processing a message pump, it seems that a rich, complex GUI is not making good use of the capabilities of the system. Am I wrong in saying this? So my coworkers were discussi...

Threads, queue and workflow

(As justification - I've never worked with threads so the description below is just an idea I want you to criticize) The task overview: - There is a list of some Objects - We need to check if the object has been changed in some way - If it was changed - apply some logic (for example - show notify). This is how I think it should be impl...

StructureMap singletons varying by argument?

Using StructureMap, is it possible to have a singleton object for each value of an argument? For example, say I want to maintain a different singleton for each website in a multi-tenancy web app: For<ISiteSettings>().Singleton().Use<SiteSettings>(); I want to maintain a different singleton object corresponding to each site: ObjectFac...

Method overloading - good or bad design?

I like to overload methods to support more and more default cases. What is the performance impact of method overloading? From your experience, is it advisable to overload methods? What is the limit? What are the workarounds? ...

Algorithm to generate a random number? Don't use System.Random

Had there been no System.Random class, how would have you generated a random number? Are there any known algorithms or have you guys ever designed one? ...

Run command line program silently with c# on wince

Hey everybody, I once again need some help. I'm using the .net Compact Framework and the programming language C# to develop for mobile devices that are running WinCE 5.0. What I want to accomplish is to programmatically mount a network drive. To do so, the app runs the following code in a background thread: ProcessStartInfo startInfo...

DataBound ListBox and Button inside a ScrollViewer/StackPanel construct, with Button appearing below end of ListBox content.

I have the following construct, which shows a DataBound ListBox and a Button inside a StackPanel, which again is placed inside a ScrollViewer: <ScrollViewer VerticalScrollBarVisibility="Visible" Height="400"> <StackPanel Orientation="Vertical" MaxHeight="400"> <ListBox x:Name...

Can LINQ To SQL used for other database (MySQl, Oracle, etc)

I have project creating with WPF and for database O/RM using LINQ to SQL, when i finish my project some people want to use MySQL as database, so can I change my Linq to MySQL without change any source code (maybe just change the connection string) Regards ...

How to make my project runnable on any system?

I have developed a solution in Visual Studio 2008 C# WPF! I'm using a service-base SQL database (I've created and managed using Microsoft Visual Studio Sever Explorer), now I'm going to publish it but the problem is that when I install .NET Framework 4.0 and SQLEXPRESS 2005 on other systems, my application doesn't launch! :-( What compon...

Why doesn't IEnumerable<T> implement Add(T)?

Just now find it by chance, Add(T) is defined in ICollection<T>, instead of IEnumerable<T>. And extension methods in Enumerable.cs don't contain Add(T), which I think is really weird. Since an object is enumerable, it must "looks like" a collection of items. Can anyone tell me why? ...