.net

Best way to remove multiple items matching a predicate from a c# Dictionary ?

I need to remove multiple items from a Dictionary. A simple way to do that is as follows : List<string> keystoremove= new List<string>(); foreach (KeyValuePair<string,object> k in MyCollection) if (k.Value.Member==foo) keystoremove.Add(k.Key); foreach (string s in keystoremove) MyCollection.Remove(s); The re...

ConfigurationManager.AppSettings is empty?

Hello All, I have a VS2008 ASP.NET Web Service Application running on the local IIS of my XP machine. A separate project in the same solution uses test methods to invoke the WS calls, and run their processes. When I added a web reference to the WS App, VS2008 created a Settings.settings file in the Properties folder to store the addres...

Best way to parse DateTime to SQL server

I was wondering what is the best way to parse a DateTime object to your SQL server. Where you are generating the SQL in code. I have always used something like DateTime.Now.TolongDateString() and had good results, apart from today where i got a error, and it made me think. System.Data.SqlClient.SqlException: Conversion failed when ...

C# regex replace unexpected behavior

Given $displayHeight = "800";, replace whatever number is at 800 with int value y_res. resultString = Regex.Replace( im_cfg_contents, @"\$displayHeight[\s]*=[\s]*""(.*)"";", Convert.ToString(y_res)); In Python I'd use re.sub and it would work. In .NET it replaces the whole line, not the matched group. What is a quick...

How do I move service references to their own assembly?

A little background: I'm creating a set of adapters to allow communication with mobile devices over different cellular networks. This will be achieved using a class factory pattern. At least one of the networks requires a service reference to communicate with their devices through a web service. So far I've got 3 assemblies so far wh...

Does SqlDataAdapter.Dispose actually Close an associated SqlConnection?

Does anyone know if the SqlDataAdapter.Dispose method actually closes or disposes any SqlConnections? I loaded up Reflector and I see that SqlDataAdapter inherits from DbDataAdapter. If I disassemble and look at the dispose method in that class, there appears to be no disposal of any SqlConnections. I suppose I could write a test for ...

How do I create an automatic UI event trace in winforms?

I need to take an existing winforms application and drop into an event tracing mode, with hopefully as little friction as possible. I would like to see every action the user takes as a simple stack trace-looking thing: MainForm.LaunchThing_Click ThingWindow.NameInput_Focus ThingWindow.NameInput_TextChanged ThingWindow.AddressInput_Focu...

.NET form that preserves text fields across sessions?

Its a simple config app with 4 checkboxes and 5 textboxes, and all values must persist across sessions. do I have to serialize the fields and restore them by hand? I really have no idea the best way to approach this. ...

Best practice for SQLite with WPF and ASP.NET MVC?

What is the correct way to work with SQLite in WPF and ASP.NET MVC? In WPF, I have a test.sqlite file into a directory called App_Data but when I compile and run it, it doesn't copy the database into ../bin/Debug so of course it can't find it. But if I manually copy the test.sqlite file into ../bin/Debug, then it works. But this can't ...

What advantage does C++ have over .NET when it comes to to game development and apps like VirtualBox

This is an attempt to rephrase a question I asked earlier. I'd like to know why C++ seems to be the language of choice for certain thick client apps. The easiest example I can think of is video games and my favorite app VirtualBox. Please don't close this post I'm just trying to understand why this is the case. ...

WCF security mode is TransportWithMessageCredential using UserName, where to validate?

Hi, Here is part of my web.config for my WCF service: <bindings> <basicHttpBinding> <binding name="sslBinding"> <security mode="TransportWithMessageCredential"> <message clientCredentialType="UserName" algorithmSuite="Default" /> <transport /> </security> </binding> ...

Where are user-mode .NET settings stored?

Hi, I'm wondering what is the magic behind .settings files in .NET. Imagine you create an assembly called in this exemple SettingsHolder, you create your settings class which is public with a string inside in user mode , then you compile. Now you reference your assembly in MyApp, you compile then you can change the value in your applic...

Konami Code in C#

I am looking to have a C# application implement the Konami Code to display an Easter Egg. http://en.wikipedia.org/wiki/Konami_Code What is the best way to do this? Update 1 This is in a standard C# windows forms app. ...

Detect closed pipe in redirected console output in .NET applications

The .NET Console class and its default TextWriter implementation (available as Console.Out and implicitly in e.g. Console.WriteLine()) does not signal any error when the application is having its output piped to another program, and the other program terminates or closes the pipe before the application has finished. This means that the a...

display application icon on UAC elevation prompt for application run from network share

I have configured my .NET application using an application manifest to request administrator privileges. I have also signed the assembly using signtool. Everything works greatwhen you start the application, you get the nice UAC prompt with the application's name and the name of the signing certificate. However, when I run the applicatio...

Per version (1.0,1.1,2.0,3.0,3.5) how many classes are in the .NET framework?

Per version (1.0,1.1,2.0,3.0,3.5) how many classes are in the .NET framework? I am looking for the info for a presentation that I'm going to give for a class in my Master's program. ...

Command Line ( or equivalent) tools for .Net Development

Spending most of my time in Visual Studio and using all the IDE tools. I wish I could spend more time using either of the following. *the Command Window in VS *cmd *cygwin, minGW... *PowerShell. *scripts? What are your favorite and essential commands to type in, opposed to keyboard shortcuts or clicking around? ...

Calling Assembly to get Application Name VB.NET

Hi! I have a console application (MyProgram.EXE) that references a Utilities assembly. In my Utilities assembly, I have code that does: Dim asm As Assembly = Assembly.GetExecutingAssembly() Dim location As String = asm.Location Dim appName As String = System.IO.Path.GetDirectoryName(location) Conole.WriteLine("AppName is: {0}", appNam...

.NET Compact Framework GetHashCode(Object) equivalent

What is .NET Compact Framework equivalent for following method? Is there any P/Invoke call available? System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Object) I am in middle of an open source project port to .NET Compact Framework. ...

ObjectIDGenerator vs. HashSet<T>

Can anyone tell me how is ObjectIDGenerator better (worse?) then using HashSet when traversing an hierarchy of objects (that might be recurvise/circular), and not wanting to traverse the same object twice? ...