.net

NAnt errors when generating assembly info after project is upgraded to VS2010

I have a project I recently upgraded to VS2010 - the project/solution files are updated, but I'm still targeting .NET 3.5. Until now, my standard NAnt build script has not given me any trouble. However, it appears that after updating the project, and updating the NAnt config to be aware of the new tooling, I am now receiving an error wh...

Determine if a server is listening on a given port

I need to poll a server, which is running some propriatary software, to determine if this service is running. Using wireshark, I've been able to narrow down the TCP port its using, but it appears that the traffic is encrypted. In my case, its a safe bet that if the server is accepting connections (i.e. telnet serverName 1234) the servic...

How do I create Dependency Objects that inherit the parent's data context?

Normally wpf objects inherits their parent's data context, so if you set a binding and theres no data context set, the binding engine it will automatically look for it in the parents. How can I make a custom class(that is not an UI element) to produce the same behavior when set as the child of another element? ...

Get remote PC's date time?

Is there any class available to get a remote PC's date time in .net? In order to do it, I can use a computer name or time zone. For each case, are there different ways to get the current date time? I am using Visual Studio 2005. ...

How can I programatically (using reflection?) change a method body and save my changes back to disk

I can get at the method body easily enough using reflection Type type = assembly.GetType("Lorem.Ipsum.Dolor.Sit"); MethodInfo methodInfo = type.GetMethod("Amet"); MethodBody methodBody = methodInfo.GetMethodBody(); How can I programatically change the method body and save my changes back to disk? ...

.NET timezone information

What is the standard format for datetime with timezone in a C# ASP.NET application? Updated to clarify: In ASP.NET I need to check a datetime from a Domino database against a .NET DateTime. The client is asking what would be the best format in which he should provide the datetime with the timezone. Meaning which format is most easily re...

Why does TrimStart trims a char more when asked to trim "PRN.NUL" ?

Here is the code: namespace TrimTest { class Program { static void Main(string[] args) { string ToTrim = "PRN.NUL"; Console.WriteLine(ToTrim); string Trimmed = ToTrim.TrimStart("PRN.".ToCharArray()); Console.WriteLine(Trimmed); ToTrim = "PRN.AUX"; ...

Layered Architecture and Static Methods

I need suggestion for three layered architecture I am planning to implement. Scenario Am Working in ASP.NET c# 3.5 Environment. DLHelper: Methods to get data from database. DAL : Contains Methods which collects data from database with help of DLHelper classes. Most of the methods in this layer are not referencing any page level objec...

How can I tell if a user is using a laptop

I need a way for my .Net Winform app to detect if my app is opened on a Laptop or a Workstation. I have looked at Environment and SystemInformation but to no avail. Would WMI do the trick? Thanks for the direction.... As requested I have an application that uses Merge Replication to allow our users to work in Members homes. Some...

Convert Lit to PDF using .NET

Hello everyone, I've ran across a bit of a problem and I'm hoping the community will be able to help. My wife uses an Ereader from Sony that does not support .Lit files. Her old Ereader did. We found a program to convert these .Lit to .PDF but it doesn't work well with 64 bit Windows 7. I'm trying to write a program in C# that would perf...

Sending a DataTable's content in an html email, what is the preferred way to generate HTML from a DataTable?

Sending a DataTable's content in an html email, what is the preferred way to generate HTML from a DataTable? ...

How to protect an imported Win32 DLL into a .NET application from memory issues

I have a C# application that needs to use a legacy Win32 DLL. The DLL is almost its own application, it has dialogs, operations with hardware, etc. When this DLL is imported and used, there are a couple of problems that occur: Dragging a dialog (not a Windows system dialog, but one created by the DLL) across the managed code applicat...

Opening my application when a USB device is inserted on Windows using WMI

I'm trying to launch an event when someone plugs in a USB device. For now, I'm content to simply print something to the console (in the finished product, it will launch an application). This code is very loosely adapted from: http://serverfault.com/questions/115496/use-wmi-to-detect-a-usb-drive-was-connected-regardless-of-whether-it-wa...

How to play multi sound?

using Microsoft.DirectX.AudioVideoPlayback; public static void playNote (string pass) { Audio myAudio = new Audio(pass); myAudio.Play(); } and to play sound I press button playNote("PianoDo#.wav"); This is the way I play sounds in my piano. Butif i press a lot of buttons for 30 sec my app starts la...

Which 3rd party Code-by-Contract library is most like MS's .NET 4.0 library?

I want to jump into coding by contract. I got VS2010 (with the C# 4.0 compiler) but I have to target the 3.5 framework. What 3rd party code by contract library has classes and interface the most like the .NET 4.0 ones? ...

Is there a way to do WeakList (think WeakReference) in CLR?

A List does not work in the way that I want. The way that I want is that WeakReferences are automatically removed from the list when the object they weakly reference is garbage collected. ConditionalWeakTable does not do what I want either, because although its keys and values are weakly referenced and collectable, you cannot enumerate ...

Can somebody recommend a CSV to Html Table Generator?

I need to parse a pretty simple csv file which represents 7 columns and 3 rows. Is there anything built into .Net to do this or should I do it manually? ...

Visual Studio add-in to quickly test a code snippet

One thing I really love about languages such as Python is that if you have a piece of code you'd like to try out, you can just open the interactive shell and do it in seconds. Is there a Visual Studio add-in that does the same for C#? Basically what I'm looking for is something that opens up a window or tab with a text editor (preferab...

How to use a dialog in an Excel shared addin

I'm writing a shared addin for Excel. It adds a CommandBarButton that when clicked opens a WPF window to collect some information from the user. I wanted to keep the same WPF dialog in memory and reuse it so that if the user clicks the CommandBarButton again their previous values would still be there. So I made a reference to my WPF di...

Serializing MDI Winforms for persistency

Hello, basically my project is an MDI Winform application where a user can customize the interface by adding various controls and changing the layout. I would like to be able to save the state of the application for each user. I have done quite a bit of searching and found these: http://stackoverflow.com/questions/2076259/how-to-auto-s...