.net

Java/.NET - reusing values

Do we reduce memory consumption when storing a String value that we use very frequent ? As far as I know, every time we do a "some string" declaration, a new string is constructed, instead of using the address of an existing one with the same value. Am I correct ? (I am not talking here about improving the code maintainability) ...

What's .NET XML configuration file for?

I find some of the .NET execution files have accompanying .config file. For example, I have LINQPad.exe and LINQPad.exe.config. What's this LINQPad.exe.config for? <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> <runtime...

Why my custom control referencing a .NET wrapper cannot be designed?

Why I get the following error in the Visual Studio (2010) designer if a try to load the Form1 that hosts my custom control at design-time? Could not find type 'myCustomControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project h...

Correct way to deal with UAC in C#

I have an application (Windows service) that is installed into a directory in the Program Files folder. Alongside this application is another WinForms application that is used to configure the service (amongst other things). When it does configuration, it saves changes to a config file that lives alongside the service. When running on V...

Which Layer for Domain Events, EventHandlers, Dispatcher

Hello, I have been reading about Domain Events and have seen codes from Udi's implementation(http://www.udidahan.com/2009/06/14/domain-events-salvation/) ,Mike Hadlow (http://mikehadlow.blogspot.com/2010/09/separation-of-concerns-with-domain.html), Jimmy Bogard and Jason Dentler's implementation. All in All I like the idea of events....

Making State abbreviations from State Names

Is there built in .NET functionality for making state abbreviations out of state names? I know the function wouldn't be difficult to write, but I would assume that MS has thought of a more efficient way than the following x50: if statename.tolower = "new york" then statename = "NY" else if any other thoughts of making this more e...

how to return 404 not found from a wcf service?

hey there Once, to have a complete control over the head/body of HTTP messages - I use the Message class. To return some XML, for example, I call public Message ShowRunResults() { // some [OperationContract] implementation webContext.CreateTextResponse(result.ToString(), "application/xml", Encoding.ASCII); } The questi...

Is there a way to bind a DataTrigger to a template in WPF?

For example, if I have a border with a style like this: <Border> <Border.Background> <SolidColorBrush /> </Border.Background> <Border.Style> <Style TargetType="Border"> ...

Mono's equivalent to .NET Framework Debugging Control

The fusion workshop explains about the .NET Framework Debugging Control .ini file setting. I think this is only for .NET. Is there any equivalence to mono for debugging control? [.NET Framework Debugging Control] GenerateTrackingInfo=1 AllowOptimize=0 ...

How to set the file types in the coolite FileUploadField

I using coolite in my project. And upload files through the FileUploadField control. I have to add a filter for the file type, so that the user could see only jpeg and bmp files from the choose file dialog. Havent found how this can be implemented in the web. Can anyone give me a hint on this one? ...

Running application compiled with visual studio 2008 on .net 4 computer

Hi, I've compiled an application with vs 2008 and .net framework 3.5. I tried to run this application on computer with only .net framework 4 (.net framework 3.5 is not installed) and I've got an error (says that it can't load the assembly ....ServiceModel.... version 3.0). After installing .net framework 3.5 SP 1 it works. I have foun...

.NET 4 Content Based WCF Routing vs. .NET 3.5 Compact Framework

Hi all, I consider using .NET 4.0 Content Based WCF Routing. Currently I have a normal .NET 3.5 WCF Server. All Clients uses the compact framework .NET 3.5. Could there be a problem, if I will port my WCF Server to .NET 4.0? Thanks for your answer. Kind regards, pro ...

Coalesce operator in C#?

I think i remember seeing something similar to the ?: ternary operator in C# that only had two parts to it and would return the variable value if it wasn't null and a default value if it was. Something like this: tb_MyTextBox.Text = o.Member ??SOME OPERATOR HERE?? "default"; Basically the equivalent of this: tb_MyTextBox.Text = o.Me...

Accepting a HTTP Post request in Azure

Hi If in Azure I wanted to write an application that accepted an XML file via HTTP Post, should I use WCF or just create a asp.net (web role) to accept the input? Thanks Steve ...

Generate .config file automatically using .NET configuration on Windows 7/Mono

This site explains about searching assemblies using .config file that has relative search path. I couldn't find the .NET configuration utility on Windows 7, so I just copied the config file to see it works. But I wonder why I can't find the .NET configuration tool in Windows 7. Where is the .NET configuration utility or equivalent i...

How to properly implement a custom control that handles mnemonics?

I am implementing a custom control in WinForms. This control needs to respond to a mnemonic character, and the mnemonic needs to focus the next control in the tab order - like a Label control does. The ProcessMnemonic method is clearly the one to override. However, looking at how the Label control does it, for reference, shows that it r...

.NET Can I wait for a specific background thread finish, then another background thread starts?

thank you for the asnwers ...

Generating Interface Proxies

Hello, Ran into an issue with a class; I have a class that looks like: public class MyPresenter { public MyPresenter(IMyView view) { } } public class SomePresenter { public SomePresenter(ISomeView view) { } } The custom views inherit from a base IView instance. I ran into a situation where I need to create a custom class on...

Getting started with JSON in .net and mono

I would like to keep a custom configuration file for my app and JSON seems like an appropriate format*. I know that there are JSON libraries for .NET, but I couldn't find a good comparative review of them. Also, my app needs to run on mono, so it's even harder to find out which library to use. Here's what I've found: JSON.NET JSONSh...

Handling Known Errors and Error Messages in a Method

What are some good ways to handle known errors that occur in a method? Let's take a user registration method as an example. When a user is signing up, a method SignUp( User user ) is called. There are a few known errors that might happen. Email is already registered Username is already registered Etc You could throw specific excepti...