.net

What is the algorithm used by the memberwise equality test in .NET structs?

What is the algorithm used by the memberwise equality test in .NET structs? I would like to know this so that I can use it as the basis for my own algorithm. I am trying to write a recursive memberwise equality test for arbitrary objects (in C#) for testing the logical equality of DTOs. This is considerably easier if the DTOs are struct...

Disable "Foo has encountered a problem and needs to close" window

Is there a way (other than WerAddExcludedApplication which won't work in Windows XP) to disable the window "Application has encountered a problem and needs to close" from appearing when my application crashes? (image taken from Bil Simser' blog) I need this to work in Windows XP. ...

Returning data from sqldependency

I'm trying to write a vb.net application that uses an sql dependancy. The dependancy will be triggered when data is added to the database. I'm wondering if it's possible to have the dependancy return the data/query that triggered it. currently i have to have the onchange event trigger a select statement to refresh the data i have cach...

Domain credentials for a WebClient class don't work.

I'm trying to get a html source of a website through C# code. When I access the site with windows authentication the following code works: using (WebClient client = new WebClient()) { client.Credentials = CredentialCache.DefaultCredentials; using (Stream stream = client.OpenRead("http://intran...

C#/.NET: how do I close the application from a parent window?

I have a Windows application that has 2 Forms. From one form I am opening a 2nd form. When opening the 2nd form I am hiding 1 form and in the second foem I am starting a thread. Now I want to close the application. But I was not able to do that. On my 1st form I have tried: Form1 frm = new Form1(this, tcpClient); frm.ShowDialog(); this...

Edit connectionstring of Web.config in webservice (ASPNET)

Hi! I'm using webservice for my Desktop application(C#). I want to edit my database connectionstring programmatically in web.config(in web service) through C#. How to do this? Any simple idea? ...

Is there a tool for winforms which can tell you what control your mouse is hovering on

I seem to remember a tool that could be used at runtime to tell you what the type of a control was when you hovered your mouse over the control. is there something similar for .Net? ...

How to write FireFox extension with Visual Studio using C# programming language?

I was wondering if it's possible to write Firefox extension using .Net Framework? Had anybody such experience in writing Firefox extensions using C# programming language? Any good sites or guidelines would be very helpful. Here is an example of what I need. Extension to enter phone number and to send SMS Message. I draw it in Paint, s...

where to get some map images for deepzoom test data?

Hello everyone, I am developing Silverlight 3.0 deep zoom + C# + .Net 3.5 + VSTS 2008. I need some png or jpg small images to compose to a big map image, or using a big png or jpg map image to test deep zoom effect? Any free ones? thanks in advance, George ...

Is there an advantage to USING vs. declaring a context variable?

These two snippets do the same thing - is there one that's better than the other, or is it just a matter of preference? Using context As MyDatabaseDataContext = New MyDatabaseDataContext() Dim test = context.Employees.Count End Using vs. Dim context As MyDatabaseDataContext = New MyDatabaseDataContext() Dim test = context.Employe...

GAC Comparison Tool for multiple servers?

Does anyone know of a tool that would allow me to generate a report of the assemblies installed to the .NET GAC on all the servers in my web farm? (30-40 servers) Or alternatively, does anyone have a pointer or a link on some way of accessing the information programmatically, via WMI, or remote registry query, or some other technology?...

I know this regex can be simplified - .NET

Here are my requirements: 1-80 characters These characters are allowed: alphanumeric spaces _ ( ) [ ] ! # , . & * + : ' / - The regex I have below works, but in particular I'm not sure how to reuse the character class [\w\(\)\.\-\[\]!#,&*+:'\/] [\w\(\)\.\-\[\]!#,&*+:'\/][\w\s\(\)\.\-\[\]!#,&*+:'\/]{0,79} Update: ...

Simple Data Access Layer

Can anyone suggest a simple Data Access Layer (C# .NET)? Not keen on using the Microsoft Application Data Access block, seems very bloated and overkill. Also don't want to use LINQ to SQL for various reasons. I want to build upon this and create our own in-house ORM, again for various reasons. In the past I've always had the Data Access ...

Pros and Cons explicitly setting enum field's values

Is it preferable to explicitly set enum's fields instead of just defining their names? E.g. any pros and cons for Enum1 vs Enum2? Enum1: enum SomeEnum { Something1 = 0, Something2 = 1 } Enum2: enum SomeEnum { Something1, Something2 } P.S. This question doesn't relates to enums that would be stored in database, which i...

Where can I find some clear examples of static vs. instance "fieldless" properties for use in the classroom?

In all but a few cases, properties are backed up by fields, either explicitly or implicitly. However, properties like DateTime.Today are calculated properties not backed up by a field (EDIT: properties like Guid.Empty and Math.E are backed up by a static field, I'm not interested in those). In terms of best practice or experience, shoul...

Custom WPF Control Dependency Property Not Binding to external DP

I'm trying real hard to make this short and easy to read. I am creating a custom control that has a DP defined (RandomNumber) in the code-behind. The value of this DP is set from a click event fired by a button in my control. Here is the relevant code for this: public partial class Tester { public int RandomNumber { ge...

Inconsistant behavior of ListBox.SelectedIndices when SelectionMode = MultiExtended.

I have a Windows.Forms.ListBox on my form. Its SelectionMode is set to MultiExtended. That allows the user use both CTRL/Click and Shift/Click to select a multiple items. The behavior of the SelectedIndices list is inconsistant. If the user selects n consecutive items by doing a series of CTRL/Click operations, the list will have a Cou...

How do I retrieve AppSettings from the assembly config file?

I would like to retrieve the AppSetting key from the assembly config file called: MyAssembly.dll.config. Here's a sample of the config file: <configuration> <appSettings> <add key="MyKey" value="MyVal"/> </appSettings> </configuration> Here's the code to retrieve it: var myKey = ConfigurationManager.AppSettings["MyKe...

Parameters cause sql query to time out.

I have a long SQL query, it does some inserts, updates, then deletes. Each query uses the same 2 parameters. If I pass them in as SQL parameters from C#, it times out, after 20 mins. I just put the parameters into the command text, and it works. When I use it with the parameters it doesn't even show up in the profiler till it times out. ...

.net Setup project force new file replacement on reinstall

Hello, I have a setup project that install a couple of projects and a couple of external files (one of which is a SQLite Database) - everything worked fine until i've recently modified the base database file included in the setup project. Now, everytime i try to reinstall the project the new database file does not replace the previous...