.net

WPF: How to install thumb behavior in a Canvas?

I would like to have a Canvas that supports the DragDelta event. My first idea of how to do this was to make a ControlTemplate that includes a thumb. But I do not know how to do this correctly. How can I change the XAML below to make it compile, and what's the right way to install the DragDelta event handler? <UserControl.Resources> ...

Upload a Massive CSV File to SQL Server Database

Hi, I need to upload a massive (16GB, 65+ million records) CSV file to a single table in a SQL server 2005 database. Does anyone have any pointers on the best way to do this? Details I am currently using a C# console application (.NET framework 2.0) to split the import file into files of 50000 records, then process each file. I uplo...

WPF: Trigger animations on elements by name from EventTrigger on a dynamically created control

I have a Grid inside of an ItemsControl's DataTemplate, so there will be many copies of this grid. I want a mouse click on the grid to trigger the storyboard of an element outside of the DataTemplate. For example, I would like to animate Transform properties of a named element that exists elsewhere in the Window. Let's say my DataTemp...

What are the most useful, free .NET libraries?

Please ignore. DUPLICATE to http://stackoverflow.com/questions/662956/most-useful-free-net-libraries There's a similar question on SO for Java. I didn't see one for .NET. What are the best can't-live-without free (gratis and/or libre) .NET libraries? This is a poll, so please: Post only one library per answer to avoid duplicate an...

const Dictionary in c#

I have a class in C# that contains a Dictionary, which I want to create and ensure nothing as added, edited or removed from this dictionary as long as the class which contains it exists. readonly doesn't really help, once I tested and saw that I can add items after. Just for instance, I created an example: public class DictContainer { ...

Dynamically enumerating values for a property in .Net

You know how a TreeView control's ImageList property lists all ImageLists on a form? I need something similar, but with a list of strings. It's like an enumeration, but defined at runtime, with the object that exposes the property in a PropertyGrid. So, with a list of strings like { "foo", "bar", "grill" } the property should list those...

Is there an easy way to append lambdas and reuse the lambda name in order to create my Linq where condition?

I have a user control which takes a Func which it then gives to the Linq "Where" extension method of a IQueryable. The idea is that from the calling code, I can pass in the desired search function. I'd like to build this search function dynamically as such: Func<Order, bool> func == a => true; if (txtName.Text.Length > 0) { //add it...

In VS08, On F5, sometimes WCF service loaded correctly, sometimes I get a list of files

Sorry, but I am not sure what causes the problem, and the problem isn't happening right now. I'll have to describe from memory. So I've started creating WCF Service Applications. Sometimes, when press F5 to run the project I get the correct screen, a screen that says: Service1 Service You have created a Service. To test this service...

Parsing NHibernate exception text

I'm trying to get NHibernate to load some records for me (it's been partially set up, and is used for some other parts of the app already), and while working on an <any> mapping, I got this exception: [InvalidOperationException: any types do not have a unique referenced persister] Can somebody help me parse what they mean by this? I ...

Visual Studio "Start Debugging" vs. "Attach to Process"

I have a client/server application using the .Net 2.0 Framework. I'm using Visual Studio 2008 to build and manage code. When I run either a Debug or Release version of the application simply by starting the .exe, I get an insert statement on the database that tries to insert a "0" for the foreign key of a table, triggering an error beca...

.Net client vs Java Server with raw data

I am writting a .Net/C# client to a Java Server on Solaris. The Java server is writting Raw byte data in a Gziped format which I need to extract, but I am having trouble to read the data in the right buffer sizes. I read the message not-deterministicly incomplete or complete and can not read the second message in any case. I am reading ...

ShowPageSetupDialog Method

Is there any way to disable some of the functions on the ShowPageSetupDialog box that displays when the method is called? I only want the user to be able to choose portrait or landscape and customize the margins. The other functions should be disabled if possible. Thanks. ...

Paging in GridView using SqlDataSource

I have a GridView that accesses data from a SqlDataSource in DataSet mode. I have paging enabled and it works, but on large datasets it takes an extraordinarily long time to pull data. It seems like the SqlDatSource is pulling all the data, and then it's being paged at the UI level. This is obviously a lousy solution. I've looked at htt...

Communicate between a COM DLL and C#

I asked a question the other day regarding overlay icons. With help, I figured out how to get that working. Here's how an icon overlay works (as far as I understand): Before the shell draws an icon it contacts all the icon overlay handlers in the system to determine whether it should draw an overlay on the that particular icon. My se...

Windows service can't copy to file share

I have a windows service set to copy files from a local directory to a samba share. The service connects via a UNC path to the server (i.e. \remoteserver\shareddir). I have logged in as the user under which the service is running, and was able to both copy files and create files on the samba share, using the UNC path. However, when ru...

Client copying from server to same server, without roundtrip?

This is inspired by Does File.Copy() from a network share to another share on the same machine copy the file over the network? Is it possible, in .NET, for a client to get the server to copy a server file to a different location on the same server without round tripping the file via the client? Is there any in-build support for this ki...

In C#, how do I add event handlers to an object based on names?

I'm am trying to add event handlers to 'myObject' based on the name of an event or events. 'myObject' has an event called 'MyEvent' and I have a public event handler called 'MyEventHandler' (which I don't need to get by name but do it below to get a MethodInfo). This is what I have so far: EventInfo eventInfo = myObject.GetType().GetEv...

Ways in .NET to get an array of int from 0 to n

I'm searching the way(s) to fill an array with numbers from 0 to a random. For example, from 0 to 12 or 1999, etc. Of course, there is a for-loop: var arr = int[n]; for(int i = 0; i < n; i++) { arr[i] = i; } And I can make this method been an extension for Array class. But is there some more interesting ways? ...

What are these called <% ... %>? And what ways can they be used in a page.

In a .Net web form... What are these special tags called? I know of 2: <%-- comment --%> for comments and <%# used with Eval and Bind #> So what does the # signify? Are there more? I know you can put some basic logic and function calls in there but I've never found anything that really describes how that can be used and should be...

A bug in .NET?

It's with great hesitation that I pose this question because I know that whenever you think you've found a bug in something like the .NET framework it's probably just you doing something wrong. Never the less, I really can't figure out what has caused my current situation. I'm building a ray tracer in C# and in a special case the return...