.net

More Elegant Exception Handling Than Multiple Catch Blocks?

Using C#, is there a better way to handle multiple types of exceptions rather than a bunch of ugly catch blocks? What is considered best practice for this type of situation? For example: try { // Many types of exceptions can be thrown } catch (CustomException ce) { ... } catch (AnotherCustomException ace) { ... } catch (Ex...

File imported into App_Code isn’t referenced

Hello, Q1 A) I’ve created a new .cs file, declared a class inside it and then save it on my disc. Now according to my book, I should be able to import this file into App_ Code folder of a website application ( via Website --> Add Existing Item. BTW – since file was copied into root folder of a website, I had to move it into App_Cod...

Website --> Add Reference also creates files with pdb extensions

Hello, Q1 Any assemblies stored in Bin directory will automatically be referenced by web application. We can add assembly reference via Website --> Add Reference or simply by copying dll into Bin folder. But I noticed that when we add reference via Website --> Add Reference, that additional files with .pdb extension are placed inside ...

Customize or skin .net DataGridView controls

Hello, does anyone know how easy it is or how possible it is to skin a .net Windows Forms DataGridView control? I'd like to render the control vastly different then what it currently looks like. For example, think of the open source application Boxee. It has a completely custom interface which is how far I'd like to push the control...

cross-language configuration for java/.Net

I found this question, but didn't see a good answer. I'm interested specifically in configuration files, say in XML. Are there cross-language standard/tools for reading config files? XML itself is just a medium, but I want tools and libraries and standards, like those existing in .Net's ConfigurationSection class. My main targets are ja...

The correct way to call unmanaged code from partially trusted code

What is the correct way to call unmanaged code such as a COM API through .Net interop from a code that is being executed in a partially trusted environment? While developing an ASP.Net WebPart for Microsoft SharePoint I had to communicate with another system through its COM API. I solved this issue temporarily by changing SharePoint's p...

Adding column functionality to a Custom Repeater

Hi, I'm trying to extend a custom repeater I have in order to display in a tabular fashion (reasonably similar to a Gridview). What I'm conceptually looking to achieve is to get to something that can be applied in the following way: <my:customrepeater id="rpt" runat="server"> <cols> <col Header="ID">##ID##</col> <co...

Cannot execute stored procedure with ADO.NET Entity Framework

I've created a simple parameterless stored procedure which I've pasted below. I've imported the stored procedure to my Entity Model and created a Function Import. The function in the model is never created and I am unable to execute this stored procedure using the ADO.NET Entity Framework. I've opened the .edmx file in XML view and have ...

Easy to implement .net library for geocoding using a free service?

I need to geocode adresses (get lat/long from addresses) using in .Net, to store in the database. What is the library/project to look into, to get that done? After a search here, on google and codeplex.com, I have found there to be a few options, that seem like they will do what I ask for... But some of them could be crap and a waste ...

Should I unit test for multithreading problems before writing any lock? (.NET C# TDD)

I am writing a class that I know that needs a lock, because the class must be thread safe. But as I am Test-Driven-Developing I know that I can't write a line of code before creating a test for it. And I find very difficult to do since the tests will get very complex in the end. What do you usually do in those cases? There is any tool to...

Fill combobox with english months

I have to fill a combobox with month in English: January, February, etc. I did it next way: private string[] AmericanMonths { get { var arr = new string[12]; var americanCulture = new CultureInfo("en-US"); for (int i = 0; i < 12; i++) { arr[i] = new DateTime(2000, i + 1, 1).ToString("MMMM", americanCulture); ...

Web Deployment Projects tool and Web application project

Hello, Q1 - As far as I know, Visual Studio doesn’t use aspnet_compiler.exe when compiling web application projects. And since Web Deployment Projects (WDP) tool is only used for manipulation the output created by aspnet_compiler.exe, I don’t understand how VS 2008 also has an option for using WDP with web application projects?! Q...

Trying to parse XML tree with Linq to XML (C#)

Hi, I would like to reflect the XML tree in my object structure, but I am quite a beginner in LINQ to XML I have an XML with following structure: <questions> <question id="q1"> <number>1</number> <text>some text11</text> <answers> <answer> <v>some text11</v> </answer> <answer> <v>some text11</v> </a...

Autoscale Font in a TextBox Control so that its as big as possible and still fits in text area bounds

I need a TextBox or some type of Multi-Line Label control which will automatically adjust the font-size to make it as large as possible and yet have the entire message fit inside the bounds of the text area. I wanted to see if anyone had implemented a user control like this before developing my own. Example application: have a TextBox ...

Which is the purpose of async methods? (.NET)

In ASP.NET we use async methods because the Thread Pool has limited slots, and by using an async method you free a Thread Pool slot while the method is outbound, increasing the number of requests that a server can handle in the same interval of time. I guess that in other types of applications (i.e. Windows Forms) the thread limit is mu...

Can I build 2 or more dlls from C# project in Visual Studio 2008?

Because I'm working on Creating RIA Framework with Silverlight & C#. So I need to use rich features of Silverlight such as dynamic loading. But I found that Visual Studio will merge all class library(same namespace or difference namespace) into one dll. Do you have any idea to build 2 or more dlls from C# project? I just create 1 projec...

Save ListBox_SelectedItem to file.txt.

HI all, i wish save in a file.txt the chronology of the song played by my music Player . I tried this code snippet but doesn't work : StreamWriter sw = new StreamWriter(@"c:\Media PlayList\List.txt"); private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { wmp.URL = Convert.ToString(listBox1.Selecte...

What is WPF for the WinForms programmer?

What is WPF to the WinForms programmer? WinForms distilled is adding controls to forms, and adding event handlers. This is simple and easy and allows you to make functional GUIs quickly. WPF on the other hand is XAML (?) + Code (?) that seems like a much more complicated way to make prettier UIs slowly. There are plenty of existing S...

.Net ClickOnce deployment and wrong assemblies called after updated version

Hi! I have a ClickOnce application (app1) that calls dlls from another Solution (app2). I recently updated this application at one customer and a strange thing occured. He got the new version (publish version was correct in control panel/add remove programs) of app1 and the application version was correct as manually inspected in the a...

.NET remoting and Delphi win32

Hi, Is it possible (and feasible) to use .NET Remoting interface with Delphi win32 application? I need communication between .NET application and Delphi win32 application, so .NET remoting would be native for other end of the pipe. Any other solutions, as close to native as possible, for both ends without 3rd party libraries? Applicat...