.net

C# + Castle ActiveRecord: HasAndBelongsToMany and collections

Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like FindAllPostByTags(IList<Tag> tags) that returns all Posts that have all (not just some of) the Tags in the parameter. Any way I could ac...

How to begin WPF development?

I've been using Winforms since .NET 1.1 and I want to start learning WPF. I'm looking for good resources for a beginner in WPF. What should I read, what Tools I need and what are the best practices I need to follow. ...

NHibernate : map to fields or properties ?

When you create your mapping files, do you map your properties to fields or properties : <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Foo" namespace="Foo.Bar" > <class name="Foo" table="FOOS" batch-size="100"> [...] <property name="FooProperty1" access="field.camelcase" column="FOO_1" type="string" length="5...

Forms in SharePoint

If I want to put a form up on SharePoint, is it easier to use InfoPath or build a custom web part in C#? Are there other options that I should consider? What are the requirements and hurdles for each option? ...

What is the best way to launch a web browser with a custom url from a C# application?

It's common knowledge that using System.Diagnostics.Process.Start is the way to launch a url from a C# applicaiton: System.Diagnostics.Process.Start("http://www.mywebsite.com"); However, if this url is invalid the application seems to have no way of knowing that the call failed or why. Is there a better way to launch a web browser? If ...

What's the best way to generate a Text file in a .net website?

I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server? Edit: to answer a question down below, this is going to be a download once and then throw-away kind of file. U...

Multi-line string in a PropertyGrid

Is there a built-in editor for a multi-line string in a PropertyGrid. ...

Windows Forms Threading and Events - most efficient way to hand off events?

My form receives asynchronous callbacks from another object on random worker threads. I have been passing the data to the main thread (where it can be used to update onscreen controls) using delegates as shown below. Performance is dreadful -- once I reach 500 updates per second, the program completely locks up. My GUI processing itse...

config file syntax for configuring WCF Webservice Client Target EndPoint

What is the web config syntax for specifying a WCF WebService Proxy's Default Target Endpoint? Specifically, I'm trying to configure the address that the client uses for locating the .asmx of the webservice ...

What's the best way to instantiate a generic from its name?

Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? If it helps, I know that the class implements IMyCustomInterface and is from an assembly loaded into the...

Call a certain method before each webservice call

Here's the situation. I have a webservice (C# 2.0), which consists of (mainly) a class inheriting from System.Web.Services.WebService. It contains a few methods, which all need to call a method that checks if they're authorized or not. Basically something like this (pardon the architecture, this is purely as an example ;)): public cl...

Auto-organize Visual Studio Tabs?

Is there any setting in Visual Studio 2008 to group/organize tabs? For example, I'd prefer to have all code-behind files open in a tab next to its .aspx page if that page is open and vice versa. Dragging tabs around really kills my productivity. ...

In .net, what's the best / safest way to add a "end of line" character to a text file?

I assume there must be a system and language independent way to just stick the "current" EOL character into a text file, but my MSDN-fu seems to be weak today. Bonus points if there is a way to do this in a web application that will put the correct EOL character for the current client's machine's OS, not the web server's. ...

Looking for a .NET Function that sums up number and instead of overflowing simply returns int.MaxValue

I use int.MaxValue as a penalty and sometimes I am computing the penalties together. Is there a function or how would you create one with the most grace and efficiency that does that. ie. 50 + 100 = 150 int.Max + 50 = int.Max and not int.Min + 50 ...

How do you check for permissions to write to a directory or file

I got a program that writes some data to a file using a method like the one below. public void ExportToFile(string filename) { using(FileStream fstream = new FileStream(filename,FileMode.Create)) using (TextWriter writer = new StreamWriter(fstream)) { // try catch block for write permissions writer.Wri...

Best way to swap two .NET controls based on radio buttons

I've got a form where I have two radio buttons and two interchangeable controls (made up of a ListView and a handful of buttons). Based on which radio button is selected I want to display the proper control to the user. The way I'm doing this now is just loading both controls and setting up an OnRadioButtonSelectionChanged() method whic...

Data visualization in desktop applications

I would like to create data visualizations in desktop apps, using frameworks, languages and libraries that help with this kind of task. Visualizations should be interactive: clickable, draggable, customizable, animated... What I would like to create is something similar to the examples seen here: http://www.visualcomplexity.com/vc/ Th...

.Net Multithreading: SQL ConnectionPool

In a VB.Net Windows Service I'm currently pooling units of work with: ThreadPool.QueueUserWorkItem(operation, nextQueueID) In each unit of work (or thread I'll use for ease of understanding), it will make a couple MSSQL operations like so: Using sqlcmd As New SqlCommand("", New SqlConnection(ConnString)) With sqlcmd ...

What is a .snk for?

Hi, What is a .snk file for? I know it stands for Strongly Named Key, but all explanations of what it is and how it works goes over my head. Is there any simple explanation on how a strongly named key is used and how it works? I'm using this in BizTalk server. ...

Forcing a ListView to draw in the background

I have a ListView which sometimes I need to put around 10000 items in. ListViews don't really handle this well, and they lock up for a couple of seconds while they sort the items and draw them. If you add the items in individually, it's even worse, locking up for nearly a minute. To get around this, I thought I'd try populating the List...