.net

Connect and DisConnect usb devices programmatically .

hi , I need to connect and disconnect the usb devices such as flash drive, etc. in programmatical manner,with out un-plug and re-plug the device. Is there any way to do in .net,c# window application.??? Thanks in advace ...

Forward a Copy of Http Requests to another system

I have a WCF service deployed on production. I'm looking for a tool to forward a 'Copy' of all the messages received by that service to a development server. I need this to debug the requests in my IDE on the Dev box. ...

SerialPort memory leak in .NET 2.0/3.5

Hello, I'm having a very big problem with the SerialPort class and I need some help to solve this. We're using multiple serialports in a generic list since we need to connect to multiple devices. This is what our basic code looks like... List<SerialPort> ports = new List<SerialPort>(); private void button1_Click(object sender, EventA...

Simple Class Question

I have class person that contain FirstName and LastName, I'd like to create an array of person which is populated from a DataTable with columns Fname and Lname. How would I do that? ...

How to Monitor and edit images on shared hosting server?

Just want advice on how to think and do the following, I am creating a website and the user will setup some settings on his profile "images size", then using this settings i want him to point to a folder on his server and my service will monitor and any image upload in this folder i will re size based on settings he saved I first thought...

How to step into C/C++ DLL from C# application while debugging

I have two project in my solution: C/C++ Win32 DLL and some C# application. What I have to do to be able to step into DLL while debugging? I switched on all debugging options in C++ project's settings and copied to C# application root next files: MyLib.dll, MyLib.pdb, vc90.pdb, vc90.idb, but it doesn't helped. What additional actions ...

What's the point in Max(Threading.Interlocked.Increment(Offset), Offset - 1)?

I have seen the mentioned piece of code on several occasions now, what's the point of doing a Max(a+1, a-1)? At first I thought it might be to prevent underflow, but it doesn't really make sense not to prevent the underflow in that case. ...

WCF - net.pipe vs. net.tcp vs. http Bindings

I'm new to WCF and would like to know the differences/advantages/limitations/etc of each of the following bindings: net.pipe net.tcp http Supporting scenarios on when to use each binding and other examples would be appreciated. ...

When should an `out` parameter be used instead of returning a complex type?

When should we use an out parameter in C#? For example bool TryGetValue(out object value); vs. class ReturnType { public bool Found {get;set;} public object Value {get;set;} } ReturnType TryGetValue(); Apart from reducing the number of lines of code, when should an out parameter to be used and when it should be return...

COM Interface question - .NET

Hi Recently I was reading about interop marshalling but I still don't understand one thing. To make .NET assembly visible to COM I need to use tlbexp tool and/or regasm tool. To make COM visible to .NET assebly I have to use tlbimp tool - all that is clear for me. Apart from that, I've seen on the internet a lot of code dealing with C...

Video overlay on Windows (using C#?)

I am working on a video processing library in C# and would like to display videos on Windows XP up. For this purpose, I currently use a custom double-buffered UserControl with overridden OnPaint that uses Graphics.DrawImageUnscaled. This works okay, but is not ideal. Therefore I would like to implement a video display using hardware ove...

How to shift array elements

Hi, I have an array of n = 32 items with positive and negative values. First n/2 elements are positive and sorted by value and second n/2 elements are negative and sorted by value as well. I would like to sort the whole array by value, starting from the smallest negative value to biggest positive value which means if there are 32 elemen...

NetNamedPipe: varying response time when communication is idling

I have two WCF apps communicating one-way over named pipes. All is nice, except for one thing: Normally, the request/response cycle takes zero (marginal) time. However, if there was a time span of, say, half a minute without any communication, the request/response increases up to ~300-500ms. I looked around the net and I got the idea of...

Copy file to remote computer using remote admin credentials

I am using C#... I need the ability to copy a set of files to about 500 unique computers. I have successfully been able to use the LogonUser() method to impersonate a domain account that has the required permissions to copy the files. The destination path for the files is something like: \\RemoteComputer\C$\SomeFolder My questions i...

store image in database or in a system file ?

Exact Duplicate: User Images: Database or filesystem storage? Exact Duplicate: Storing images in database: Yea or nay? Exact Duplicate: Should I store my images in the database or folders? Exact Duplicate: Would you store binary data in database or folders? Exact Duplicate: Store pictures as files or or the database for a web app? Exact ...

.net - Problems with Array.Sort and Array.BinarySearch - culture and globalization

I need to sort an array containing a list of words and search the same using binarysearch. For certain reasons, the word-list must always be sorted using the sorting-rules of "en-US" i.e. American Regional Settings. The code will run under various international Operating Systems and of course this will mean that the word-list will be sor...

Do Asp.Net handlers pass data back to HttpResponse?

Hello, Q1: A) I assume web form passes rendered html to HttpResponse object, and in turn HttpResponse object passes these rendered data back to IIS? B) I also assume that regardless of which Asp.Net http handler processes the request, all Http handlers eventually pass data back to HttpResponse? Q2 - When request is received by...

What components of the .Net framework should a professional developer typically avoid?

.Net is a huge framework with some functionality that appears to target beginners or becomes problematic if much customization is involved. So what functionality available in the .Net framework do you feel professional developers should avoid and why? For example, .Net has a wizard for common user management functions. Is using this fu...

How can a Ruby on Rails style counter cache be implemented using Linq2Sql?

How can for example a Blog post comment counter cache be implemented using linq2sql? The way I currently implement this in a site I am developing is using hand coded sql queries and the ExecuteCommand() adhoc sql execution method of the linq2sql datacontext. I would like to know if there is a better/simpler approach using linq2sql tha...

Convert "1.79769313486232E+308" to double without OverflowException?

I have this string "1.79769313486232E+308" and am trying to convert it to a .NET numeric value (double?) but am getting the below exception. I am using Convert.ToDouble(). What is the proper way to do this conversion? OverflowException: Value was either too large or too small for a Double ...