.net

NUnit Test - How to use it in your application

Can anyone tell me what is NUnit in .NET and how to use it? I have heard that using this tools improves design of an application. Is it true? Where can I get an absolute beginners tutorial on this topic? ...

C# and PostgreSQL

Can any one show me working example of using cursor returned from PLSQL to c# code? I found many examples showing how to fill dataSet with returned data but I cannot find how to use that cursor with DataReader, as a result I have {unnamed portal}. NpgsqlTransaction tr = (NpgsqlTransaction) Connection.BeginTransaction(); NpgsqlCommand cu...

How to return many Child Collections Count() in a single entity framework query.

I have two entities, Parent and Child, in Entity Framework. The parent has a collection of Child entities. In my query, I want to return only the Parent entities (the fully typed EF types) and also the Count() of the Child entities (this could be set to a property on the Parent), but I only want to do this in one call to the database, ...

problem with System.Activator.CreateInstance

Hi, I'm trying to use System.Activator.CreatInstance to Create an object based on the typeName. I'm using the following code: Object DataInstance = System.Activator.CreateInstance( System.Reflection.Assembly.GetExecutingAssembly().FullName, "CMS.DataAccess.SQLWebSite"); IWebSite NewWebPage =...

How to display clickable formatted text in .NET CF?

Hi, I'm doing a kind of dictionary for .NET CF. I'm trying to display formatted text in which all (or some) words are 'clickable' -- in which I means if one clicks on it, it should fire an event telling me which word was clicked. However, .NET CF 3.5 only supplies me with WebBrowser, which I could use for displaying formatted text, but...

SqlMetal wrongly generates the return type of my stored proc (LINQ)

Hi, Hi have a stored proc that always returns a single row depending of a parameter: IF @bleh = 1 SELECT TOP 1 Xyz FROM Abc ELSE SELECT TOP 1 Def FROM Abc I must use SqlMetal to generate the DataContext but this stored procedure returns a IMultipleResults, which is an error. Instead it should return a ISingleResult... If I remov...

How do I represent a time only value in .NET?

Is there is way in which one can represent a time only value in .NET without the date? For example, indicating the opening time of a shop? TimeSpan indicates a range, whereas I only want to store a time value. Using DateTime to indicate this would result in new DateTime(1,1,1,8,30,0) which is not really desirable. ...

System.Drawing.Image.Save throws ExternalException: A generic error occurred in GDI

I have function which takes a bitmap, copies part of it and saves it as 8bpp tiff. Filename of the result image is unique and file doesn't exist, program has permission to write to the target folder. void CropImage(Bitmap map) { Bitmap croped = new Bitmap(200, 50); using (Graphics g = Graphics.FromImage(croped)) { ...

Programmatically access the "Open with" Windows Explorer menu list from .NET

When right-clicking a file in Windows Explorer, the "Open with" menu item displays a list of available applications, based on the file type of the clicked file. See this picture as an example: Now I want to be able to programmatically read the list of applications for a given file extension/type (e.g. "png") from within a C# .NET 2.0...

how to use javascript and css in WebPart?

Hello everyone, I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am using publishing portal template. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. And I want to develop a WebPart, which refers css and javascript (.js) files. My question is (1) how to deploy css/javascript files and (2) ho...

Remove all problematic characters in an intelligent way in C#

Is there any .Net library to remove all problematic characters of a string and only leave alphanumeric, hyphen and underscore (or similar subset) in an intelligent way? This is for using in URLs, file names, etc. I'm looking for something similar to stringex which can do the following: A simple prelude "simple English".to_url =...

.NET exception doesn't get passed from class to main program

I created a simple console application using C#. It creates an instance of a class and calls one of the class' methods. This method contains a try-catch block to catch exceptions of the type System.Net.WebException and rethrow it so that the main method can catch it and act appropriately. When I execute the compiled application the excep...

Which overload is called and how?

I wrote some extensions methods to handle the css class like how you would do it in jQuery. Since I'm using ASP.NET the framework has two extension points i need to handle. The first one is System.Web.UI.WebControls.WebControl public static bool HasCssClass(this WebControl control, string className) public static void AddCssClass(this ...

Is there any WCF equivalent in any platform other than .NET?

In other platforms can I develop a service without worrying about addresses and bindings? What is the name of equivalent technologies for Java, Python and other environments? Edit: For those who are unfamiliar with WCF, this is a part of the .NET 3.x framework whose main feature is to enable developing services that can answer multiple ...

Changing foreach iteration variable and implementation differences between C# and C++/CLI

Consider the following C# code. string[] stringArray = new string[10]; foreach (string s in stringArray) s = "a new string"; // Compiler error - Can't assign to foreach iteration variable Now consider the following valid C++/CLI code. array<String^>^ stringArray = gcnew array<String^>(10); for each(String^% s in stringArray) ...

C#: Filter the members of an object

I have a model public class User : EntityObject { public int Id { get; set; } public string Username { get; set; } public string Password { get; set; } } and I would like to return to the client a JSON result containing only the Username and Password members of the User. I am currently doing this like so return Json(new...

Get typeof(...).Name using Spring.NET

Is there a way to get the string representation of an interface using Spring.NET? In code: typeof(ISsoUrlTemplateRepository).Name I would need this name in Spring.NET configuration... I could just take the string itself but if I would ever refactor and change the names of some interfaces, the Spring configuration wouldn't work anymor...

A library for analyzing executables

There are tools like Dependency Walker, dumpbin, ildasm for looking into DLLs/EXE files on Windows. I would like to analyze DLLs from code, especially dependencies both managed and unmanaged. Are there any (.NET) libraries out there for analyzing with similar functionality? I want to use this to verify that we am deploying the right DLL...

Is there a way to prevent WinForms controls in a WPF window from being unstyled?

I have some WinForms controls that I need to use in a WPF window. I'm able to get the controls to show up just fine and everything works as I would expect, but I'm experiencing one issue: all the WinForms controls are unstyled. I'd like for the WinForms controls to at least use the default OS style (like I would see in a WinForms applic...

Feasibility of shared code between .NET and Silverlight?

Having just gone through a small experimenting session to try to see how much work it would take to bring our .NET class library, or at least portions of it, into Silverlight so that we can reuse business logic between the two worlds, I'm wondering if others have experience with this sort of thing. The things I noticed, off the top of m...