.net

One service appends to and another one truncates a file.

I have a service that controls an RS-232 device and logs actions to a file. I am to write another service which will read the log file line by line and run some queries on a database then delete all the logs. My concern is about read and write conflicts on the file. For example, the logger service open the file to append a new line at t...

Why does IPAddress constructor take Int64 instead of UInt32 ?

Why does IPAddress constructor take Int64 instead of UInt32? According to Reflector the address is stored as an Int64 internally (m_Address) and the constructor validates it to be within the range valid for UInt32. So I'm just curious why it uses Int64 and not UInt32. And before anyone says IPv6.. IPv6 is bigger than Int64 and is stor...

Variable interpolation in VB.NET

Can I do something like "%s said %s blah.", $name, $blah; in VB.NET it's getting painful writing name & "said" & blah & "blah" ...

Convert an Icon to IPicture in .NET 4.0?

One of the standard and (somewhat) supported answers was to use Support.IconToIPicture from the Microsoft.VisualBasic.Compatibility assembly. However, in .NET 4.0, "This API is now obsolete". Yes, there are various solutions out there, but I would think that if Microsoft was obsoleting this method, there would be another "supported" al...

C# - What should I use, an Interface, Abstract class, or Both?

So, hypothetically, I'm building some sort of real estate application in C#. For each type of property, I'm going to create a class such as ResidentialProperty and CommercialProperty. These two classes as well as all other property classes will share some common properties, such as Id, Title, Description, and Address information. What I...

'Must have' .NET components: experienced developers?

Hi all, I thought I'd canvas the more experienced .NET (mostly CSharp/ASP.NET) Developers on the most useful general components. I've got about $5-$7k to spend as I want on components as part of a project which involves web based graphs/reports/data visualisation, but I want to get things that will be useful for general purpose the boa...

Suppress command window from started command-line application with .NET

I have a module that needs to run a small .Net command-line program to check for updates. Everything is working great, however I am having trouble suppressing the Command Prompt output from being shown. The app has it's own Windows Form that it pops up if it detected an update. Updating needs to run as a seperate app due to the fact tha...

Is there a way to include the xsd:documentation in the C# class generated with XSD.exe?

I am using xsd.exe to generate a C# class from a collection of xsd files. The xsd file makes use of the <xsd:documentation> tag to include useful descriptions. Example: <xsd:complexType name="AddressType"> <xsd:annotation> <xsd:documentation>A formatted or free form address and its intended use.</xsd:documentation> </x...

Programmatic Load Testing?-- outside Visual Studio

I was just wondering if there is a FREE framework I can use to programmatically run WCF load tests outside of Visual Studio. I've seen that NUnit provides such functionality for unit testing, but can you do load testing with it? Any help would be appreciated. Thanks. ...

XML serializing arrays with type="array" in .NET

I'm attempting to serialize a class to XML, but I have some strict requirements on the output (because I want Rails' ActiveResource to consume it). One of those requirements is specifically for arrays. Here's two examples: class Person { public string FirstName { get; set; } } List<Person> people = new List<Person>(); people.Add( new...

Multiple threads slowing down overall dictionary access?

I am profiling a C# application and it looks like two threads each calling Dictionary<>.ContainsKey() 5000 time each on two separate but identical dictionaries (with only two items) is twice as slow as one thread calling Dictionary<>.ContainsKey() on a single dictionary 10000 times. I am measuring the "thread time" using a tool called ...

Services and WPF.

This is a general technologies question. I am building a Media Player for a school project. It is written in C# and uses WPF for the interface. I am adding a service to it to maintain the database as the user makes changes to it. I also want it to contain the config class I built in a previous iteration which is the subject in the obser...

Quartz.Net and dependancy injection or calling a job from external dll at runtime

I am trying to evaluate Quartz.Net. I tested it with adding a class which implemented IJob in the executing assembly and it worked. Now I want to develop an Job Scheduler in which I can add jobs at runtime. How to proceed. Edit: If it seems subjective I have following specific question. How to add external class/dll which are unkno...

Get the KB or speed of a download in .NET

Right now i use either HttpWebRequest or WebClient to download files. I would like to see how many kbytes per second i am currently downloading at. How may i do this? ...

Changing UI language on-the-fly

I need to support UI language change through the application menu. Localized strings store in resource files. I use this approach. It works fine, but I one problem. How I can change UI language on-the-fly, without reloading application? I try to google this problem - many advises to implement INotifyPropertyChanged interface. But, I st...

Delete last N bytes from file

There's a file on disk which can be very large. Is there any way to delete the last N bytes from it without copying the remaining content to another file? ...

How to detect when the laptop is running on batteries in .NET?

Hi, How to detect when the laptop is running on batteries (or AC) in .NET? Thanks, Mahesh ...

How to make nested child forms in C#.net

In my windows form application I am using 10 forms.It is fine when only a parent and single child form are used at a time. But in case of multiple use of child form I am getting problem and not able to use them as child forms.They are not working as child form. Your any effort would be helpful for me. Th...

Erratic behavior from ContextMenuStrip

I am getting some erratic behavior from a ContextMenuStip: private void lstModules_MouseMove(object sender , MouseEventArgs e) { mouse = e.Location; } private void lstModules_MouseDown(object sender , MouseEventArgs e) { ListViewItem item = null; if((hitTest = lstModules.HitTest(mouse)) != null) item = hitTest.Item; switch...

restrict num of items loaded in navigation property

Hi All, I have the following query in Linq: var query = from question in context.Questions.Include("QAnswers") join answer in context.Answers on question.id equals answer.qst where answer.user == param_userID select question; return query.toList(); The problem is that it doesn't...