.net

Unable to map serial port when using virtual PC 2007 SP1

I'm writing an application that communicates with the serial port to control a device. The development environment is on a virtualized Windows 2003 R2 machine hosted on a Windows Vista machine. When I try to map the COM ports through virtual PC so they can be use in the virtual machine, I get the following error right after the machine...

Is there any way to determine if a connection has been broken when using YAHOO.util.Connect.asyncRequest?

I connect to a .NET handler to upload an image using YAHOO.util.Connect.asyncRequest. The handler then throws an exception because the file is too big. When the exception is thrown, the request connection is immediately cut meaning that the javascript callback for asyncRequest is not called and the user is not notified that the image u...

hide parameterless constructor on struct

Is it possible to hide the parameterless constructor from a user in c# I want to force them to always use the constructor with parameters e.g. this Position class public struct Position { private readonly int _xposn; private readonly int _yposn; public int Xposn { get { return _xposn; } } public int Y...

How to avoid Name-itis in Windows Workflow (WF)?

I just started working with WF and what I find really annoying is that you have to name so many things. IMO, one of the most difficult things that a programmer deals with every day is constructing good names for things, and WF seems to take this to the extreme. Take the WF IfElse Activity for example. If I were coding this in raw C# ...

Is there a .NET Culture dependent 'Today' string?

I am writing a month calendar style control and need to display a string that indicates today's date. So on an English culture machine it would show 'Today : 11/02/2009'. If a different culture happens to be used, such as French, then I would like to use the French word for 'Today'. Does anyone know if the .NET platform exposes this word...

XmlDocument - ParentNode and DocumentType are null

In .NET what does it mean if you LoadXml() into the XmlDocument object and then ParentNode and DocumentType are null? Also, I get this as the answer to xmldoc.FirstChild.Value: version="1.0" encoding="utf-8" Is this right? Been a while since I have done any XML DOM stuff. The file is encoded UTF-8. Think that shouldn't be an issue. I...

Can the Presenter of Web Client Software Factory(WCSF) and Smart Client Software Factory(SCSF) shared and how?

Web Client Software Factory(WCSF) and Smart Client Software Factory(SCSF) both use MVP pattern. M-Model can be shared. V-View has to be different as both are on different platform(Desktop/Web). I want to know can the P-Presenter can be shared or can I be exactly same for both and how. ...

What's the best way to shut down a .Net winforms application and delete the executable

I need to shut down my application and then delete the executable. I am doing it by kicking off a low priority batch job and then immediately shutting down the exe. Is there a better way? ...

Ordering items by length in IEnumerable<T>?

I have a IEnumerable<T> collection with Name and FullName as items in it. There are around 5000 items in it. I want to display the FullNames sorted by its lenght, so first the longest name to the shortest name displays. How can I do it in most optimized manner? ...

Best-Practices : how should I store settings in C# (Format/Type) ?

Now I'm curious what are possibilities to store/load settings in .net. For example I need to store user name/password for different db's and etc.., also I need to store some options and etc. My though was to create [Seriazable] class and save it to file... What can You suggest? what are possibilities in .net and etc. ...

How to merge multiple datatables into one?

I have multiple excel files which I open as datatable I want to merge all this datatables single DataTable in .net. eg, Apr09.xls,May09.xls,Jun09.xls All have dataas follows Apr09.xls EMPCODE,PresentDays 0001 ,30 0002 ,21 May09.xls EMPCODE,PresentDays 0001 ,25 0002 ,30 New datatable will be as follows EMPCODE,PresentDa...

Error: <target>.ColumnName and <source>.ColumnName have conflicting properties: DataType property mismatch.

I am trying to merge multiple excel files using DataTable.Merge() option For Each fileName As String In Directory.GetFiles("C:\TEMP\", "*.xls") Dim connectionString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=""Excel 8.0;HDR=NO;IMEX=1;""", fileName) Dim adapter As...

Using a custom WPF control in WinForms

I'm going to have to build a custom control for a WinForms application. But in the near future that same control will have to be used in a WPF application. I've already written all the logic in a controller class which I can use for both WinForms and WPF (I will only have some databinding to do and that's it), but of course it would be ...

How to make a .NET executable run on 64-bit framework

I have an executable that defaults to 32-bit. It doesn't have source code and I want to keep both 32-bit and 64-bit frameworks on the system. Is there a way to make that executable run on 64-bit .NET framework instead? ...

Lambda Expression cause weakreference's target cannot be GC?

namespace Test { class Test { delegate void HandleMessage(string message); public void handleMessage(string message){} static void Main(string[] args) { HandleMessage listener1 = new Test().handleMessage; WeakReference w1 = new WeakReference(listener1); HandleMessage listener2 = (message) => { ...

How to use trackpad scrolling in .Net

My WinForms app uses the mouse wheel, subscribing to the Control.MouseWheel event. How can I get it to work with scrolling methods from other input devices, in particular "finger along the edge" scrolling on the (Synaptics) trackpad on my T61? I assume that I need to wire up the trackpad messages to the Control.MouseWheel event somehow, ...

Why microsoft made JavaScriptSerializer obsolete prior to .net 3.5 SP1 and again active after that?

JavaScriptSerializer is not obsolete after .net 3.5 SP1. Should I uses JavaScriptSerializer or the prior recommended DataContractJsonSerializer?. Also why it was made obsolete? ...

How can I check if configuration file is proper?

Is there any way I can check in .net if my configuration file (I provide my own config) is proper without validating it against Xml Schema? ...

How to call MSBuild from C#

Is there a better way to call MSBuild from C#/.NET than shelling out to the msbuild.exe? If yes, how? ...

String to time format but how?

I want to change a value from int or string format to datetime format. There is any function in SQL like the following?: Function: Result TimeAdd( nextrundate,"sec",45) 00:00:45 TimeAdd( nextrundate,"min",45) 00:45:00 TimeAdd( nextrundate,"hour",4) 04:00:00 But: TimeAdd( ne...