.net

Unhandled, non-ui thread, exceptions in Windows Forms

Short of inserting a try/catch block in each worker thread method, is there a way to deal with unhandled, non-ui thread, exceptions in Windows Forms? Thread.GetDomain().UnhandledException works great for catching the error, but by then it's too late to do anything about it (besides log it). After control passes out of your UnhandledExce...

Scripting for .Net Deployment

I am researching various options for deploying a batch of .Net applications. Deployment is more than just copying files, we need to stop/start services, call an exe that executes database scripts, initiate a number of setup.exe installs, etc. These scripts will be given to a third-party who will apply various application updates to our...

Why does the parameterless Guid constructor generate an empty GUID?

Why does the parameterless Guid constructor generate an empty GUID rather than default to a generated one as with Guid.NewGuid()? Is there a particular use for an empty Guid? ...

Static Indexers?

Why are static indexers disallowed in C#? I see no reason why they should not be allowed and furthermore they could be very useful. For example: static class ConfigurationManager { public object this[string name]{ get{ return ConfigurationManager.getProperty(name); } set { ...

UserControl Focus Issue - Focus() sometimes returns false

I have a user control that behaves similar to a tab control. The tab headers are UserControls that override Paint events to make them look custom. In order to leverage the Validating events on various controls on our tab pages, when the user clicks on the tab headers, we set the Focus to the TabHeader user control. I've noticed that C...

Programmatically access the <compilation /> section of a web.config?

Is there any way to access the <compilation /> tag in a web.config file? I want to check if the "debug" attribute is set to "true" in the file, but I can't seem to figure out how to do it. I've tried using the WebConfigurationManager, but that doesn't seem to allow me to get to the <compilation /> section. Update: I know I could easil...

Automated Build Tool With Managed C++ (.NET 2.0)

I'm laying the groundwork for an automated build process and am trying to make sure I start down the right path. Our codebase is a mixture of Managed/Unmanaged C++. The managed part is in .NET 2.0 and all of the projects are part of a Visual Studio 2005 solution. Right now I'm looking at NAnt, but I can't figure out how to perform a bui...

How to iterate through a tree structure using a generator?

Hello people. I'm trying to figure out how to implement a function in a tree node which returns all its descendant leaves (whether direct or indirect). However, I don't want to pass a container in which the leaf nodes will be put recursively (the tree could be huge), instead I'd like to use a generator to iterate through the tree. I've ...

Converting GUID to Integer and Back

so I have a 3rd party application that I have to interface with, this application needs the userID from my users table. the problem is that I store my userIDs as GUIDs and the 3rd party app only accepts an integer. so I figure, if there is a way to convert a GUID to an integer then be able to convert it back (as i get communications fro...

Linq2Sql Testing

I have test database and a production database. When developing I of course work against that test database then when deploying I have to semi-manually update the production database (by running a batch-sql-script). This usually works fine but there's a chance for mistakes where the deployed database isn't the same as the test database. ...

Can ReportViewer render a hyperlink with a relative path?

I have created a local report on a datasource that has a field named "RelativePath". When my WinForms app renders the report, it exports files to the location specified in the RelativePath field. In the report builder, I set Navigation|Hyperlink action|Jump to URL to "=Fields!RelativePath.Value" and set the report's EnableHyperlink prope...

Visual Studio Unit Testing of Windows Forms

We're working on a project here in Visual Studio 2008. We're using the built-in testing suite provided with it (the Microsoft.VisualStudio.TestTools.UnitTesting namespace). It turns out, that much to our chagrin, a great deal of complexity (and therefore errors) have wound up coded into our UI layer. While our unit tests do a decent j...

How do IN () statements work in NHibernate? (Using Criteria)

I'm trying to create the equivalent of the below using NHibernate. I've done all the mappings using fluent and I can do the basic queries just fine but I have no idea how to do this. -**Product Table** Reference Title Subjects (Many to Many relationship) Price -**Subject table** SubjectID Name -**SubjectToProductMapping Table** Refere...

How to draw subsection of text using .net graphics

I'm doing custom drawing in datagridview cells and I have items that can vertically span across multiple cells. An item displays text and the issue at hand is how can I draw just the cell's part of the text? I have the item's rectangle and the cellBounds. Currently, I am drawing all the text on each cell paint i.e. I'm drawing over cel...

Is there anyway to speed up SQL Server Management Objects traversal of a existing database?

I'm currently using SMO and C# to traverse databases to create a tree of settings representing various aspects of the two databases, then comparing these trees to see where and how they are different. The problem is, for 2 reasonably sized database, it takes almost 10mins to crawl them locally and collect table/column/stored procedure i...

How can I make a Click-once deployed app run at startup?

How can I make a Click-once deployed app run a startup? The best option I found by searching was to set the Publisher on the app to Startup, so the Start menu shortcut would be placed in the Startup folder, but that seems like a huge hack and I would like there to be a Start menu icon people can find. What options do I have? ...

Is COM+ still recommended?

I used to write ASP.Net apps deploying business dataaccess layers in COM+ components several years ago. This was the standard in several corporate infrastructure here in my country. Is this still recommended? What is the alternative? ...

Trace and Debug statements.

Im a little confused over how to use the .NET Trace and Debug classes. Why would you bother using Trace instead of Debug? Trace.TraceError() Trace.TraceInformation() Trace.Assert() Debug.WriteLine() Debug.Assert() Also, I understand that Debug statements are ignored when your in Release config mode, but If trace statements apply all ...

Connect to remote MySQL database with Visual C#

I am trying to connect to a remote MySQL database using Visual C# 2008 Express Edition. Is there a way to connect using the editor, or do I have to code the connection manually? The editor has a clear and easy-to-follow wizard for connecting to Microsoft SQL Server and Access databases, but I don't see an easy way to add a remote MySQL d...

How do I use .NET without loss of control over intellectual property?

Am I correct in assuming that .NET is a kind of Claytons Open Source (the open source you have when you're not having open source) given that it is so readily decompiled into a variety of representations? Obfuscation is nothing for someone with a text editor and access to regular expression-based text substitution tools. What do I do wh...