.net

Will conditionals that are always false be removed by compiler in C#

Say I have the following code snippet in c# static const bool DO_PERFORMANCE_CODE = false; if (DO_PERFORMANCE_CODE) { // performance monitoring code goes here } Will that code get removed by the compiler? This is the functionality I'd like. Basically I want to mimic the conditional compilation stuff in C#, but I want more configur...

HttpListener.Start() AccessDenied error on Vista

Running this code as a regular user throws HttpListenerException (access denied). Snippet runs ok as an administator class Program { static void Main(string[] args) { HttpListener listener = new HttpListener(); listener.Prefixes.Add("http://myip:8080/app/"); listener.Start(); //.... and so on ...

PHP range() function in .NET?

I need to generate a list of sequential numbers. I know Ruby you can do 1..10 or PHP you can do range(1, 10). Anything like that in .Net already, or do I have to write it? Thanks. ...

C# Mono+Winforms MessageBox problem

I have a file called hellowf.cs class MyFirstApp { static void Main() { System.Windows.Forms.MessageBox.Show("Hello, Mono+WinForms!"); } } On Ubuntu 8.10, I do the following gmcs hellowf.cs -r:System.Drawing.dll -r:System.Windows.Forms.dll mono hellowf.exe ... and it looks like this: The second part of the message is m...

Log4Net works in main thread but not in created thread

In VS2008, C#, I've created a unit test (VS unit test) that calls some code which in turn calls Log4Net and logs some information. This works. If I create a thread in the unit test to call the same code I'm getting "Failed to parse config file" exception from Log4Net. Any ideas why it would not be able to parse the config file from the...

Drawing Pixels in WPF

how would I manage pixel-by-pixel rendering in WPF (like, say, for a raytracer)? My initial guess was to create a BitmapImage, modify the buffer, and display that in an Image control, but I couldn't figure out how to create one (the create method requires a block of unmanaged memory) ...

Why is the Chars property of the StringBuilder class missing in Visual C# 2008 Express?

That's pretty much the whole question. I've installed Visual C# 2008 Express on a clean Windows XP Pro SP3 machine, started a new Windows Forms project, double-clicked the form to create a Form1_Load method, then typed: StringBuilder SB; SB = new StringBuilder("test"); SB.Chars but Chars doesn't appear on the autocomplete menu. Why no...

Can a Programmer that is 'Smart' and "Gets Things Done" work in a foreign programming language?

Does it matter for a programming company manager if the programmers that come in know such technology like asp.net or ruby on rails, or it doesn't really matter as long as they're smart and get things done? I mean, specific technology is a matter of learning some new stuff, but it's still programming. Or do .NET technologies actually com...

Powershell Remote Commands

I'm trying to run the get-service command on a remote machine in powershell. After doing some research, it appears this is only possilbe n powershell 2 CTP, which I cannot use as I need to use the version of powershell installed with exchange, which is usualy 1. It seems the -computerName switch is only availible in get-service in ps 2....

Easiest way to validate and read an xml file in .net?

What is the easiest/simplest/cleanest way to: Read an xml file from the filesystem Validate the xml against an xsd Read parts of the xml file into variables Using .net. ...

What are the best functions, practices, and/or techniques to read/write XML with C#/.NET?

The question says it all... looking for the n00b overview w/ best practices. Thanks, -greg ...

How to prevent deadlocks in the following C# code?

The following C# class is used in a multithreaded enviroment. I removed very much of the actual code. The problem occurs when calling MethodA and MethodB almost simultaneously. The order of the lock in the IsDepleted property doesn't solves the problem. Removing lock(WaitingQueue) from the IsDepleted property solves the deadlock, but thi...

Can you use the asp.net membership provider in a windows application?

The Asp.Net membership provider has some clear uses in a web app. I am thinking about trying to leverage some of the features in a windows application (more specifically WPF). Does anyone know if it is possible to use the core features in a windows app? I am mostly just looking for it to create my database tables, and maintain users, ...

Are there any .NET data providers for Oracle that do not require the Oracle Client to be installed?

I am developing a rich client application that will use the Entity Framework (with DevArt's DotConnect for Oracle) to connect to a central Oracle database. However, I have found that this scenario requires every client machine to have the Oracle client installed in order to connect to the Oracle 10g server. Is there an easy way around ...

Making an application run in multiple zones

I am currently revising for exam 70-536. Is there a sample of how to configure an application to run in multiple environments? E.g. intranet and internet. I can't find a good code sample for this. Anyone have one? ...

How do I focus a foreign window?

I have an application which may only have one instance of itself open at a time. To enforce this, I use this code: System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); System.Diagnostics.Process me = System.Diagnostics.Process.GetCurrentProcess(); foreach (System.Diagnostics.Proc...

asp.net web application compile and deployed on x64 vs x86

My web application crashes almost once a week due to not enought memory error. Although server has 8gb of memory and it's server 2003 x64. And almost 5gb is always free. I compile my application with Any CPU option in studio 2008. My laptop that i use to build this has 32 bit vista. Is my web application running under x86 or x64? if ...

User32's ShowWindow doesn't act as expected

I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn't hide the window (and sometimes doesn't the f...

What is my Azure Table Storage AccountName?

I'm trying to move some table storage in Azure from local storage to the cloud. I had been using the "devstoreaccount1" for local access, but I'm not sure what I need to put there for moving to the cloud. It's not the user account I used to sign up for my Azure accounts, is it? That's just my email address, and that didn't seem to wor...

Loop through all elements in a ListView in virtual mode

I have a reporting module which creates PDF reports from ListViews. Now, I have a ListView in Virtual mode and therefore I cannot loop over the Items collection. How do I loop over all elements in the list view from the reporting module? I can get the VirtualListSize property, so I know how many elements there are in the list. Could I...