.net

Writing Extension methods with Action / Func / Delegates / Lambda in VB and C#

hey guys. Firstly I can't get my head around the functional / Lambda aspects of .NET 3.5. I use these features everyday in LINQ, but my problem is understanding the implementation, and what they really mean (Lambda? System.Func? etc etc) With this in mind, how would the following be achieved: As an example, I'd like to have an Extensi...

How can I customize category sorting on a PropertyGrid?

How can I customize the sorting of categories in a PropertyGrid? If I set either of the following... propertyGrid.PropertySort = PropertySort.Categorized; propertyGrid.PropertySort = PropertySort.CategorizedAlphabetical; ... then the categories will be alphabetized. ("Alphabetical" would seem to apply to the properties within each ca...

Who should install a shared .NET library to the GAC? The framework that provides the library? Each application that uses it? Both?

This is more of a philosophical question, perhaps. Let's say I have a framework of some sort and I decide to provide a .NET library that makes the use of certain aspects of the framework easier. I don't want each application that uses the framework to carry a copy of the library locally, so I want it in the GAC (even with all the mainte...

Sorting a list with paths by deepest directory

Hello. I need to sort a list that contains paths (relative or absolute) so that the deepest path appears first, for example: \New Folder\Item1\tools\1 \New Folder\Item1\tools \New Folder\Item1 \New Folder etc... Is there an API in Path class I can use to do it? Thanks! J. ...

Type Caching

I have this scenario: i have a assembly with my business object types and this assembly is loaded with reflection at runtime(Assembly.LoadFile) in WCF with KnownTypesProvider but this assembly maybe can change (some developer add a new method or new property o even change some functionality maybe bugfix) but using Assembly.LoadFile the ...

Apply function to all elements of collection through LINQ

Hi I have recently started off with LINQ and its amazing. I was wondering if LINQ would allow me to apply a function - any function - to all the elements of a collection, without using foreach. Something like python lambda functions. For example if I have a int list, Can I add a constant to every element using LINQ If i have a DB tabl...

Stack capacity in C#

Hi All, Could one say me how much the stack capacity is in C#. I am trying to form 3D mesh closed object by using an array of 30.000 items. Thanks in advance George ARKIN ...

Loading XDocument while validating against schema in .NET 3.5

Input is xml as a string and I have a XSD schema to verify against. I wish to validate the xml against the XSD schema while loading the xml into an XDocument (requirement since I need to do parsing with Linq afterwards). Anyone has a small code-snippet? ...

C#, List<T>.Contains() - too slow?

Could anyone explain me why the generics list's Contains() function is so slow? I have a List with about a million numbers, and the code that is constantly checking if there's a specific number within these numbers. I tried doing the same thing using Dictionary and the ContainsKey() function, and it was about 10-20 times faster than with...

How do I cancel standby and hibernate?

my application running in C#, using third party framework.it works as an UI for many application.my question is when my appplication is running and the system should not happen standby/hybernate OS operations. somehow i have to cancel the event for standby/hybernate raised by OS.please any one help my in this regards. Thanks Sun ...

How can I make all columns in a TableLayoutPanel autosize to exactly the same width?

Hi, I'm trying to create a fairly extensive UserControl incorporating square controls into the design, and allowing resizing. Because the design calls for squares, I need all the columns in my TableLayoutPanels to be the same width, so that the contained, docked controls are also square. Unfortunately, the behaviour of the TableLayoutPa...

How to add xsl stylesheet node to XML produced by XmlSerializer?

I have an WCF REST service which returns objects serialized with XmlSerializer. How can I add XSL stylesheet information (like the one below) to the output returned by the WCF service? <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="transforms/Customer.xsl"?> <Customer> <Name>Foo</Name> </Customer> My...

Inserting image over 3mb via linq-to-sql

New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) { DbServiceClient sc = new DbServiceClient(); abw = (AddBlobWindow)sender; fi = ((AddBlobWindow)sender).fi; if ((bool)((AddBlobWindow)sender).DialogResult) { blob = new Blob(); binBlob = new Binary(); bina...

How far to go overriding methods, properties, ... of a base class e.g. .net TreeNode class

I'm working on some application, that uses a TreeView control to represent business objects. Currently the link between business objects and TreeNodes is maintained through the Tag property of the TreeNode. Im not very happy with this, because I think the link is not "tight" enough. For example there could be an TreeNode object without a...

MVC with IIS 6

Hi there, I've read a couple of posts on this issue but still can't seem to get MVC working on IIS 6. I've mapped .mvc to aspnet_isapi.dll in IIS but get a 404 when I browse to my mapped URL which looks like this RouteTable.Routes.MapRoute("action", "api.mvc/{controller}/{action}", new {action = "Index"}); I then browse to //localhost...

Best way to serialize a wpf element tree to Xaml?

What is the best way to serialize a wpf element tree to xaml so that I can get a design time representation? XamlWriter.Save is having serious limitations, and it can provide only the run-time representation Probably Microsoft don't want any one to build a customized xaml designer with out much effort :( ...

WPF equivalent to TextRenderer

Hi, I have used TextRenderer to Measure the length of a string and therefore size a control appropiatly. Is there an equivalent in WPF or can I simply use TextRendered.MeasureString? Cheers, James ...

C#.NET start Outlook..?

Can I make C#.NET start outlook in the code? In VB6 we use object 'Outlook.Application' and write:' Set oOutlook = CreateObject("Outlook.Application") Set oNameSpace = oOutlook.GetNamespace("MAPI") Set oInbox = oNameSpace.Folders(1) 'Set oInbox = oInbox.Folders("Inbox") oInbox.Display 'oOutlook.Quit 'Close All Outlook copies Co...

wcf json web service

What is the best way to create a JSON web service? We have another team that is using Java and they insist to having all communication done using JSON. I would prefer to use WCF rather than any 3rd party framework. I found this blog: http://www.west-wind.com/weblog/posts/164419.aspx, and it suggests that the Microsoft implementation is ...

How do I give my .net app secondary locations to look for dependent assemblies?

I'm sure this was asked somewhere in another question, but the wording used there obviously is not generic enough to find easily. How do I tell my windows forms application about secondary locations that it can find assemblies that it may need at run time? I'm not talking about using reflection to discover plugins, but rather dependenci...