.net

Visual Studio: Collecting the members of an interface in the same region

I find it useful to right-click on an interface, and click "Implement Interface." This will create any missing interface members in a new region. However, if your interface has recently changed (ie some of the members already exist, some do not) the members will not be placed together in the same region. Is there an easy way to collect ...

How can I make HttpContext available to be used by my Unit Tests?

Hi, I want to write a unit test which tests the function of a class called UploadedFile. The problem I face is this class' static constructor uses HttpContext.Current property and because I am running my unit test from a class library I do not have an HttpContext at the testing time. Look at my static constructor: static UploadedFil...

How can i fill Anonymous type in list?

I try to write some codes about Generate list from Anonymous type via below codes : public static List<T> MakeList<T>(T itemOftype) { List<T> newList = new List<T>(); newList.Add(itemOftype); return newList; } But ERROR return me: A primary key field specified via the KeyFieldName property is not found in the underl...

Which approach to take with this multithreading problem?

Short question: I would like to spawn a single background thread that would process work items submitted to a queue (like a threadpool with one thread). Some of the work items are capable of reporting progress, some are not. Which one of the .NET's myriad of multithreading approaches should I use? Long explanation (to avoid asking ab...

.Net Application references another .Net Application in same .sln, referenced App's .exe.config not being copied over?

One console application in a .net solution references another console application in the same solution but when building the first one, the second/referenced one's secondapp.exe.config file is not being deployed over.. does anyone know why or how I could do that? ...

.Net MDIForm eating usercontrol keydown events

Hi Guys, I wonder if any one has experienced the following issue and can give me some pointers. We have an MID form with Cut, Copy, Paste, and Delete child menu items of a menuItem called Edit. Each of these child menu items has the ShortcutKeys property set with CTRL+X, CTRL+C, CTL+V, and Del, respectively. The short cut key and combi...

Zlib compresion technique in asp.net

I am new to .net. I created one website.I want to implement Zlib compression technique for compressing data in each every page, so that i can access open my website quickly.But i don't know where I have to write code for that and how to implement it. Can yo send me the sample application code or zip file. ...

A component for page flipping when viewing a pdf in .Net

Hi I have developed an asp.net web application which will generate report pack for various customers. We will convert them to pdfs. Our requirement is to provide viewing of PDF document in the website itself with flipping effect. For a sample please click the below link. http://viewer.zmags.com/showmag.php?magid=174428#/page18/ How can...

What's the point of writing a dynamic query in a stored procedure.

If we need some information that can be achieved only through dynamic query then should not it be written in the application code directly (in DAL) rather than in the stored procedure? Because the benefit we achieve from SP is already lost if we use dynamic query in it which is the already saved execution execution plan along with it. ...

.NET version of Java's assertGC: Unit tesing memory leaks

I am trying to write a unit test using .NET 4 to ensure that an object can be garbage collected after some code is run. In Java, I would use assertGC to ensure that a weak reference is collected. How can I write this type of test for .NET? I have tried keeping a WeakReference to the object and calling GC.Collect(), but as you'd expect, ...

What advantages does method chaining have over plain imperative method calls?

Look at this example code, from a Telerik MVC grid: <% Html.Telerik().Grid(Model.InstallerList) .Name("InstallerGrid") .DataKeys(key => key.Add(c => c.InstallerID)) .Columns(column => { column.Template(action => {%> <%= Html.ActionLink("Edit", "Edit", new{ id = action.InstallerID}) %> ...

Silverlight repeat behavior in visual state.

I have visual state = loading. And i need in this visual state show loading circle with always repeated animation. But it repeats only once! How can i set repeat behavior to forever?? <VisualState x:Name="LoadingChildNodes"> <Storyboard RepeatBehavior="Forever" AutoReverse="False"> ...

ListView ItemCreated postback

Hi, I'm a bit lost here with how the ListView works. When my ListView is created I do some coloring depending of the data in the result set. protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e) { DataRow myRow; DataRowView myRowView; myRowView = (DataRowView)e.Item.DataItem; myRow = myRowView.Ro...

Nullable enum or an additional element

Consider the following Enum and a corrsponding nullable field of that type enum PossibleOptions { One, Two } PossibleOptions? option; Alternatively I could declare the enum and the corresponding field as enum PossibleOptions { Unspecified, One, Two } PossibleOptions option; This non-nullable field would be initialized to the fir...

silverlight speech to text

Hello, Does anybody knows if it's possible to record a voice and transcribe it to text in real time? I want to do that with silverlight or if it's not possible with the standard .Net framework thanks for help ...

Converting COM DLL to .NET DLL is Possible?

I have a WIN32 COM DLL. And I want to Convert .NET DLL. Is it possible? Thanks. ...

Is Team Foundation Server the right solution to automatically publish .net website to remote server?

We currently build our .net website in C# in Visual Studio 2010 Pro on our dev server, then manually publish it and upload to the live server where it is copied over the current files to go live. We want to automate this process as much as possible and if possible push it at a certain time, such as every day at midnight. We don't curren...

What is the value of Exception factories?

In looking at some code reflected from the WCF libraries, I'm seeing a pattern used to create exceptions: if(argument == null) { throw Error.ArgumentNull("argument"); } Null arguments being the simplest example, with other types of exceptions available through the static error class. What is the value of this factory pattern? Why...

DataContractSerializer problem with events/delegate fields

On my WPF application, I am using DataContractSerializer to serialize object. I observed that it fails to serialize the types that has got an event or delegate declaration. Consider the following failing code: [Serializable] public abstract class BaseClass { public string Name { get; set; } public event PropertyChangedEventHand...

Why does this simple .NET console app have so many threads?

This simple program starts with 15 threads - according to the count. Sometimes during its lifetime it drops a few, but they come back. class Program { static void Main(string[] args) { while (true) { Console.WriteLine(Process.GetCurrentProcess().Threads.Count); Thread.Sleep(500); ...