.net

How to programmatically configure an ODBC Datasource using C#

Is there any way to create a ODBC DSN with C#? Maybe a P/invoke? ...

Save and Restore Form Position and Size

In a WinForms 2.0 C# application, what is the typical method used for saving and restoring form position and size in an application? Related, is it possible to add new User scoped application settings AT RUNTIME? I totally see how to add settings at design time, that's not a problem. But what if I want to create one at runtime? More de...

Learning C# in Mono

How solid is Mono for C# development on Linux and OS X? I've been thinking about learning C# on the side, and was wondering if learning using Mono would suffice. ...

Tips on walking through unfamiliar code or info on tools that help the process?

I would love tips on how to walk unfamiliar code with many objects. Before OOP this was still a difficult thing and I would do it with listings and have tabs and 8 fingers holding my place. With multiple monitors I have advanced my techniques so it's easier but still difficult. Eclipse does a pretty good job with letting you jump to ...

How to define listview templates in code

I am writing a Composite control, which contains a listview to display a table of items. Normally when using a ListView in Asp.NET I would define the templates in the code-forward. <asp:ListView runat="server" ID="ArticleList"> <LayoutTemplate> <div class="ContentContainer"> <div runat="server" id="itemPlaceholde...

Is there a .NET function to validate a class name?

I am using CodeDom to generate dynamic code based on user values. One of those values controls what the name of the class I'm generating is. I know I could sterilize the name based on language rules about valid class names using regular expressions, but I'd like to know if there is a specific method built into the framework to validate a...

Are properties accessed by fields still lazy-loaded?

I'm using the field.camelcase in my mapping files to setting things like collections, dependant entities, etc. and exposing the collections as readonly arrays. I know the access strategy does not affect the lazy loading, I just want confirm that this will still be cached: private ISet<AttributeValue> attributes; public virtual Attribu...

Built in unit-testing in VS

Hi all, I'm looking for advice on the built-in unit testing feature provided in VS08. Can any body please tell me if they know of any reasons NOT to use this feature over any of the other packages available (I'm vaguely familiar with NUnit)? I'm planning on applying unit testing to an older project just to learn the ropes of unit testi...

Why can't strings be mutable in Java and .NET?

Why is it that they decided to make string immutable in Java and .NET (and some other languages)? Why didn't they make it mutable? ...

Windsor Container: Registering things in Code vs Xml

From what I've read about Windsor/Microkernel it is in theory possible to do everything that you can do using xml files with code. As a matter of fact - and please correct me if I'm wrong - it seems like the major contribution of the Windsor layer is to add xml configuration for things Microkernel can already do. However, I have been ...

Easy way to set CurrentCulture for the entire application?

In a .net 2 winforms application, what's a good way to set the culture for the entire application? Setting CurrentThread.CurrentCulture for every new thread is repetitive and error-prone. Ideally I'd like to set it when the app starts and forget about it. ...

Editing Autogenerated DMBL file for WCF Service

Hi, In our project we have a standard auto-generated designer.cs file, linked to a DBML file, that contains all our object classes that map onto our database tables. We want to pass these objects directly through a WCF Service and so they need decorating with the [DataContract] and [DataMember] attributes where appropriate. What is the...

Stack overflow from .NET code in IIS, but not in Winforms

Hello all. So I have a nasty stack overflow I have been trying to track down / solve for the past 8 hours or so, and I'm at the point where i think i need advice. The details: Interestingly enough this code runs fine when called in the context of our regular winforms application -- but I am tasked with writing a web-based version of ...

Call .NET objects/dlls across virtual sites

Site 1 has dll's for x amount of object and data calls. Can Site 2 (a separate .net web app) call the objects/dll's of Site 1 ? ...

DateTimePicker: pick both date and time

Is it possible to use DateTimePicker (Winforms) to pick both date and time (in the dropdown)? How do you change the custom display of the picked value? Also, is it possible to enable the user to type the date/time manually? ...

Baseline snaplines in custom Winforms controls

I have a custom user control with a textbox on it and I'd like to expose the baseline (of the text in the textbox) snapline outside of the custom control. I know that you create a designer (inherited from ControlDesigner) and override SnapLines to get access to the snaplines, but I'm wondering how to get the text baseline of a control t...

Want to write to a file, but may have potentially multiple writers at once, need to lock.

Hi, In a asp.net web application, I want to write to a file. This function will first get data from the database, and then write out the flat file. What can I do to make sure only 1 write occurs, and once the write occurrs, the other threads that maybe want to write to the file don't since the write took place. I want to have this wr...

Is FileStream lazy-loaded in .NET?

I have a question about using streams in .NET to load files from disk. I am trying to pinpoint a performance problem and want to be sure it's where I think it is. Dim provider1 As New MD5CryptoServiceProvider Dim stream1 As FileStream stream1 = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read) provider1.ComputeH...

Do you generate code? If so, what do you use and what do you generate?

I've used MyGeneration, and I love it for generating code that uses Data Access Applicaiton Blocks from Microsoft for my Data Access Layer, and keeping my database concepts in sync with the domain I am modeling. Although, it took a steeper than expected learning curve one weekend to make it productive. I'm wondering what others are doi...

What are some good, useful, applications created using C# / .net ?

I know that there are two obvious answers: sharpDevelop and Paint.net. But I was thinking the other day, what else is out there? What are some good, useful, applications created using C# / .net ? Here are the answers. Feel free to add to this post. Baby Smash! by Scott Hanselman MySpace StackOverFlow Singularity FlashDevelop SharpOS ...