.net

C# - Displaying server control based on how many items are in a datalist

What I'm trying to do is on page load display either of two controls based on how many items are in a datalist. For instance, if the datalist only contains 1 item I want it to display Literal1.Visible = true; If there is more than 1 item in the datalist, show LiteralMulti.Visible = true; Anyone know how to do this? ...

Using .NET XmlSerializer for xml with different polymorphic roots.

I have XML docs with different roots coming from one source. I have a XSD schema just like described in this question, with the abstract='true' root element 'BaseElem' of a Base type, plus additional root elements Elem1, Elem2, ... that extend the Base type and use substitutionGroup='BaseElement' attribute. xsd.exe generates BaseElem an...

Binding an rdlc report with a business object

Is it possible to bind a rdlc report to a business object (.NET 4/VS 2010) In my report I have TextBoxes called Name and Email. Say I have an object Person with properties Name and Email. Can I bind the .rdlc with an object Person at runtime? ...

.NET - extract codec information from MPEG-TS

I am writing a streaming-application using VLC (VideoLAN) and its ActiveX-plugin. I am getting a stream from a satellite-decoder and now I need to get information from the stream (MPEG-TS) as to the subtitles present (for instance from a film) in the stream so I can tell the ActiveX-control which subtitle-language to use. In this case, s...

Testing classes with threads, events, and private methods

hey guys general consensus I've done quite a lot of reading up on the subject of testing complex classes and private methods. The general consensus seems to be: "if you need to test private methods then you're class is badly designed" "if your class is complex, then you need to separate it out" So, I need your help. the problem C...

How do you start knowing when to write code?

I've been a programmer for a few years now and I've noticed that my productivity increases and error rate decreases the less code I write. I favor collections over writing my own data structures and I've utilized libraries from various sources where I can (python packages, codeplex, etc). I'd like to take it a step further though and l...

Wix 3.5 and .net 4 custom action doesn't work

My custom action assembly doesn't work with wix 3.5. When I build custom action under .net 3.5 in propreties all works fine, but when change in project properties of custom actions assembly target framework to .net 4 - it fails with BadImageFormatException. Utility makesfxca.exe works fine with both - .net 3.5 and 4.0 ca assemblies. Co...

Enabling and disabling CDN via ScriptManager

I want to use the Microsoft's CDN for hosting the AJAX Library for my .NET 4.0 web application. However, I was asked to implement a fallback for when the CDN isn't available or when developers want to develop locally without internet. In these scenarios the ScriptManager should send the locally hosted copies rather than the CDN copies ...

Regex to parse functions with arbitrary depth

I'm parsing a simple language (Excel formulas) for the functions contained within. A function name must start with any letter, followed by any number of letters/numbers, and ending with an open paren (no spaces in between). For example MyFunc(. The function can contain any arguments, including other functions and must end with a close ...

Generate list of words based on microsoft word dictionary - Stops working at some point - why?

I wrote a small app that Generates words and then verifies them against Microsoft Word 2007 dictionary. This works great for me when I test it against the english dictionary with 3 letters length(and I guess with more letters) but for some reason it stops working when I try to run it against the hebrew dictionary. Does any one know why...

findResource() not working with DataTemplate

I defined a DataTemplate the following way: <s:SurfaceWindow.Resources> <ImageBrush x:Key="WindowBackground" Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/> <DataTemplate x:Key="ContainerItemTemplate"> <Grid> <Border BorderThickness="1" BorderBru...

the default search base directory is not appDomain.BaseDirectory?

hi, i created a appDomain in my application which base directory is different to my application directory, but it is under the application. i loaded an assembly in the created domain and create object instance from that domain. then i try to execute the method of the object. but i observe an odd behavior. public class Class1 : Mars...

.NET Garbage Collector difference between x86 / x64. x64 doesn't collect.

I have a WPF application which doesn't seem to garbage collect on x64 systems. I have tested it carefully on x86 machines and I am confident it isn't a programming problem, the memory usage will grow and then will be garbage collected as I expect. a) Some users access the application via terminal services on x64 Windows 2008 which is a ...

Create WPF Window at Runtime

Hi, Is it possible to create a WPF Window control at runtime? I'm thinking of a somewhat hack-ish solution to a problem, but I would essentially like to be able to have a dll which allows me to dynamically load a WPF Window and compile it's associated code behind (from an xaml and cs file respectivly). I assume I would also have to man...

Open source software vs. proprietary

Oh boy, this sounds like a magnet for religious warfare, but honestly - that is not what I intend from this question. Today, in a sales presentation, I got my butt kicked because I was trying to sell some software that our company wrote, and one of the audience members said, "Oh the govt should never buy anything from a small company, s...

Performing a DeepCopy(clone) when Events are Attached

When you have an object that provides events and you use a deepclone (serialisation) approach to cloning the object, how do you do it when there are events on the object that are actually attached. If my object declares an event, but nothing is attached then object can be cloned without issue. BUT if the object has had events attached,...

My generic type converter smells bad, exceptions at runtime, object as catch all, boxing etc.

Firstly, I've asked this question elsewhere, but meta.stackoverflow.com seems to think that asking the same questions elsewhere is fine, so here goes. I'll update both if/when I get an answer. I'm doing a lot of conversion between simple types and I wanted to handle it as nicely as possible. What I thought would be nice would be to be a...

Is an Extension Method the only way to add a function to an Enum?

I have a Direction Enum: Public Enum Direction Left Right Top Bottom End Enum And Sometimes I need to get the inverse, so it seems nice to write: SomeDirection.Inverse() But I can't put a method on an enum! However, I can add an Extension Method (VS2008+) to it. In VB, Extension Methods must be inside Modules. I r...

C# Making program wait untill brower finish loading webpage

HI , How do i make my program to wait until webpage finish loading before executing next statement.I tried Process::WaitForInputIdle(); but it doesnt wait . Any one has any idea.thanks ProcessStartInfo pInfo = new ProcessStartInfo("firefox.exe"); pInfo.Arguments = "http://xxx.com"; Process p = Process.Start(p...

Can I improve these Pagination extension methods?

I've just written a couple of pagination extension methods and I was curious to know if there was any improvements I could make. I'm pretty happy with the base pagination method, where you supply both the page size and page number (as seen below) public static IEnumerable<T> Paginate<T>(this IEnumerable<T> source, int pageSize, int...