.net

Visual Studio on a Mac

My job is currently based on Visual Studio (ASP.NET). Looking for experiences using Visual Studio on a Mac. Does it work? ...

Detect if code is running as a service

Is there a way for an .NET library to detect whether or not it is being run as a service? My library can be run either way. But when its run as a service, developers need to call an additional method indicating that fact or certain features won't work correctly. I want my library, which handles logging, to write a warning if it is used...

Should a .NET generic dictionary be initialised with a capacity equal to the number of items it will contain?

If I have, say, 100 items that'll be stored in a dictionary, should I initialise it thus? var myDictionary = new Dictionary<Key, Value>(100); My understanding is that the .NET dictionary internally resizes itself when it reaches a given loading, and that the loading threshold is defined as a ratio of the capacity. That would suggest ...

Best practices re sharing IDbConnection or connection string/factory in your .Net code

Hi guys, I'm wondering what would be the best prectice regarding mainataining connections to the database in .Net application (ADO.NET but I guess the practice should be the same for any data layer). Should I create a database connection and propagate it throughout my application, or would it be better to just pass connection strings/fac...

.NET Shell Control Library

Looking for a good quality .NET Control library that provides shell capabilities such as folder trees, item lists, right click, file context menu, and OLE drag/drop. Update: (I am asking this for someone else) Specifically want to provide the list of "files" which may be from numerous locations (the results of a search). And then have t...

Nhibernate foreign key to foreign key collection mapping ?

I have a Staff and e SecuredPage entity and the properties are below Staff id Name LastName Level // SecuredPage.RoleId SecuredPage id PageId RoleId // Staff.Level I want to have a collection of SecuredPage in Staff entity, so it s a one-to-many but i couldnt figure it out how to handle with it in mapping. Staff.hbm.xml <bag name=...

ASP.NET MVC Globalization of Views

I am looking at globalizing an application that I have developed in asp.net mvc. I am currently using resource files to store messages that I present to the user (i.e., when I save something to the database, and the user is shown the message "The whatever was correctly saved", that text is stored in a resource file so that I can easily ...

Best practice for AJAX calls in .Net 1.1

Well, my latest contract is forcing me into the antique world of .Net 1.1. Since I have been using jQuery and Rails for quite a while AJAX like solutions to problem keep on popping into my head and I can't help writing them. So my fairly straight forward problem is that I have 3 actions I need to perform on a record (insert, update a...

Fluent interface for rendering HTML

Rendering HTML with the HtmlTextWriter isn't incredibly intuitive in my opinion, but if you're implementing web controls in web forms it's what you have to work with. I thought that it might be possible to create a fluent interface for this that reads a bit more like the HTML it outputs. I would like to know what people think of the synt...

Collection initialization

You can initialize an array like this: int [ ] arr = { 1, 2, 3, 4, 5 }; but List<T> doesn't allow this: List<int> list = { 1, 2, 3, 4, 5 }; What's the reason behind this? After all both allow this: int [ ] arr = new int [ ] { 1, 2, 3, 4, 5 }; List<int> list = new List<int> { 1, 2, 3, 4, 5 }; Also why it's not possible to d...

Will T-Sql SET parameters be reset with pooled .NET connections?

The only SET parameter that I have found specific guidance for is SET TRANSACTION ISOLATION LEVEL: If you issue SET TRANSACTION ISOLATION LEVEL in a stored procedure or trigger, when the object returns control the isolation level is reset to the level in effect when the object was invoked. For example, if you set REPEATAB...

why minus is slower than mod?

in that specific case Const debugTime As String = "hh:mm:ss.fffffff" Dim i As Integer Debug.Print("Start " & Now.ToString(debugTime)) For i = 0 To 4000000 j = 5 - 4 Next Debug.Print("End " & Now.ToString(debugTime)) Debug.Print("Start " & Now.ToString(debugTime)) For i = 0 To 4000000 j =...

How do I create compiled user files in Visual Studio 2008?

In C++ you are able to compile files that are not included in the solution, with c# this is not the case. Is there a way to keep a file in a project but not have the standard SCCI provider attempt to keep checking in the file? Essentially what we are wanting to do is to create "by developer" code ability similar to how we code in c++, ...

Is AxBrowser.GetOcx() is equal to Webbrowser.ActiveXInstance() ?

I'm trying to understand the different between .NET 2.0+ provided Webbrowser Control and AxWebBrowser. As far as I understand AxWebBrowser is a COM object and Webbrowser Control is just managed wrapper around AxBrowser. Am I right? Is AxBrowser.GetOcx() is equal to Webbrowser.ActiveXInstance() almost same? ...

What is the optimal (speed) way of parsing a large (> 4GB) text file with many (milions) of lines?

I'm trying to determine what is the fastest way to read in large text files with many rows, do some processing, and write them to a new file. In C#/.net, it appears StreamReader is a seemingly quick way of doing this but when I try to use for this file (reading line by line), it goes about 1/3 the speed of python's I/O (which worries me...

DeepCopy for arrays

Anyone knows if there is an easy or known way to write a deep copy method that's gonna work on arrays of any kind, ie jagged, multidimensional, etc? I plan to write it as an extension method. There isn't a default method in the framework to do this, right? I am surprised not to find one. I have seen some serialization-based implementat...

silverlight, how to implement a property of type StoryBoard

I have a user control and I want to create a property of type storyboard which I can set in xaml, so I tried to following, but I get a bad property error when I run it: private Storyboard sbTransitionIn_m; public Storyboard TransitionIn { get {return sbTransitionIn_m;} set {sbTransitionIn_m = value;} } xaml: <MyStuff:MyUserCo...

Directly modifying List<T> elements

I have this struct: struct Map { public int Size; public Map ( int size ) { this.Size = size; } public override string ToString ( ) { return String.Format ( "Size: {0}", this.Size ); } } When using array, it works: Map [ ] arr = new Map [ 4 ] { new Map(10),...

Change Tracking Structure

We are looking to implement Optimistic locking in our WCF/WPF application. So far the best way I've come up with doing this is to implement a generic Optimistic which will store a copy of the original and any changes (so it will store two copies: the original and modified) of any value object that can be modified. Is this the best way of...

Fixed length strings or structures in C#

I need to create a structure or series of strings that are fixed lenght for a project I am working on. Currently it is written in COBOL and is a communication application. It sends a fixed length record via the web and recieves a fixed length record back. I would like to write it as a structure for simplicity, but so far the best thing I...