.net-4.0

When to use Partitioner class?

Can anyone suggest typical scenarios where Partitioner class introduced in .NET 4.0 can/should be used? ...

ListView and DataPager implementation in FW 3.5 works but misbehaves when project migrated to FW 4.0

I have 2 listviews in an asp.net page. Both use a datapager with a dropdown (showing X of X pages, each listview can show just 5 records in a single list page). Based on selection in the first, I show some items in the second listview and I also have ability to add new items in the second one. When I add new items in the second listview...

What is the fastest code to call multiple stored procedures?

Solution 1 : foreach (var item in itemList) { myContext.ExecuteStoreCommand("EXEC MyProc {0};", item); // Insertion } or Solution 2 : StringBuilder sb = new StringBuilder(); foreach (var item in itemList) { sb.AppendLine(String.Format("EXEC MyProc {0};", item)); // Insertion } myContext.ExecuteStoreCommand(sb.ToString()); ...

Problem deploying WPF application

I created an installer for it, installed .NET Framework 4 on target machine. However, my application didn't work. I've got a message, that is has stopped working and offered to send a report. Windows log: The name of the offending module: KERNELBASE.dll, version: 6.1.7600.16385 Exception Code: 0xe0434352 Offset error: 0x00009617 ...

A simple C# question I hope! Add additional properties to Buttons

hi on a windows form (not WPF) I dynamically create buttons on a flowlayout and I would like to add some properties to them simply to store other values (int and string) with the buttons for latter use. Button bn = new Button(); bn.Text = "mybutton"; bn.Name = "mybutton"; toolTip1.SetT...

Data-driven testing in NUnit?

In MSTest you can do something like: [TestMethod] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "testdata.csv", "testdata#csv", DataAccessMethod.Sequential)] public void TestSomething() { double column1 = Convert.ToDouble(TestContext.DataRow["column1"]); ... Assert.AreEqual(...); } What is the equivalent c...

Compiling .NET 3.5 project using .NET 4.0 compiler

I have a solution that contains several projects. One of the test projects is using .NET 4.0 due to a dependency. The deploy-able project I want to build is targeted against the .NET 3.5 compiler. Our current build script is not granular enough to target different .NET compilers on a project by project basis. Basically I can only use...

Awesome HTML minifying function but causes problem at Google Adsense ads - Very Important !

function works perfectly. it makes source code single line. but problem is about Google Adsense ads. their locations get messed up. what might be the reason ? programming language is c# asp.net 4.0 here the function protected override void Render(HtmlTextWriter writer) { if (this.Request.Headers["X-MicrosoftAjax"] != "Delta=tr...

Providing update notification from DomainService to DomainContext

I need to inform the DomainContext in the silverlight application about changes that are made on the serverside (aka. Model of the DomainService). Does the DomainService or other classes for RIA Services provide such notification (like Events) or do i have to call a method on the DomainService periodically to check if changes where made...

Linq read XML doc with missing nodes

Hi I want to read an XML document but it may have some of the node missing and if so I want to use a defualt value for the missing nodes. XDocument xmlDoc = XDocument.Load(Path.Combine(Application.StartupPath, "queues.xml")); var q = from c in xmlDoc.Root.Descendants("Queue") select new Queue {...

XmlSchema object from an XML file with inlined Xsd

Hi, In .Net, I'm trying to get a XmlSchema object from Xml file with an embedded Xsd and can not find out how to do it? anybody know? For example if it just an Xml file I can Infer Schema using the XmlSchemaInference class or if its a Xsd I can use XmlSchema class, but can not find away with inlined Xsd. example file is at http://past...

log4net doesn't log when running a .Net 4.0 Windows application built in Release mode

I have a .Net 4.0 windows service application that uses log4net. Here's my log4net config. <log4net> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{Context}] - %message%newline" /> ...

nHibernate - Iterate properties of a class to generically add parameters for stored procedure

I want to have a class that defines my parameter data for a stored procedure. It's going to be a very simple object: public class MyQueryData : SprocObjectBase { public int Value1 { get; set; } public string Value2 { get; set; } public bool Value3 { get; set; } ... } It will inherit from a base class with shared values, like...

WHY! doesn't this dispose of all the objects on the flow panel!?

WHY! doesn't this dispose of all the objects on the flow panel!? the count shows 5 and there are 5 buttonsWithProperties on the form, no other objects are on the form. foreach (ButtonWithProperties itemButton in flowLayoutPanel1.Controls) { itemButton.Dispose(); } It disposes 3 of the object but not the las...

Recommend a good .NET 4.0/SQL Server 2008 web host (shared platform)

Hi all, This is my first question so play nice!!! I've done a search and could only find similar questions relating to .NET 3.5 last year so I thought I'd ask for people's recommendations at this point in time regarding a good web host to use for a small e-commerce website that will run on .NET 4.0 with a SQL Server 2008 back end. Opi...

template field visible only in insert mode

Hi, Is it possibile to have templateField from detailsView visible only in inserMode? <asp:TemplateField HeaderText="My Header" SortExpression="TypeName" Visible='<%# Eval("DetailsView1.CurrentMode == DetailsViewMode.Insert")%>'> this doesnt work exception is: Databinding expressions are only supported on objects that have a DataBi...

Could not load type 'System.Web.Mvc.ViewMasterPage<dynamic>'.?

I am deploying a Asp.Net MVC 2.0 application on IIS 6.0. When I request any page I get the following error. Parser Error Message: Could not load type 'System.Web.Mvc.ViewMasterPage<dynamic>'. Source Error: Line 1: <%@ Master Language="C#" Inherits= "System.Web.Mvc.ViewMasterPage<dynamic>" %> Line 2: <%@ Import N...

How can I protect and test security of a WCF service?

Hi how can I protect my WCF service and how can I test its security? For example, I do not want to allow people who knows the WCF service url to invoke it and pass parameters to get database information. Later, should I create a C# console program to invoke this WCF service in order to test if an invalid visitor really can't access d...

Getting around base64 encoding with WCF

I'm using WCF, REST and "pretty URI's" as shown in this blog post with the Online Template for VS 2010 .NET 4.0: http://christopherdeweese.com/blog2/post/drop-the-soap-wcf-rest-and-pretty-uris-in-net-4 I have one problem though. I want to return a a raw byte[] array but it automatically gets base64 encoded. Unfortunately for my program ...