.net

Re-usability of controls within .NET MVC

I only know a small amount about .NET MVC and haven't used it barely at all so far but I was wondering how would you create re-useable controls that can be spread across different applications? We have various controls that have been created in external libraries and we reference the assembly if we want to use them. An example would be ...

How to do Joins in Linq using lambdas and the expression tree?

I'm trying to do a JOIN in Linq using lambda expressions ... and running into some problems. I have two entities, Comments and CommentSources. CommentSources are associated to Comments. I have the following code, which does work: 01 IQueryable<Data.Comment> query = ctx.DataContext.Comments; 02 03 04 if (criteria.IsDeleted == Delete...

Drawing a point on the screen

I need to read the color of and draw to a calculated point on the screen What is the VB.NET equivalent of the old Peek and Poke, or PointSet and PointGet, commands in older versions of VB. Or in the alternative, is there a way to use a label as a Cursor object, so that it does not erase my picturebox contents as I move it around. I ca...

Templating Engine to Generate Simple Reports in .NET

I'm looking for a free templating engine to generate simple reports. I want some basic features such as : Ability to Write Loops (with any IEnumerable) Passing Variables Passing Templates Files (main template, footer, header) I'll use this to generate reports in HTML and XML. I'm not looking for a ASP.NET Template Engine. This is fo...

What the best way to print the contents of the WPF web browser?

We use a modified version of the IE engine (the COM version in a C# wrapper) to display a lot of the formatted content in our application. The problem, however, is you don't have a lot of control of any printout of such documents. For example, you can't force a color printout without accessing the registry or directing the user to thei...

How to set the name of the file when streaming a Pdf in a browser?

Not sure exactly how to word this question ... so edits are welcomed! Anyway ... here goes. I am currently use Crystal Reports to generated Pdfs and just stream the output to the user. My code looks like the following: System.IO.MemoryStream stream = new System.IO.MemoryStream(); stream = (System.IO.MemoryStream)this.Report.ExportTo...

How to create a non OwnerDraw Button in .NET?

Hi, I'm creating a plugin to a software that skins the form I created. However, the button are not skin based on them and a standard gray button is shown. Asking on the software forum pointed me that .NET forms control are owner-draw and therefor my button won't redraw with the correct style instead of creating a non ownerdraw button. ...

Are there Weak References in .NET?

I would like to keep a list of a certain class of objects in my application. But I still want the object to be garbage collected. Can you create weak references in .NET? For reference: Garbage Collecting objects which keep track of their own instances in an internal Map Create a weak reference to an object Answer From MSDN: To e...

What is the .Net Client Profile PREVIEW?

I understand what the .Net Client Profile is, but what does "PREVIEW" mean? (http://www.microsoft.com/downloads/details.aspx?familyid=8CEA6CD1-15BC-4664-B27D-8CEBA808B28B&amp;displaylang=en) Is this like a beta release? Is it safe to deploy alongside my application? Thanks. ...

F# winforms MenuStrip problem: Not sure how to get a handle on DropDownItems

I have recently started learning F#, and this is the first time I've ever used WinForms. Here is my code. #light open System open System.Windows.Forms let form = let temp = new Form() let ms = new MenuStrip() let file = new ToolStripDropDownButton("File") ignore(ms.Items.Add(file)) ignore(file.DropDownItems.Add("Test...

How do you find out if your AD/AM instance is up and running via C#?

I saw a link to find out if AD was running, but am not too sure if the same applies to AD/AM. One caveat is that I should be able to check about any AD/AM instance (any domain) assuming I have permissions. ...

Can not round trip html format to clipboard.

I want to write Html format, but I can not even get a simple MSDN example of it to work. http://msdn.microsoft.com/en-us/library/tbfb3z56.aspx Does this console app, a clipboard round tripper, work for anyone? using System; using System.Windows; //Need to add a PresentationCore or System.Windows.Forms reference class Program { [...

How to write Unit Tests for Web Applications and Controls

I am just learning about Unit Testing. I am using NUnit to build tests for a VB.NET project. The project I'm working on is part of a framework which will be used by people who build ASP.NET websites. It includes a base class (which inherits System.Web.HttpApplication) that users of my framework will inherit their application class fro...

An Open Source Project, Can Teach Membership and Role Management For .NET

I want to see a basic project to learn how to organize membership and role management. Can you give me some open source project link about it? ...

Using scripts in a master page with ASP.NET MVC

I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master page. However, if I do (from my ~/Views/Shared/Site.Master): <script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script> Then that is literally wha...

How to test fluent-NHibernate's PersistenceSpecification.VerifyTheMappings with lists and relational objects?

How would you test this scenario? I've just started looking into NHibernate and having my first bash at TDD. So far I've really enjoyed it and have been using fluent-Nhibernate for my mapping of the classes. However I seem to be hitting a dead end when it comes to using the VerifyTheMappings method on PersistenceSpecification. Essenti...

WPF image resources

I come from a mostly web and a little bit Windows Forms background. For a new project, we will be using WPF. The WPF application will need 10 - 20 small icons and images for illustrative purposes. I am thinking about storing these in the assembly as embedded resources. Is that the right way to go ? How do I specify in XAML that an Imag...

Trusted subsystem on a single tier

Imagine a .NET application designed using a Layered architecture. Is it possible to use something like the trusted subsystem pattern when deploying all layers of an application to the same machine? Is this design insecure by default? ...

Where can I download the latest ngen.exe?

I am using ngen.exe (the .Net Native Image Generator) version 2.0.50727.312. Is this the latest version? If not, where can I download the latest version? This page on msdn... http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx ... does not appear to have a link to a download. If it matters, I need ngen.exe for .Net Framework 3.5. Th...

How to detect when laptop power cable has been disconnected?

OK that does it. For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it. Now I want to write a little C# program that detects when my power cable disconnects and then emits a nice long System beep. What API could I use for that? ...