.net

Force C# (.Net 3.5) to use ASCII

I'm working on an application in C#, and need to read and write from a particular datafile format. The only issue at the moment is that the format uses strictly single byte characters, and C# keeps trying to throw in Unicode when I use a writer and a char array (which doubles filesize, among other serious issues). I've been working on mo...

Reference to a refrence type in .net?

So I want a pointer to a pointer. I've got a class that is updated in one object. In another object I want a reference to the current version of the object in the original Class. Here is sort of a simplified version of what I have going on. Public Class Foo 'conaints information End Class Public Class myMainApp Dim myHelper ...

Page not found when trying to access HttpHandler with IIS 5.1

The problem is as follows: I have an HttpHander, which works completely fine in IIS 6.0 (it's configured throught Web.Config) <add verb="*" path="MyHandlder" type="MyNamespace.MyHandler"/> But when i'm trying to access it via url (http://localhost/MyHandlder?somevar=somevalue), it gives me "Page cannot be found" error, even thou t...

Starting a new Outlook 2007 Message from C# .NET

Hello, I'm looking for the most barebones complete example, to launch Outlook 2007 with a new message started via C# .NET (I happen to be using VS2008 .NET 3.0) Here's what I'm trying: using System; using System.Collections.Generic; using System.Text; using Microsoft.Office.Interop.Outlook; namespace CreateMessage { class Progra...

Subsonic3 Active Record Query using SubSonic.Query.Select throwing errors

So I am trying to get the following query to work using SubSonic3 ActiveRecord with a Sql Server 2008 backend facilities = new Select().From<Facility>() .ExecuteTypedList<Facility>(); as well as the following facilities = new Select().From<Facility>() .InnerJoin<mem_Users_Facility>().InnerJoin<mem_User>()...

NSIS installer that checks for .NET Framework

I want to create an NSIS installer that checks for the .NET Framework and installs it if it's not there. Can you point me to a script for this? I'm very new to NSIS. ...

Xaml serialization and immutable structs?

How can I do this? Tried using a TypeConverter, but the only thing I could think of was to construct the XML for the types, which doesn't quite cut it. TypeConverters in xaml serialization will escape xml and treat it like plain text. Value converters aren't much better. Now, I'm moving to ISupportInitialize and will throw if changes...

Is there a Windows API to modify file type associations for an extension?

I'm looking for a way to programatically tweak the particulars of a file association on a Windows system. For example, the "Application User to Perform this Action" setting for the "Open" action for a particular file type. Clearly I could do this by modifying the registry directly, but if there is an API I'd prefer to use that as it wou...

How can I have Visual Studio 2008 server still server site while not debugging?

In Visual Studio 2008, I'd like to have the internal web server still serve my website on the designated port even after I've stopped debugging. In other words, if my site runs on localhost:2923 once I begin debugging, after I stop debugging I'd still like to go there to have the site run (not in debug mode). Sometimes this works and s...

Custom WinForms DataGridView issues with adding columns

Hello everyone, I'm working on creating a custom winforms datagridview control that inherits the built in DataGridView control. I'm having an issue with the Columns property, the property is set to as ReadOnly so I can't edit any information in it and need to add columns to the datagrid. If you look at the property outside of my custo...

How to detect that a file is not ANSI-Latin1?

I have a date import project in which the clients send ANSI-latin1 encoded files (iso-8859-1). However... It seems that on a weekly basis we get a surprise file, one that is not of the correct format and the import basically dies horribly and needs manual intervention to recover and move on... Most common bad file formats seem to be e...

C# CryptoStream result not as expected

I'm trying to understand why the following code results in the encrypted byte array being 16 bytes if plainText is 8 bytes in length. I expected the result to also be 8 bytes in length? private static byte[] encrypt(byte[] key, byte[] plainText) { try { using (MemoryStream ms = new MemoryStream()) { D...

WPF Binding Fails. Why?

I have this Markup: <GroupBox BorderThickness="2"> <GroupBox.BorderBrush> <SolidColorBrush x:Name="Border"> <SolidColorBrush.Color> <MultiBinding Converter="{StaticResource ConnectionAndLoggedInToBorderBrush}"> <Binding Path="IsConnected"/> <Binding Path=...

Enumerating through an object's properties (string) in C#

Let's say I have many objects and they have many string properties. Is there a programatic way to go through them and output the propertyname and its value or does it have to be hard coded? Is there maybe a LINQ way to query an object's properties of type 'string' and to output them? Do you have to hard code the property names you w...

How do I convert a Dictionary<string,string> to a json string using System.Json?

Hi, I'm trying to convert a Dictionary in Silverlight to a string. I don't want to use any third-party libraries so would like to use System.Json to do this? The best way I have thought of so far is to add all the items in the dictionary to a JsonObject and then call toString(), any better ideas would be most helpful. ...

Check Network Status

I want to check the network status if network is down, I mean if my network is down then I want to find out by programmatically using C#/VB.net, to find out which router, or server etc is down due to which the network is also down, Hope I have explain my question, if you want more explanation Please tell me. I want to check if there i...

Debugging questions

If I have a an app which relies on a .dll which contains my core classes. I have noticed when debugging the main app and it steps into the .dll, the debugger steps through (At my request) blank lines!? Why is this? Sometimes when I debug an asp.net app and get a ysod, I don't get the name of the file with the bug or line numbers, but I ...

Confused about when to throw an exception

I am working on a library designed to communicate (over RS232 serial communication) with external devices. I was thinking about error handling strategy and exceptions seemed to be right and industry standard way of reporting errors. So I read few guidelines on exceptions. One pretty clearly states that I should not worry about performan...

Transactions - How to avoid deadlocks?

I was asked this question in a .net/C# interview: If we have two threads T1 and T2. T1 acquires a lock on obj1 and then does some processing and acquires a lock on obj2. T2 acquires a lock on obj2 and then does some processing and acquires a lock on obj1. So, we can have a deadlock. What is common technique that we use ...

Deserializing some JSON with JSON.NET

Hi everyone! I'm very new to JSON, and I need to parse some that an API is providing. A quick google search turned up JSON.NET, so I'm trying to use it now to parse this JSON into a list object. First of all, is JSON.NET the best library to use for this? This is what I'm trying to do: I have a class called Item, for example. The json ha...