.net

General String Encryption in .NET

I am looking for a general string encryption class in .NET. (Not to be confused with the 'SecureString' class.) I have started to come up with my own class, but thought there must be a .NET class that already allows you to encrypt/decrypt strings of any encoding with any Cryptographic Service Provider. Public Class SecureString ...

How to create c# function to convert from groups of ranges of numbers to continues numbers

Hi we have 6 groups of 253 machines each one ,but each group are ranges from machine #2 to machine #254 , and continues IDs to represent each machine. like in the following table: Group Machine ID 0 2-254 1-253 1 2-254 254-506 2 2-254 507-759 3 2-254 760-1012 4 2-254 1013-1265 5 2-254 1266-1518 I am looki...

How to restrict a method to a particular thread?

I have a method that for thread-safety reasons should only ever be used by a particular thread. If another thread tries to use it, I would like an exception to be thrown. public void UnsafeMethod() { if (CurrentThreadId != this.initialThreadId) throw new SomeException("Can only be run on the special thread."); // continu...

Why does UnicastIPAddressInformation.IPv4Mask return null on an IPv4 Address?

The following is a section of code which builds a list of IP addresses and their subnet masks from the local system, however the Warn function seems to get triggered regularly which should in theory be impossible - as it should not be possible to have an IPv4 address without the associated subnet mask[?]. static NetworkUtil() { ...

Designing Options/Settings Forms in .NET

I've got an application with about 35~ different settings in different categories. What are the best practices to expose this to the client. Secondly is there any VS.NET add-on or library (commercial or not) which can help to speed up this process. Something like "Property Grid" maybe but with a more professional and user friendly loo...

Calculate text height based on available width and font?

We are creating PDF documents on the fly from the database using PDFsharp. I need to know the best way to calculate the height of the text area based on the font used and the available width. I need to know the height so I can process page breaks when required. ...

Apple Ipod and C#

Hi What would be the best way to read ipod songs with C#. I am thinking of doing a interface to the ipod as a test :) Thanks ...

The remote name could not be resolved

Hello, i m creating mobile application for windows mobile 6.i m uploading an image on url/website. for this i m using webrequest and webresponse class.at the time of getting response i m getting this type of error- The remote name could not be resolved.. my code is- String url = "http://weblogs.asp.net/scottgu/rss.aspx"; Sys...

How to fire a GET request over a pseudo REST service in C#.

I need to communicate with legacy php application. The API is just a php scripts than accepts get requests and return a response as XML. I'd like to write the communication in C#. What would be the best approach to fire a GET request (with many parameters) and then parse result? Ideally I would like to find something that easy as the...

Is there a way to test a potential zombie transaction to see if it can be rolled back?

If a sql call fails, say to timeout due to deadlock, the transaction can turn into a zombie transaction-- I guess either my code or framework code does the rollback. The SqlTransaction isn't null, but it is a zombie can throws an error if you try to do a Rollback(). I can't find the .IsZombie property. // Make sure the transaction is ...

WPF: XamlParserException for a very simple form?!

I don't believe this: Just built a very simple form with one combobox, when user select one item, the label will display the selection. Here is my code: <Window x:Class="WpfApplication8.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Win...

Simple Message Poster for Friendfeed

I am trying to integrate a function into an application that posts a message to friendfeed using the C# API. Being a total novice I cannot work out how to make the connection and then publish a message to it. Can anyone help with this? I have the HTTP Basic Auth working fine, just not the function to post to my friendfeed account. ...

LINQ: How to declare IEnumerable[AnonymousType] ?

Hello, This is my function: private IEnumerable<string> SeachItem(int[] ItemIds) { using (var reader = File.OpenText(Application.StartupPath + @"\temp\A_A.tmp")) { var myLine = from line in ReadLines(reader) where line.Length > 1 let id = int.Parse(li...

Has a month gone by?

In my database I have a table holding some subscription information. I have among others a StartDate and an EndDate as DateTime. What I need is to make a Linq query getting all rows due for payment. The payment is supposed to take place each month on the same day they registered (StartDate) and stop on the EndDate. So if they registered...

HttpHandler Returning Zero Length byte[]

I have a custom HttpHandler that invokes a webservice to get a file. In test, I invoke the production webservice and the HttpHandler returns the file correctly. When I test it in the production environment on the server, it works as well. However, if I invoke the HttpHandler from a remote client (not on the server) the filename and si...

Installing dev tools in production

What are the reasons for not installing VS 2008 on a live production web server? ...

JOIN with LinqtoSql, only select TOP(x) on joined table?

I've had a look around on StackOverlow but haven't been able to find a definitive answer on this. Below I have a code snippet of what I currently have, and I will explain what I am trying to achieve. Table<Gallery> galleries = pdc.GetTable<Gallery>(); Table<GalleryImage> images = pdc.GetTable<GalleryImage>(); Table<Comment> comments = ...

How to Respond to Sound In Another Application?

Can someone give me some info/background info on how I might go about writing an application that 'listens' to the sounds being made by the computer's sound card or a specific other program. For example, if I kicked off a long-running 3rd party app that gives no indication of when it is done, except a loud 'DING!' sound. Is there anywa...

Better way to deploy to Windows Mobile Device

I have been working on a Windows Mobile app for a little while now (havnt done much work with mobile before) and i have been having a problem when deploying to my mobile, at the moment i can only run the application once then if i want to run it again i have to do a soft reset. Maybe im deploying wrong? (pretty sure i am actually, im pr...

How can I add a state to a control in Silverlight?

I have my own TextBox2 class that derives from TextBox. I want to add a state called TextBlock and I want the VisualStateManager to go to that state when the IsTextBlock property/dependency property is true. When this is true, I want to change the style of the text box to be readonly and look just like a TextBlock but be able to select...