.net

How to access anonymous object's property

I have a WinForms combobox to which I bind a list of anonymous objects (printer descriptions and locations). The goal here is a to select a default printer (which matches printer location). But within a foreach loop below, I am having trouble accessing the anonymous object's properties. I know of a work-around (I tried a private nes...

.Net 3.5 DLR DynamicObject Help

I have been struggling to get a simple DynamicObject example working in .NET 3.5. Using the latest build of the DLR off codeplex I haven’t been able to figure out what the .NET 3.5 equivalent to the following is: public class DynamicObjectBag : DynamicObject { private Dictionary<string, object> _properties = new Dictionary<string, ...

RegularExpressionValidator.ValidationExpression to force length in 10 or 12 symbols

RegularExpressionValidator.ValidationExpression="\d{10}" means only digits - 10 max. RegularExpressionValidator.ValidationExpression="\d{10,12}" means only digits - 10, 11 or 12. How to force strictly 10 or 12 symbols? ...

Tabbing off control bypasses validation .NET

So, I have a User Control which is just a TextBox with special formatting rules (there are reasons why I'm not just using a MaskedTextBox...y'know...the sensible solution). Anyhow, when the user inputs invalid data, they can't click off using the mouse because the TextBox_Validating event cancels like it should and the control can't los...

How do I control the screensaver (friendly/display) name shown in the drop down list? - Windows Server 2003 / Windows 2000

So I asked a question with the same title earlier and got an answer that works for the most part. My issue now is that the string table in the Win32 resource file is not working on Windows Server 2003 (maybe others too, limited O/S testing at this point). Testing results: Displays correctly: Windows XP Windows Vista Windows 7 Doesn...

Unit Testing an Event Firing From a Thread

I'm having a problem unit testing a class which fires events when a thread starts and finishes. A cut down version of the offending source is as follows: public class ThreadRunner { private bool keepRunning; public event EventHandler Started; public event EventHandler Finished; public void StartThreadTest() { ...

Print image in .Net winform

I am trying to allow my users to print the current page they are on in our WinForm program. First I take a screenshot of the app and save it to disk. Then I kick off a PrintPreviewDialog and load it in there. That all works, except for the fact that it goes off the page! I can't figure out how to change or allow the user to change th...

Is it ok to catch all exception types if you rethrow them wrapped another exception?

I know you're not suppose to write code that caches all exception types like this. try { //code that can throw an exception } catch { //what? I don't see no } Instead you're suppose to do something more like the code below allowing any other exception that you didn't expect to bubble up. try { //code that can throw an exception ...

BitConverter.ToString() vs Convert.ToBase64String()

I had thought that Convert.ToBase64String() was the method to use to create a base64 string of a byte array, but I recently came across BitConverter.ToString(). What is the difference between the two? And more specifically when should one be used over the other? For example in this question about creating a MD5 digest, a comment by C...

WinForms Webrowser Sync Scroll

How do you sync scroll two winforms webrowser controls? Meaning when you scroll one up and down, the other scrolls to the same spot in the underlying document? ...

get length of wav file ? (playing wav with soundplayer class)

I'm playing wav sound files using the .NET SoundPlayer class in my program, is it somehow possible to get the length of the wav file (in milli sec) ? thanks for answers ...

How do i prevent my code from being stolen?

What happens exactly when I launch a .NET exe? I know that C# is compiled to IL code and I think the generated exe file just a launcher that starts the runtime and passes the IL code to it. But how? And how complex process is it? IL code is embedded in the exe. I think it can be executed from the memory without writing it to the disk wh...

Problem with WPF Effects and Video Card

Hi, I'm building a WPF application and this WPF application is having a toolbar-like panel that I use for adding button based on the context. The code of the toolbar is: <Grid x:Name="ToolBarGrid" VerticalAlignment="Top" Height="46"> <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> ...

Comparing trees in a treeview

I want to be able to iterate through a tree and compare nodes one tree to the nodes in another tree of the same format. EX: There are five categories. 1 - 5. Are all static and identical between both trees. In 1. All static values. So i need to just compare the values of the nodes there. In 2. This is comes from a KVP object and...

Distorted System Tray Icons

I've written a little system tray application that uses a NotifyIcon to display the status of a process. I'm loading a high quality 64 by 64 png formatted icon in the following way: Bitmap rawImage = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Snitch.Icons.Loading.png")); m_icon.Icon = Icon.FromHandle(rawImage...

What is the maximum length of an array in .NET on 64-bit Windows

I heard from someone that the maximum array size in .NET is 4 GB? Just wondering if that is true. You wouldn't dream of doing this on 32-bit .NET but on a 64-bit system with 12 GB of RAM, maybe, just maybe you might want to do this. :-) ...

Loading an typed dataset from an XML document

I am unable to fill a typed dataset Using reader as New StringReader(My.Resources.sampledata) typedDataset.ReadXML(reader) 'typedDataset.WriteXML("c:\data.xml") End Using The above does not work. If I enable the commented line to write the results to file I get a 1K file with <?xml version="1.0" standalone="yes"?> <testSchema xml...

Configuring Threadpool Max Threads via app.config?

Can I configure the max threads via the config file? ...

What is the best way to create a reminder service in .Net?

I am looking to build a web application that will allow users to manage simple tasks or todos. As part of this, I'd like to send users email reminders daily of their tasks. I'd like each user in the system to specify what time of day they get their reminder, though. For example, one user can specify to get their emails at 8AM while anoth...

GetPrivateProfileString in .NET

Is there a .NET version of GetPrivateProfileString? (I can use p/invoke, I just don't want to unless necessary.) ...