.net

Enterprise Library 5 logging class name.

Hi, I'm trying to use the logging block of Enterprise library for our application and I'm wondering if there's a way for the logger to automatically log the Class name that it is called from? I could manually insert the class name in the message when calling logger.write but I want to know if there's another way of doing this. Thanks ...

Exchange Management Powershell with .Net Return Code

How can I get the return code from the following command: RunspaceConfiguration rsConfig = RunspaceConfiguration.Create(); PSSnapInException snapInException = null; PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException); Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsCon...

Code To Open Password Protected Excel File

Help! I have a password protected Excel 2007 file and I lost the password. Any code in .NET to open such a file? Basically, I would need just a snapshot of the contents of the file. Thanks. ...

Running an executable programmatically .NET

I would like to execute a program in .NET server side code. So far I have this: Process p = new Process(); p.StartInfo.FileName = "myProgram.exe"; p.StartInfo.Arguments = " < parameter list here > "; p.Start(); p.Close(); This is a console program. What happens is that console is opened and closed repeatedly wi...

PHP & MySql versus .net & sql server

We are planning to do a large application, and we are tented to do it in php and mysql, because of it cost, but this application might grow a lot, and the database engine could have thousands of connections per second, so I am not sure what technology could handle this volume better. I would like to know what technology I should use, and...

Multiple AppDomains: Keeping the Console Open

I have an integration test harness which launches a console exe several times, simultaneously, each in its own appdomain. As soon as any one of the console exe applications exits from its appdomain, it causes stdin, stdout, stderr to shutdown for all of the remaining console exe appdomains as well. That is, the console is closed even t...

What alternative frameworks for ASP.Net exist?

Ok so we all of course know of the big two frameworks built atop ASP.Net. Webforms and MVC. Are there any alternatives to these two big and Microsoft-made frameworks? I believe that OpenRasta had something extremely lightweight which was independent from both, but I'm not sure. Is there anything else like that though? The reason I as...

Matching an interface's ProperyInfo with a class's PropertyInfo

I use a method similar to the following to get some precomputed metadata related to a Type's properties. MyData GetProperty<T, U>(Expression<Func<T, U>> member) { // Get the property referenced in the lambda expression MemberExpression expression = member.Body as MemberExpression; PropertyInfo property = expression.Member as...

What am I missing that is making sql deploy not work?

Hi I am trying to use the package/publish sql in VS 2010. So I went through this tutorial http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&amp;l=EN-US&amp;k=k%28WEBAPPLICATIONPROJECTS.DEPLOYSQLWALKTHROUGH%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29&amp;rd=true I imported the connection string from...

Mono problems with cert and mozroots

I am using this command on my mono VM sudo mozroots --import --sync It appears to be getting the cert from this site. I then try to connect to my ssl site and i get the exception that the cert is invalid. I use firefox and see the cert was issued in 2010. I looked at that file and see the last time its been updated was 2009-05-21 12...

C#: DateTimePicker control's default timezone

What is the default timezone/kind for the DtateTime value of the DateTimePicker of the .NET. Is it UTC or the local time zone of the machine at the run time, or is the the timezone of the machine where my code was compiled? Or will it be ambiguous if not specified explicitly within the code? ...

Strategies for keeping a .NET alt-tab replacement responsive after a long period of non-use?

I'm working on a simple alt-tab replacement program. It's implemented in C# as a hidden WPF window that's brought to the foreground by a global keyboard hotkey. For the most part this works great, and the application window appears immediately after the hotkey is pressed. However, if it has been a long time since the user has activa...

Run managed code on secure desktop

I am working on creating an application which must interact with the user on the secure desktop (i.e. locked computer screen), but does not specifically provide authentication. From my research, it seems that the only way to get code running on the secure desktop is to use the Credentials Provider API. However, you can only write a crede...

Changing [Serializable] to [DataContract]

Hi, I have an existing set of classes that use the [Serializable] attribute. I need to expose them in a WCF service and so I need them to have the [DataContract] attribute. It works with just Serializable but then the properties get funny names like ...k__BackingField. These classes are also used elsewhere and I'm wondering whether I r...

How to calculate actual months difference (calendar year not approximation) between two given dates in C#?

Example: given two dates below, finish is always greater than or equal to start start = 2001 Jan 01 finish = 2002 Mar 15 So from 2001 Jan 01 to the end of 2002 Feb months = 12 + 2 = 14 For 2002 March 15/30 = 0.5 so grand total is 14.5 months difference. It's very easy to work out by hand but how do I code it ...

essential tools for .net programmer?

This question looks familiar with this: http://stackoverflow.com/questions/2187/essential-programming-tools, but I want to focus on .NET programming. Beyond Windows and Visual Studio, which tools are your daily-need to get your job done? Free, open-source code tools are preferred :) I've been using these tools: Resharper - top of its...

How to chop a continuous date range list into a list of financial year in C#?

Example: given a continuous list of date range List[0] = from 2001 Jan 01 to 2001 Aug 14 List[1] = from 2001 Aug 15 to 2002 Jul 10 Let’s assume that a financial year is from 1st of July to 30th of June (of next year) so the output should be AnotherList[0] = from 2000 Jul 01 to 2001 Jun 30 period: 2001 Jan 01 to 2001 Ju...

ASMX webservices with Silverlight Async confusion

I have a silverlight 4 web app that needs to communicate with a server by accessing the ASMX web service on the server. I have a list(yes, the array), of objects that I need to send(one by one) as a parameter to the service. However looping through the list and running the method(objecttosend); will not work because I need to send then ...

Is it possible to invoke on a waiting thread?

Hi, I have a situation where I would like to have the main thread waiting, while other threads can invoke on the main thread, without calling Application.Run. The following code shows what I try to achieve, except that the main thread and the data loading thread are causing a dead lock. static class Program { /// <summary> ...

Regex for (see question)?

Hi guys, Here is an easy one :) on REGEX I have this regex "^\\$?(\\d{1,3},?(\\d{3},?)*\\d{3}(\\.\\d{2})?|\\d{1,3}(\\.\\d{2})?|\\.\\d{2}?)$" which works on {100, $100, $100.15, $1,000, $1,000.15} and so on.... I want a simple Regex which works on numbers like : {100, 100.15} and thats all - no commas and currency symbols crap... T...