.net

How do I deregister an anonymous handler?

C# 2.0 has a neat feature called anonymous functions. This is intended to be used mostly with events: Button.Click += delegate(System.Object o, System.EventArgs e) { System.Windows.Forms.MessageBox.Show("Click!"); }; Now, suppose that Button is a static member, then adding delegates to it would count as unmanaged r...

Is the Windows Forms AcceptButton behavior in effect when the referenced button is disabled?

With the following: this.AcceptButton = this.OKButton; this.OKButton.Enabled = false; ... will the OK button click handler still be invoked when the user presses Enter? ...

Batch Script to Install or Uninstall a .NET Windows Service

I have no experience writing batch scripts, but I was wondering if there was a way to install a .NET Windows service using installutil.exe using such a script, or uninstall the service if it is already installed, ideally with some kind of confirmation that I actually would like to perform the uninstall (e.g. press y to uninstall). Here ...

StructureMap injection question....

I am trying to use StructureMap and have essentially 3 levels of abstraction. I have a service a repository and database interface. So the IService depends on IRepo and IRepo depends on IDatabase. My issue is that my IDatabase concrete type takes in db connection information. I am going to create these on the fly, trying to use Object...

Calling .net assembly from vb6 results in runtime error 424

Hi Everyone, I'm running into some trouble calling a .net assembly from vb6 and was hoping SO could help. In VB.net I built a ComClass and kept the default constructor and GUIDs. When deploying, I REGASM.exe the dll, which is located in the same folder as the VB6 exe. The .net dll references two other .net dll's, both of which are ...

Can you explain why DirectoryInfo.GetFiles produces this IOException?

I have a WinForms client-server app running on a Novell network that produces the following error when connecting to the lone Windows 2003 Server on the network: TYPE: System.IO.IOException MSG: Logon failure: unknown user name or bad password. SOURCE: mscorlib SITE: WinIOError at System.IO.__Error.WinIOError(Int32 errorCode, String...

My SQLParameter isn't passing NULL correctly.

I have this C# webform that has has a date picker box. If the date is set to nothing (the default) I want it to pass NULL to the database. This happens inside my parametrized query. SqlParameter CMActionDate = new SqlParameter(); CMActionDate.ParameterName = "@ActionDate"; if (ActionDate.Equals("")) { CMActionDate.Value = Syste...

Building a composite control with nested items

My goal is to create a composite control that looks like, acts like and behaves like a RadioButtonList. There is some extra things done behind the scenes which are working no problem. What I am unable to accomplish is the desired markup to use the control. My ideal markup looks like this: <cc1:RadioButtonField ID="rfCardType" runat="...

Not that lazy Regex match?

I have a C# Regex class matching multiple subgroups such as (?<g1>abc)|(?<g2>def)|(?<g3>ghi) but with much more complicated sub-patterns. I basically want to match anything that doesn't belong to any of those groups, in addition to existing groups. I tried (?<g1>abc)|(?<g2>def)|(?<g3>ghi)|(.+?) but it turned out too slow. I can'...

Does a .NET library for the W3C Markup Validator API exist?

I'd like to validate that users of my WPF application are putting proper XHTML into its TextBox control. I found that there's an API for the W3C Markup Validator. It's web page says: Building of libraries used to interact with the validator's API is encouraged. and it lists known Perl, PHP/PEAR and ColdFusion libraries. Doe...

net reactor & clickonce deployment

After building our VB.NET .exe it is then obfuscated using the 3rd-party .NET Reactor utility before the output of that is included within a VS2005 deployment project. Is there a way of replacing the .exe with the scrambled version prior to then publishing using click-once ? Has anyone managed to deploy with click once, a net reactor pr...

POS for .NET Known Service Objects

Hi, I was wondering if anyone knew where I could find a list of LineDisplays, CashDrawers, Printers, that work well with POS for .NET. I want to get around creating my own service objects for potential devices that I might by which are not supported. Thanks. ...

Join multiple DataRows into a single DataRow

I am writing this in C# using .NET 3.5. I have a System.Data.DataSet object with a single DataTable that uses the following schema: Id : uint AddressA: string AddressB: string Bytes : uint When I run my application, let's say the DataTable gets filled with the following: 1 192.168.0.1 192.168.0.10 300 2 192.168.0....

StructureMap creating instance

I have the concrete types for interfaces configured at startup, but I want to create instances of the concrete type at runtime with setting properties or setting different values in the constructor. All the creating of instances I see have the knowledge of what the concrete type is, at runtime I dont know the concrete type. Is there a ...

How can I detect when an SD card is plugged in?

I'm writing a PC application in C++ that needs to detect when a user connects an SD card to his/her computer. I know how to detect when the card reader is connected, but I do not know how to detect when individual cards are connected/removed. Does Windows have an IO interface to detect arrival/removal of SD cards? [Update] the WM_DEVIC...

Can I color different parts of text in a WPF TextBox?

I've got a WPF TextBox into which my users type XHTML. XAML... <TextBox Name="TextBoxContentBody" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" FontFamily="Consolas" ... /> It looks like this: I'd rather that it looked like this (Photoshopped mock-up): ...

c#/.Net Socket.Shutdown..

I recognize this type of question has a long history, but the way I am using this must be the correct '.net way' and yet it does not seem to work. I have a trivial synchronous IP server daemon that does a simple AcceptSocket, do some stuff, socket.send, socket.shutdown, socket.close. My client is another trivial C# app that does URLDo...

Dictionary<T> of List<T> and ListViews in ASP.NET

Preamble I'm asking this question because even though I've read through a lot of ListView resources, I'm still not 'getting' it. Background I have a bunch of Foo's that have a list of items associated with them (known as Bar), and I'm pulling them from the Data Access/Business Logic layer as Dictionary that holds a Foo and its associ...

Things a .NET developer needs to know when using a MYSQL backend.

With the economy the way it is my team and I have been looking into using MYSQL to reduce our licensing costs. I am wondering if there are any gotchas or issues that may crop up. Is there anything we need ot do special to get .NET to talk to mysql as opposed to MsSQL? When developing for it will LINQ to SQL have issues? Any caveats we...

Elevating privileges for UAC using manifest open new console window

I'm writing a console tool. Without privileges elevating for UAC support (manifest file), calling this tool from command prompt (cmd.exe) or console file manager (like far.exe) opens it in the same window, writes its output to the same window, etc. But now, when manifest file was added, a new console windows is created for tool after UA...