.net

Grid vs. Canvas

I'm looking for opinion on using Canvas vs. Grid panels in WPF. I need to make classic input forms that have basically grid layouts, some may have small datagrids inside, groupboxes, but all aligned in grid layout. I’m struggling whether to use Grid or Canvas panel for all my forms. Grid is giving me good structure; I can maintain alignm...

Handling Authentication with HttpWebRequest (.NET)

I am accessing a REST webservice from a VB app. I create a HttpWebResponse object and call GetRequestStream on it just fine, but when I call GetResponse I get a 401 exception. Here is my code (modified for posting): Dim webRequest = DirectCast(WebRequest.Create(endpoint), HttpWebRequest) webRequest.Method = "POST" webRequest.ContentLe...

Template method accessing static variables issue.

Suppose I have two classes that both contain a static variable, XmlTag. The second class inherits from the first class. I have a template method that needs to obtain the XmlTag depending on the which type it is using. What would be the best way to accomplish this, without having to create an instance of the type? Here is an example(that ...

IniFiles in .NET

What is the best way to read and write .INI files in .NET? It looks like I could write my own parser or use native Windows API calls but neither of those options are very appealing. Are there other options? ...

DataReader hangs while mapping a record to an object

Hi all, I'm in the middle of a project where we are querying a database with more than 20 million records, applying several set of filters our query returns about 200 records (after waiting for about 1.30 minutes). After querying the database I try to create objects from this particular datareader but once every 15 or 16 records the asp...

What's the Best Way to use Response.Redirect to for A Pop-Up in a .NET Web Application?

I'm trying to do this in a way that will prevent end-user browser security features (such as a pop-up blocker) from getting in the way of my application. ...

Mysterious, ghost-like, impossible-to-find TreeNode text

So I have a TreeView that starts off empty. Sequence of events is as follows: Add a new root node. Code makes the label edit box pop up immediately, and I give it a name. Add a new subnode to that root node. Add a new root node, after the first one. The label edit box pops up, and I give it a name. The second root node takes on its n...

How to gain real world programming skills when you don't work for a software company

I work in the technical group at a large Architecture firm. While there are a number of people here that are very proficient at various programing and scripting languages, it's far from the environment of the development environment of a software company. Rarely are there ever more then one or two people working on a development project,...

What am I Doing Wrong with IQueryable<T>?

I thought IQueryable<T> was derrived from IEnumerable<T>, so why can't I access the results of my query like a collection of records? public bool DoLogIn(System.String strUserName, System.String strPassword) { if (this.IsLoggedIn) return false; ASRDBDataContext ASRData = new ASRDBDataContext(); IQueryable<user> Curr...

Do I need to remove event subscriptions from objects before they are orphaned?

If my software has two object instances, one of which is subscribed to the events of the other. Do I need to unsubscribe them from one another before they are orphaned for them to be cleaned up by the garbage collector? Or is there any other reason why I should clear the event relationships? What if the subscribed to object is orphaned b...

How to find which section of a website is not compatible with new browsers?

I have been tasked to fix a really old website (.net aspx vb). The website currently is not running well in IE8, Firefox, Chrome. The menus are displaying funny and some images are not correct, and in Chrome the complete header with menus and all is missing. I am not a vb guy, and I have no idea where to start looking. What will b...

Can anyone help me with the Windows API NetApi32?

I am trying to get a list of shares on a specific machine. So I decided to use the Windows API NetApi32.dll. Here is my code snippet: Dim svr As String = Environment.MachineName Dim level As Integer = 2 Dim sharesRead As Integer, totalEntries As Integer, nRet As Integer, hResume As Integer = 0 Dim pBuffer As IntPtr = IntPtr.Zero nRet =...

Linq to XML - Check for null element while parsing for DateTime

Let's say I have the following XML: <Account> <AccountExpirationDate>6/1/2009</AccountExpirationDate> </Account> I want to use LINQ to XML to parse this into an object I'll call Account: public class Account { public DateTime? AccountExpirationDate { get; set; } } This is the C# code I've tried, but it won't let me use ...

.Net EventProvider rights

I've got a System.Diagnostics.Eventing.EventProvider class trying to write to a custom event log. The event log was created using a manifest file and the procedure layed out on this page. You can see the new provider and channel in the windows Event Viewer, but for some reason no events that get written seem to show up there. When I ch...

Winforms UI Thread Marshalling BusinessObject list being updated from background thread

Hi, Firstly I know that there are many question and solutions to correct thread marshalling from threads other than background threads. All the questions and solutions I have found have focused on scenarios where the list or business object itself raises an event that the Windows form can subscribe to and then correctly marshall the upd...

Sorting an List<> with my custom order which is stored in another List (C#)?

Hi there, Can anyone help.. I have a generic list like so IList<itemTp> itemTps; itemTp basically is a class (has a number of properties) and one property on this is "code" I need to be able to sort it an specific order which i have set in another List. This list is a simple list that lists the order (starting from first to las...

DataContractSerializer doesn't call my constructor ??

I just realized something crazy, which I assumed to be completely impossible : when deserializing an object, the DataContractSerializer doesn't call the constructor ! Take this class, for instance : [DataContract] public class Book { public Book() { // breakpoint here } [DataMember(Order = 0)] public string Title {...

What is the best way to display percent complete in a .Net CLI application?

I'm working on a CLI application that deals with uploading of files, and would like to have a combination of appended and overwritten output. Ideally it would look something like this: c:\>upload file1.dat 100% file2.dat 100% file3.dat 59%, 36.4k/s I'd like just the last row to periodically update the percent compl...

Is the WCF Service Trace Viewer tool indispensable?

Do I need to learn the WCF Service trace viewer tool? I understand I can use the WCF Service Trace Viewer tool to trace messages leaving from clients, or arriving at servers. Can I configure WCF tracing to record REST messages as well as SOAP? Are there other neat tricks I can do? I've developed with WCF for a long while but I've n...

Displaying a Large Amount of Data C#

I'm working on a media library mock-up and I have a database of songs (over 9,000 tracks) that I want to display and make sortable. I'm not sure which GUI control would be best to use and I am not sure how it would be best to add all of the entries to the control. Obviously using a listview and adding each entry one at a time takes a lo...