.net

Displaying a Second Form in WPF

I have a main form and as sub form. I need the main Form to display the sub Form and pass into the constructor an object. When the sub Form is done it needs to destroy itself so the cycle can be repeated. Currently I declared the sub form globaly Public GlobalWindowBookmark As WindowEditBookmark I then create the form and pass it ...

C# Syntax - Your preferred practice for getting 2 or 3 answers from a method

I'm just wondering how other developers tackle this issue of getting 2 or 3 answers from a method. 1) return a object[] 2) return a custom class 3) use an out or ref keyword on multiple variables 4) write or borrow (F#) a simple Tuple<> generic class http://slideguitarist.blogspot.com/2008/02/whats-f-tuple.html I'm working on some cod...

How to add an image to ListView column header?

It should be easy, right? Have a listview, add an imagelist, add images to the imagelist, assign image index to the column you want. But, it doesn't work. Microsoft article states that it is a known problem in .NET 1.1. But has it been fixed since? ...

Which are the examples for contra guideline implementations/misnomers in .net/java framework?

I can remember Convert class in .net which is named not in accordance with the guide lines. Any more examples? ...

Programatically Break Apart a PDF created by a scanner into separate PDF documents

I have PDF documents from a scanner. This PDF contain forms filled out and signed by staff for a days work. I want to place a bar code or standard area for OCR text on every form type so the batch scan can be programatically broken apart into separate PDF document based on form type. I would like to do this in Microsoft .net 2.0 I c...

COM interop assembly loading sequence

There is very strange assembly reference problem and loading problem I experience with my Outlook addin. Here are the detail (a long story :) ): I have an old Outlook addin, written and build using .Net 1.1. The addin is loaded using an unmanaged shim in its own application domain. It works OK, with .Net 2.0, even if 1.1 is not present ...

String as char[] array in C# 3.0?

The C# 3.0 spec has the following code example in section 10.6.1.3 "Output parameters": using System; class Test { static void SplitPath(string path, out string dir, out string name) { int i = path.Length; while (i > 0) { char ch = path[i – 1]; if (ch == '\\' || ch == '/' || ch == ':') break; i--; } ...

.NET [SuppressMessage] attributes in shipping assemblies fxcop

I wonder if people (meaning the company/developers) really care about having [SuppressMessage] attributes lying around in the shipping assemblies. Creating separate configs in the Project files that include CODE_ANALYSIS in Release mode and then yanking it off in the final build seems kind of an avoidable overhead to me. What'll be the...

C# assembly.load from a byte[] issues

I have an EXE loaded into a byte array, and I am trying to load it into an assembly object using Assembly.Load. I am getting errors trying to load. Here is the code that is causing the exception: Assembly a = Assembly.Load(bin); bin is my byte array, loaded from the EXE. Here is the exception I am getting: Could not load file o...

Why is the Pair in System.Web.UI?

To me at least, the Pair class is a very multi-purpose class. So why did Microsoft put it into the System.Web.UI namespace? Is there a reason that my tiny brain cannot comprehend? Thanks. ...

How do I store a dictionary object in my web.config file?

I'd like to store a simple key/value string dictionary in my web config file. Visual Studio makes it easy to store a string collection(see sample below) but I'm not sure how to do it with a dictionary collection. <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt...

.Net framework version in Silverlight: no List<T>.Find methods?

Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have a number of the useful extension methods I've come to love, such as Find, FindAll, FindIndex, Exists, RemoveAll, etc. The object browser in VS2008 shows that those methods exist in the mscorlib version I'm using, but if I look at ...

Trap Key Entries to Digits and Cap Alphas in Textbox

In WPF need to trap the keys entered in a textblock to keep the user from entering anything but digits,cap letters and navigation keys (Backspace, Arrows, etc). Thanks! ...

Use custom font with a COM Object in .NET

I am trying o load a custom font in C#, so it is usable by COM libraries (like ESRI) and by GDI+. I want to load the font from disk and don't want to install the font on the system. COM font is of type stdole.IFontDisp. EDIT: using in AddFontResourceEx combination with the PrivateFontCollection solves the issue. ...

C# VS.NET 2008 Changing settings per configuration

Is there a way to have different application settings per each build configuration? I would like to be able to batch build a few configurations with different settings, instead of having to change the settings and build, rinse repeat. Thanks in advance! ...

: this(foo) syntax in C# constructors?

Every now and then, I bump into syntax that I've seen before, but never used. This is one of those times. Can someone explain the purpose of ":this" or ":base" following a C# constructor method? For example: public MyClass(SomeArg arg) : this(new SomethingElse(), arg) { } My gut feeling is that it is used to map a default argument o...

selectedIndex is lost during postbacks - ASP.NET

I have a list box control: <asp:ListBox runat="server" id="lbox" autoPostBack="true" /> The code behind resembles: private void Page_Load(object sender, System.EventArgs e) { lbox.SelectedIndexChanged+=new EventHandler(lbox_SelectedIndexChanged); if(!Page.IsPostBack) { LoadData(); } } private LoadData()...

What is special about HashSet<T> in .NET 3.5?

Here's an interesting puzzle. I downloaded Snippet Compiler to try some stuff out, and wanted to write the following code: using System; using System.Collections.Generic; public class MyClass { public static void RunSnippet() { HashSet<int> h = new HashSet<int>(); } } But the above code doesn't compile. I get: "...

How to Set the type of the Identity & Principle objects in WPF & WinForms

In ASP.Net when you're using Master Pages, you can provide the page a "MasterPage Type" pre-processor command along these lines: <%@ MasterType VirtualPath="~/MasterPage.master" %> This is used to provide you access to methods and properties that are defined in the Master page's codebehind. By default, when you use: Page.MasterPage ...

Can you round a .NET TimeSpan object?

Can you round a .NET TimeSpan object? I have a Timespan value of: 00:00:00.6193789 Is there a simple way to keep it a TimeSpan object but round it to something like 00:00:00.61 ? ...