.net

Animation inside an adorner (calling OnRender)

I'm using an Adorner in .NET 3.5, and I'm able to draw by overriding OnRender, but I need the ability to redraw the adorner to change its appearance. Essentially I'm looking for a way to clear the drawing context and call OnRender again. What's the best way to do this, or is there a better approach? public class MyAdorner : Adorner { ...

How can I mark generated methods obsolete?

I'm using a strongly typed DataSet for which manually adding rows will be error prone. I'm providing factory methods to create rows properly. I'd like to guide consumers of my class away from the generated Add*Row methods on the *Table classes. Adding Obsolete attributes to the generated methods would do the trick. Sadly, they would be...

Should you use pointers (unsafe code) in C#?

Should you use pointers in your C# code? What are the benefits? Is it recommend by The Man (Microsoft)? ...

VLC Server Communication with .NET C#

I am working on a project that allows for video streaming or video-on-demand. I've looked for software packages and VLC looks like an excellent choice for low cost needs. In order to really work with this application I need an API that can communicate with the system. After doing some research there were some bindings via PHP and Java b...

How to make a form resize vertically and horizontally when a control grows?

(WinForms .net 2.0) I'm making a form which, much like the standard MessageBox, has a single label on it and should grow horizontally and vertically if the text on the label grows. Horizontal seems easy enough, by setting AutoSize = true on the label and the form. However, I also want to make the label grow vertically, ie if it has newl...

C# .NET passing a collection of InterfaceImplementingClass objects to a routine that takes a collection of Interface objects

I have a routine public void SomeRoutine(List<IFormattable> list) { ... } I then try to call this routine List<Guid>list = new List<Guid>(); list.Add(Guid.NewGuid()); SomeRoutine(list); And it fails with a compile-time error. System.Guid implements IFormattable, but the error I get is cannot convert from 'System.Collections....

How to keep the windows install dialog from popping up in .NET?

When a user installs my application how do I keep User Account Control from producing this dialog? And no I don't want to tell them to disable UAC. ...

how to add the namespace automatically on every new Page, Control added To a WebSite in VS2008?

how to add the namespace automatically on every new Page, Control added To a WebSite in VS2008? when i add a new page the code behind looks like this public partial class MyNewPage : System.Web.UI.Page { } i just want the page wrapped into a namespace as below: namespace Project.Web { public partial class MyNewPa...

What's the point of overriding Dispose(bool disposing) in .NET?

If I write a class in C# that implements IDisposable, why isn't is sufficient for me to simply implement public void Dispose(){ ... } to handle freeing any unmanaged resources? Is protected virtual void Dispose(bool disposing){ ... } always necessary, sometimes necessary, or something else altogether? ...

How do I do Print Preview when using a DocumentPaginator to print?

I'm using a class I've derived from DocumentPaginator (see below) to print simple (text only) reports from a WPF application. I've got it so that everything prints correctly, But how do I get it to do a print preview before printing? I have a feeling I need to use a DocumentViewer but I can't figure out how. Here's my Paginator Class: ...

How to use Default column value from DataBase in Entity Framework?

I have a Date column in table which has default value or binding as getutcdate(). I want to use this in entity framework.On generating EDM I was able to find "Default Value " property at column level but I think it is for hardcoded value. Please let me know how can I use default value specified in database. Thanks, Mak ...

Code Contracts, will you use them?

Microsoft just released Code Contracts, a tool that integrates with Visual Studio and allows you to define contracts for your .Net code and get runtime and compile time checking. Watch the video on Channel 9 that shows how it being used. For now it's an add-on but it will be part of the Base Class Library in .Net 4.0 Is this something...

How to display a Reporting Services report as an inline PDF, in a ASP.Net and C# web page?

I need to display a preview of a report, in an ASP.Net web page (using C# server side scripts). The preview needs to be a PDF rather than HTML and displayed inline (possibly in an iframe?). Is it possible to specify the headers of a report rendered as a PDF, so its 'Content-Disposition' is inline rather than attachment? Or is there an...

Casting DateTime to OracleTimeStampTZ

Shortly before saving a DateTime to the datebase I'm casting a DateTime into an OracleTimeStampTZ. This converts the DateTime into an OracleTimeStampTZ in the current timezone, which is cool, that's what I want. Except the timezone is represented as a time off set (+13, since I'm in NZ). Now I'm a little afraid that this is going to bit...

Test whether a property is declared in the derived class

I have two classes public class A { public int BaseA {get;set;} } public Class B: A { public int BaseB {get;set;} } I can get the Properties for the Class B by using typeof(B).GetProperties(). However, this would include both the BaseA and BaseB properties. But I want to obtain the BaseB property only. Note: I found the solution...

What are the known limitations of ADO.NET entity framework designer?

We just found an issue like, when a foreign key relationship is broken, there is no way to re-establish the link in the designer. Any other such known limitations of Entity Framework designer? ...

Windows - Map a Keyboard Key to the Same Action as Left Mouse Button

Is the a programmatic way (or something more simple) to map some keyboard key to the same action windows-wide as the left mouse button in Windows XP / Vista. If programmatic is there a way to do this in .NET 2.0 (or greater)? ...

Creating and intialising different sub-types without lots of casting

Boy, I am sure am messing around with a lot of casting and such in this code below. It seems like there should be a smoother way. I'm basically trying to use a builder method (CreateNewPattern) to handle creating new objects of the passed sub-class type (by the CreateNewCircularPattern and CreateNewLinePattern methods). I presently only ...

To what extent are interop definitions covered under their original license

I have a project that creates thumbnails for a video file, it is heavily based off interop definitions in directshow.net. At the moment media browser is GPL so everything is compatible and I'm all good to have cut and pasted this code (since its all attributed properly). But... I'm looking at including this code in a derivative MIT l...

Using a COM DLL in delphi - Access violation in MSVCR80D.dll error

I need to use a DLL created using .NET framework. This DLL is made COM visible. I want to use this DLL in an application created using Delphi 2006. I have followed following steps: Registered the DLL using regscr32. Imported the type library using Delphi IDE. It created _TLB.pas file. Following signature was created in TLB file. fun...