.net

Why do people consistently recommend using appConfig instead of using Settings files? (.NET)

Very often I see the answer to the question like: "How should I store settings in my .NET app?" is to edit the app.config file by manually adding entries to the app.config (or web.config) like so: <configuration> <appSettings> **<add key="ConfigValueName" value="ABC"/>** </appSettings> </configuration> Then, accessing them li...

XmlSerializer.Serialize ambiguous.

I have create testing application that has 3 classes Car Radio SportCar : Car (has a Radio) As the serialize process when I create instance of XmlSerializer object I use 2 object to testing XmlSerializer xmlSerializer = new XmlSerializer(typeof(SportCar)); and XmlSerializer xmlSerializer = new XmlSerializer( typeof(SportCar),...

Does closing a database connection in Dispose method is right?

I've had a suspicion that a database connection used in one of our applications is not always closed. I went to see the code and I've found a class DataProvider that has SqlConnection object. The connection is opened in the constructor of this class and closed in it's Dispose method (don't judge that, i know keeping an open connection is...

C# WM6 Compact Framework Cross Thread Communication Problem

Hi all, I'm having a problem updating a control on my ui from a thread created using ThreadPool.QueueUserWorkItem Inside this thread i am calling addControlToPanel(li); As shown here private delegate void addControlToPanelDelegate(ListItem li); private void addControlToPanel(ListItem li) { if (panel1.InvokeRequired) { ...

Add images to subitems in a ListView control

Hi, I need to add multiple images to a list view item that is in each row of the list view and each column has different images ? Regards, Fran ...

Finding the client's timezone and culture via web service.

I have a .NET web service. It serves AJAX requests from web users. I would simply like to know how to automatically get the user's timezone... Not current time offset, but the actual timezone - like, Central Standard Time is -5:00 right now, but Eastern Standard Time will be -5:00 once daylight savings is over. I want to differentia...

Looking for some UI thread and working thread tutorials

Hello everyone, My working environment is VSTS 2008 + C# + .Net 3.5. I want to learn the differences between UI thread and worker thread, and any other types of thread (i.e. non-UI thread is the same as worker thread)? I also want to learn the restrictions of what we can do on each type of threads and best practices to avoid any issues....

How to kill a specific thread from an array of threads

Hi. I am creating an array of threads based on the number of records in a database. Each thread then polls an ipaddress and then sleeps for a time and then repolls again. I periodically check the database for any change in the number of hosts. If there are more hosts I start another thread. If there are less hosts I need to kill the spec...

Implementing OpenID: identifying users

Company I work for wants to publish an internal website to the outside world, but also wants to identify the visitors in some easy way. Some functionality will be visible for all visitors but most must be visible for authenticated visitors. (And some functionality is restricted to admin-visitors.) While management is considering to imple...

Handle XMLHttpRequest .NET

Hi All, Can anyone tell me how can i retrieve data on my web service written in .NET. I have posted my data through XML HTTP Request. Data has successfully posted as it returns readyState as 4. But i dont know how to access the data on the service so that i can do manipulation on that data. Thanks ...

Are StopWatch.ElapsedTicks and StopWatch.Elapsed.Ticks always the same?

What does ElapsedTicks and Elapsed.Ticks in the StopWatch class mean? When could the meaning be different than intended? ...

Problem with serialization

I have problem with serialization. I want to convert an object into a string and vice versa. I have two utility methods: public static byte[] Serialize(Object o) { MemoryStream ms = new MemoryStream(); BinaryFormatter bf1 = new BinaryFormatter(); bf1.Serialize(ms, o); byte[] buffer = ms.ToArray(); //string retStr = Conver...

Fingerprint SDK

Hi, I am using fingerprint reader UFP20.The SDK providing 2 DLL files (WIS_API.dll,WisCmos2.dll). Unfortunately they not provide c# demo code. I could connect the device and test the device. Its working perfectly. Problem : I can't capture finger print even capture initialize function working perfectly. I got error when i c...

.net : Are DataSet and TableAdapters agnostic of database and vendor?

Hi all, We need the application we are building to be Database-agnostic. In particular, I need it to be able work with SQL Server, Oracle and MySQL. In the future, possibly other DB Vendors will be added to the list. Of course, whatever DB is to be used will have the same schema. In order to build a prototype to demonstrate the interfa...

Protected Classes in .NET

Can a class be protected in.NET? Why is / isn't this possible? ...

How can I extend two classes the same way without copy-and-paste?

I've written an owner-drawn TabControl, but our project also uses TabWorkspace which derives from TabControl. At the moment, I've got public class OurTabControl : TabControl { // some code that overrides protected methods } public class OurTabWorkspace : TabWorkspace { // the same code } I'd like to only have the shared cod...

.NET CF AutoScroll

I have a TabControl with multiple pages. On one page, I just have a label and I want it to fill the page and scroll if necessary. Despite trying what seems like every combination of anchor and dock, the label won't scroll. I've set the AutoScroll property of the page to true but no luck. I've seen articles about using a ScrollBar and man...

How to Unit Test Asp.net Membership?

Hi I am new to unit testing and I am trying to test some of my .Net membership stuff I been writing. So I am trying to check my VerifyUser method that checks if the users credentials are valid or not. So this is what it looks like: public bool VerifyUser(string userName, string password) { bool valid = Membership.Validat...

Is there a .NET way to enumerate all available network printers?

Is there a straightforward way to enumerate all visible network printers in .NET? Currently, I'm showing the PrintDialog to allow the user to select a printer. The problem with that is, local printers are displayed as well (along with XPS Document Writer and the like). If I can enumerate network printers myself, I can show a custom dialo...

[WPF] Custom binding class is not working correctly

Hi! Currently I'm playing around with WPF data binding and I came to an issue I dont understand. So I post the problem here, maybe you have and idea whats geoing wrong. At first: I'm working with Visual Studio 2008 under Windows Vista 32bit, the problem is also present in Windows 7 RC1 64bit, latest updates/service packs are installed e...