.net

How is the best way to convert Action<T> to Func<T,Tres>?

I have the functions in my class with this signatures, public static TResult Execute<TResult>(Func<T, TResult> remoteCall); public static void Execute(Action<T> remoteCall) How can I pass the same delegate in the second method to the first one? Creating method with Delegate argument is not a way, because I am loosing some exception i...

ListBox as Numeric UpDown control in WPF.

One of the disadventage I found in WPF is it doesnot have a Numeric UpDown control. So I make a listbox with height as 25 so that it will display only one item at a time and the vertical scroll feels like a UpDown controls. My problem is when I use the scroll to change the value, I can't get the current value shown in listbox. Can any i...

Entity Model does not load

Whenever i try to open my Entity Model, i get a not very helpful error message stating that "the operation could not be completed". So unfortunately i don't have more specific information. However, i have other models that open just fine, and i didn't make any significant changes to the model, other than renaming entities. Are there any...

Should I use Screen.PrimaryMonitor or Screen.AllScreens for setting Form.Location?

As the question suggestions, should I be checking the Rectangle to set a Form.Location (which is taken from a Settings file) based on: 1. if (settings.X < Screen.PrimaryScreen.WorkingArea...) { // Set the form's Location based on the settings object } or 2. int width = 0; foreach (Screen screen in Screen.AllScreens) { width ...

Monte Carlo simulation in forecasting?

I am a physicist. Also i have some information about Monte Carlo simulation. i want to learn financial forecasting with Monte Carlo. Do you have any idea? What do you think financial decisions programming ? How is the future of financial software with Monte Carlo Simulation? ...

Pros and cons of 'new' properties in C# / .Net?

Considering the following sample code: // delivery strategies public abstract class DeliveryStrategy { ... } public class ParcelDelivery : DeliveryStrategy { ... } public class ShippingContainer : DeliveryStrategy { ... } and the following sample Order class: // order (base) class public abstract class Order { private DeliveryStr...

Want to serialize/deserialize object to/from XML - is it a good idea to specify tags as string constrants?

I have a class that I want to have opportunities to serialize/deserialize. It implements interface IXMLConvertable: public interface IXMLConvertable<T> where T: new() { T deserialize(XElement element); void serialize(XElement element); } when T is a type of object to deserialize. The question is whether it`s a good practice or...

How to get temporary folder for current user

Hi, Currently i am using following function to get the temporary folder path for current user: string tempPath = System.IO.Path.GetTempPath(); On some machines it gives me temp folder path of current user like "C:\Documents and Settings\administrator\Local Settings\Temp\". On some machines it gives me system temp folder path like "C:...

How can I get System.Type from "System.Drawing.Color" string

I have an xml stored property of some control <Prop Name="ForeColor" Type="System.Drawing.Color" Value="-16777216" /> I want to convert it back as others System.Type type = System.Type.GetType(propertyTypeString); object propertyObj = TypeDescriptor.GetConverter(type).ConvertFromString(propertyValueString); System.Type.GetType("...

WCF Service Call Wrapper

What is best practice for creating wrapper for WCF service call? I think it is necessary to monitor all calls in the same place, I am thinking to use this kind of code, is this right idea? RetType t = ServiceExecutionContext<IServiceChanel>.Execute(s=>s.GetServiceMethod()); What kind of wrapper are you use in your enterprise applica...

Is there an easy way to output a human readable object graph (specifically for an exception)

I have a unhandled exception handler (an oxymoron if ever there was one) but I'd like to get more information out of it. At the moment it logs the exception message, stack trace etc. and recursively does the same for any inner exceptions. However often the exception is a derived type of the exception class and therefore I do not know a...

What is the meaning of Default/NativeImage in fuslogvw?

I occasionally use fuslogvw to track down problems loading assemblies. After all my time of using it, it seems that the folder 'NativeImage' has results for loading native images of my dlls. When the native image is not found (usually its not), I think it then looks for a .net assembly. The 'default' folder is what I normally care abo...

In .net how to find the simple path to a element node

Given: a xmlnode that you got from calling the XmlDocument.GetSingleNode method, where you know that the node is an element, if you want to find the simple path to that element, is there something more straightforward than climbing the tree til you get to the root node and buildling the path as you go? Not that that's hard, I just w...

Is the C# '??' operator thread safe?

Everyone knows that this is not thread safe: public StringBuilder Builder { get { if (_builder != null) _builder = new StringBuilder(); return _builder; } } What about this? public StringBuilder Builder { get { return _builder ?? (_builder = new StringBuilder()); } } ...

Windows - Can console output inadvertently cause a system beep?

I have a C# console application that logs a lot to the console (using Trace). Some of the stuff it logs is the compressed representation of a network message (so a lot of that is rendered as funky non-alphabetic characters). I'm getting system beeps every so often while the application is running. Is it possible that some "text" I am wr...

How can I use the .NET 2.0 XSLT engine from a .NET 1.1 application?

I'm working on a .NET 1.1 assembly that does a number of huge XSL transforms. This is beginning to cause memory problems. I therefore want to use the XSLT engine in the .NET 2.0 framework, since I know it is much more efficient and less resource intensive. Note: Upgrading the .NET 1.1 assembly to .NET 2.0 is NOT an option at this time, d...

If statement within Lambda function?

This may be quite simple but I'm rather new to Lambda's so bear with me. I have a function that uses a Lambda function to recurse. The main function receives a bool telling it to include certain information or not within the lambda. The function is designed to write out a custom class to XML - I think the code is pretty self explanitor...

.NET Add-in to get Project that is being built

Hello. I've created a .NET Add-in that is supposed to do something when a project is being built. I know there are several ways to build a .NET project a) Hitting F5 button b) From Build menu c) From Debug menu ( by debug-ing ) d) By building the solution ( builds the project checked for 'Build' in solution properties ) e) By right-clic...

Open Source .Net Authentication Libraries?

I'm building a website and I'd like to avoid using asp.net membership. I want to consider some alternatives before I decide to write this code from scratch. Are there any open source projects that tackle the authentication problem? note: I need user/pass auth (can't use Open Id). ...

.NET Framework 3.5 SP1 Language Pack ClickOnce package

Visual Studio 2008 SP1 doesn't provide any language pack prerequisite for the .NET Framework 3.5 SP1. My research results are: it should be easy to create a custom bootstrapper package that installs a language pack. I've downloaded the Bootstrapper Manifest Generator. It's really a nice tool to create custom packages, but I don't know w...