.net

How do I set up NUnit to run my project's unit tests?

I'm starting to use NUnit to write test cases in C# and Visual Studio 2010 and .NET 4.0. I want to use NUnit to test against a DLL (a C# class library project)'s public functions. How do I set up NUnit to work with my project? Should I add UNnit code to the same class library project to test against? Or add a separate project in the...

Add Method Wizard in VS 2010 Express

How do I create Add Method Wizard in VS C# 2010 Express. It was something like right click on a class library and Add method in Visual Studio.Net 2003. Now when I right click on the class I don't see Add method menu. any Help please? Thanks ...

__CIasin and Is Arcsine much slower than sine in .NET?

I've been running som eprofile tests of a slow area of code. This is with Visual Studio 2008 and .NET 2 (fully patched). About 32% of my computation is used by the Haversine formula. This requires two sines, two cosines, a square root, and an arc sine - all using the standard .NET Math library (ie. Math.Sin, Math.Asin, Math.Sqrt). I've b...

HttpWebRequest: The request was aborted: The request was canceled

I am trying to send up an xml file and get back an xml file as a response. The file I am trying to send up is slightly over 20,000 KB. I tried adding a timeout, and setting keepalive to false, but neither one works. I've searched around but I can't find anything that is applicable to me. As of now I've just broken the file down and have ...

WPF IValueConverter - converting multiple values into a single value

Hello everyone, I'm trying to maintain someone else's code right now where that person is a WPF expert. I, on the other hand, am not. :) The code uses the IValueConverter to convert a state enumeration into a boolean which governs whether or not a UserControl is displayed on the screen. I've discovered a shortcoming that a single en...

What is the purpose of throwing specific exception subclasses?

Why is it preferable to throw this Exception Throw New DivideByZeroException("You can't divide by zero") over this general one: Throw New Exception("You can't divide by zero") What advantage is gained in this particular example? The message already tell it all. Do standard subclasses that inherit from the base Exception class ever ...

how to bind my view model properties to application settings?

My view model MyViewModel has a property MyProperty that i need to read/save from/to the application's settings. My project has Settings.settings file and the Settings type has MyProperty property. i need to bind MyViewModel.MyProperty to Settings.MyProperty so that any changes to MyViewModel.MyProperty are reflected in the Settings.MyPr...

no time display on grid view page

Hello, I am using SQL SERVER 2005, C# .NET. I want to diplay date only on my grid view page, currently it showing including time also. I am restoring date in table with file upload button click function. In my table i took Load date column data type is DateTime. Exaple in table column showing like 10/19/2010 12:00:00 AM On my grid vi...

Use unmanaged FindFirstVolume to enumerate volumes in C#

I am trying to enumerate drives that are mounted without a direve letter so I can obtain the remaining space on each of the drives. This application must work with Windows XP so the Win32_Volume class is not available. When the following code is executed, a System.ExecutionEngineException is thrown. using System; using System.Text; us...

Read object properties by reflection

In .NET I have and instance of class A which includes instances of classes B,C,D and some primitives(int, double, string,bool...). I need to read(and then write to text field) all properties(recursively) of instance, if property is another instance, then read its properties etc. But I don`t want to go into .NET types(strings,...). I try ...

Send Message with Custom Properties with Redemption

Hello. I’m using Redemption.dll to set custom properties to my messages with set_Filed() and get_field() in C#. Everything works perfectly until the moment I send my messages. From Outlook I use RDOMail.Send() and this sent the message to the Drafts folder. Then I read in the Redemption FAQ that I should use the IMessage::Submit() metho...

Entity Framework won't save relations

Hi I have the following situation: role.Permissions.Add(permission); objectContext.SaveChanges(); When I now take a look in the relations table Roles_Permissions the newly added permission to the role is not present. It only saves the new relation when I dispose the object context. Am I doing something wrong or does a call to SaveCha...

.NET pre-allocating memory vs ad-hoc allocation

Hi, I'm working on some applications that require very low latency and push a lot of memory and was doing some testing of how e.g. allocating a list ad-hoc vs. pre-allocating and clearing a list performs. I was expecting the test runs that pre-allocate the memory to perform a lot faster but to my surprise they're actually slightly slowe...

LIKE with Linq to Entities

I know the .Contains() method does like LIKE %therm%, the .StartsWith() method does like LIKE therm% and the .EndsWith() method like LIKE %therm but... Is there a way to do like below on **Linq to Entities**? SELECT * FROM [dbo].[Users] WHERE Name LIKE 'rodrigo%otavio%diniz%waltenberg' PS: I'M USING LINQ TO ENTITIES. NOT LINQ TO SQL ...

Cannot send a content-body with this verb-type.

Hello, I just got this exception (ProtocolViolationException) in my .NET 2.0 app (running on windows mobile 6 standard emulator). What confuses me is that as far as i know, I have not added any content body, unless I've inadvertently done it somehow. My code is below (very simple). Is there anything else i need to do to convince .NET...

Windows Mobile device states that the assembly System.Windows.Forms 2.0.0.0 cannot be found.

I am a newbie to .NET programming and I'm trying to create a simple Windows Forms application for a Windows Mobile device using the .NET Compact Framework 2.0. I develop using Boo and using Nant to build my application. My application compiles but it won't run. When I launch the application on my devices it states that the assembly Syste...

Why doesn't Entity Framework easily allow a custom base class?

Is this a design choice by Microsoft, or is there a way to do it, that I'm not aware of? ...

WebClient: Abort Download?

I'm using WebClient to mine a bunch of data. To conserve bandwidth (for both the client and web server), and speed my program up, I'd like to abort certain downloads early if it becomes evident that the file I'm downloading doesn't contain the information I'm looking for. I'd like to base this decision based on the headers (mime type an...

How to wrap a <myClass*, myClass*> C++ dictionary using SWIG for Python and .NET

Hi, I'm wrapping C++ code into Python and .NET code by using SWIG 2.0.0. I'm able to wrap a (myClass*, std::string) by introducing the following sentence in the "interface.i" file: %template(Dictionary_myClass_String) std::map<myClass*, std::string>; But I'm getting several errors if i try this: %template(Dictionary_myClass_myClass)...

Linq to SQL vs Access SQL - Why aren't Take() and TOP the same?

Sorry I couldn't come up with a better title, but it's kind of a convoluted question to begin with. I'm in the process of converting an access database over to the web, and I'm using linq to sql. In the access database, there is a SQL function that returns the top 3 records, ordered descending by # of individuals collected. For examp...