.net

Different HTML, Same Codebehind & Same Controls

Hi, I am building a website which allows people to send out emails to people with a choice of different templates. When they have set-up their email and chosen a template the user can preview it. At present this loads up the corresponding aspx page to the template selected. I currently have 3 templates but expect this to grow substanti...

What is the best practise for storing database connection details in .NET?

This might be a duplicate (question) but I am looking specifically for the .NET best practise. How to store database connection strings, username and password etc. in a safe way? Is an encrypted app.config best in most cases? I would also like to be able to set the password in the config file and then have it encrypted as soon as the a...

How to call a web service with no wsdl in .net

I have to connect to a third party web service that provides no wsdl nor asmx. The url of the service is just http://server/service.soap I have read this article about raw services calls, but I'm not sure if this is what I'm looking for. Also, I've asked for wsdl files, but being told that there are none (and there won't be). I'm usi...

Windows Activation Service on Windows 2003

I know (Windows Activation Service) WAS is advertised as part of Windows 2008/Vista/7 but since it appears under .NET 3.5 framework components in Control Panel Windows Components, I was wondering if anyone knows/has managed to run in under Windows 2003 as well. I'm trying to host a WCF server in WAS under Windows 2003 (written in .NET ...

How to validate format string

We have lots of strings in our resource files that contains format .e.g “{0} has moved to {1}” These strings are passed to String.Format() by the applications, sometimes the translators mess up the “formatting markers” Therefore I wish to find/write a tool that checks that all strings in the resource file has a valid format. ...

DateTime string parsing

Hi, I have made a generic parser for parsing ascii files. When I want to parse dates, I use ParseExact function in DateTime object to parse, but I get problems with the year. The text to parse is i.e. "090812" with the parseExact string "yyMMdd". I'm hoping to get a DateTime object saying "12/8-2009", but I get "12/8-1909". I know, th...

.NET: Problem with raising and handling events using AppDomains

Here is the basic gist of my problem: My main Window class instantiates Class A. Class A instantiates Class B in a secondary AppDomain. Class B raises an event and Class A handles the event successfully. Class A raises an event of its own. Problem: In step 4, when Class A raises its own event from the event handler method that caught...

Best equivalent VisualStudio IDE for Mac to program .NET/C#

I'm using my Mac most time at work. At home there's my Windows Computer, where I program with Visual Studio my .NET/C# stuff. Because I want to program outside, it would be great to have an equivalent IDE for my Mac. Which software are the best solution in my case to have a similar workplace with the same functionality? I prefer OpenS...

Should I use public properties and private fields or public fields for data?

In much of the code I have seen (on SO, thecodeproject.com and I tend to do this in my own code), I have seen public properties being created for every single private field that a class contains, even if they are the most basic type of get; set; like: private int myInt; public int MyInt { get { return myInt; } set { myInt = v...

How to center a div wrapped with panel in asp.net?

Hi, I created a div(search result term bar) which should display only when user enters a search term and it should appears in center of the layout. See the screen shot 1) before and 2) after to get a clear idea. I used the css style like below search_list{ margin:0 auto; width:1000px; } So that i appears center in all resolutions. ...

Do not fill DropDownList if upstanding UserControl isn't visible

I have page Add.aspx containing a number of UserControls: AddRequest.ascx, AddOperation.ascx, AddObject.ascx, etc. Depending on Request["type"] one control becomes visible. Each UserControl contains a number of DropDownLists that are being filled via SqlDataSource from DB. For example, types, statuses, currencies, etc. It seems that ap...

Best Practices for handling Error Strings

In my vb.net application if I have a known set of Error Strings i.e. Failed because I don't know about it Failed because I know about it but I can't find it Failed for another reason etc And I get a response which I want to ensure doesn't have the error string in it If returnedString.equals("Failed because I don't know about it")...

Construct string with multiple fonts

I need to add strings coming from different RichTextBoxes with different fonts into one RichTextBox retaining the original fonts (more typically sometime I get XML format where fonts for substrings is defined.) Is there a way of constructing this string in memory and then simply puting it in a RichTextBox? If not, is there any other wa...

Overloads in COM interop (CCW) - IDispatch names include suffix (_2, _3, etc)

I have a managed assembly containing a few classes, and those classes have overloaded methods. I expose the assembly to COM/IDispatch callers via [ComVisible(true)] ..and also setting the proper Guid, on the assembly itself. I do not define an explicit interface for the COM interop. It's all done dynamically. I run regasm.exe /codeb...

Threadsafe and generic arraylist in c #?

Hello community, I want to have a generic thread safe collection and I saw that the Arraylist can easily be used thread safe by its static Synchronized method but what bugs me is that this ArrayList is not generic so when I want to use my objects I always have to cast them. Is there an easier way to do this? Also other list types would ...

Best way to manipulate Windows ACL permissions

My goal is to find out how to programmatically adjust permissions on files & directories in Windows using .NET. I have identified the following options: Windows API (yuck!) Active Directory Service Interfaces (COM... ugh...) Windows PowerShell (?) Google for an easy-to-use facade. None of these seem very palatable to me. Which route...

C# application terminates unexpectedly

We run a C# console application that starts multiple threads to do work. The main function looks something like this: try { DoWork(); } catch (Exception err) { Logging.Log("Exception " + err.ToString()); } Logging.Log("Finished"); The DoWork() function re...

IIS 6 Application mapping default settings

This is related to another question I asked last week, but the current issue is more IIS-centric. As a workaround to correct the issue, I removed the wildcard mapping for the web application (which was set to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll) I would like to be able to add back this wildcard setting (as th...

[net]how to inject debugging code to an assembly?

Given an assembly with an entry point like: int FooClass::doFoo(int x, double y) { int ret; // Do some foo return ret; } Is it possible to use yet another assembly to simulate something like: int FooClass::doFoo(int x, double y) { int ret; TRACE_PARAM_INT(x) TRACE_PARAM_DOUBLE(y) // Do some foo TRACE_RETURN_IN...

How to subscribe to an event dynamically using anonymous methods?

I'm creating a number of UserControls dynamically using LoadControl(String) and want to subscribe to an event of each of them. All my controls inherits a common Interface that require an implementation of a common Event: public interface IObjectProcessor { event EventHandler<ObjectProcessedEventArgs> ObjectProcessed; } So I do next ...