.net

Entity Framework AddTo function inconsistency?

Let me describe the behavior I get: Load a user from the database: this means the user is attached to the context Create a new Object C: C tempC = new C(); tempC.User = previously loaded user; Context.AddToCSet( tempC ); The last line throws an exception because the object was added to the context when the property user was set. bu...

Get raw text from markdown'ed text

In my DB, I have a text that is markdown'ed. The same way than SO does when showing the excerpts of the questions, I would like to get the N first characters of the text, i.e. all formatting must be removed. Of course the MD -> HTML step must be avoided and the work must be done on the MD'ed text. Performance is a requirement. Thx. ...

Single-Threaded Apartments vs Multi-Threaded Apartments

All ThreadPool threads are in the multithreaded apartment. --As per the MSDN What does that mean? I am really concerned with what the difference between the multi vs single threaded apartment model is. Or what does the apartment model mean? I have read the MSDN on it, and it doesn't really make sense to me. I think I may have an ...

What Happens When You Set A Parent Control's Enabled Property?

I have a container of custom controls each of which have 2 controls in them. One to display when enabled (i.e. a textbox, or checkbox), and a label to display when disabled. I've overloaded Render like so: Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) If Me.Enabled Then _item.Rend...

WinDbg -- TraceListener and Saturated ThreadPool

I have a multithreaded .NET Windows Service that hangs intermittently -- maybe once every two weeks of 24/7 operation. When the hangs occurs the threadpool is completely saturated because calls to our custom tracelistener start blocking for some reason. There aren't any locks in the offending code nor anything blocking according to windb...

C#.NET: Is it safe to check floating point values for equality to 0?

I know you can't rely on equality between double or decimal type values normally, but I'm wondering if 0 is a special case. While I can understand imprecisions between 0.00000000000001 and 0.00000000000002, 0 itself seems pretty hard to mess up since it's just nothing. If you're imprecise on nothing, it's not nothing anymore. But I do...

Is there a WPF control I can use to expand/collapse panels (animated)

I have a window that has a lot of content. I'd like to be able to separate the content using panels, and have a separator that the user can click on the toggle between each panel (with an animation that moves the separator from left to right, showing one section and hiding the other). Think of the Microsoft Office (2007) navigation pane....

.NET: How to make WebBrowser control launch in IE, display HTML, out of process?

i want to create a WebBrowser control, give it the HTML to display, then make it appear out of process in its own Internet Explorer window. Can it be done? yes it has to be out of process i already have a technique that involves writing a temporary file. i want to remove this hack solution i have three other questions on stackov...

What's the best way to set a windows service description in .net

I have created a C# service using the VS2005 template. It works fine however the description of the service is blank in the Windows Services control applet. ...

Using LINQ2Sql for Validate Users

Hi there im using Linq for check if two user fields correspond for an unique user register in SQL Table, for example UID : userID PIN : passID so fields have to be from a single user, i was trying this: public bool AutentificacionUsuario(string userID , string password passID) { USER _userID = _db.USER.FirstOrDefault(uid ...

Finding the intersection of two .NET DataTables

Is there a relatively straightforward way to get the intersection of two DataTables in .NET? I can think of the obvious ways (iterating over both tables myself in O(n^2)), but I'd like something a little more elegant if it's available. I suspect there may be an intelligent way that I'm not seeing. Readability and maintainability are i...

In VB.NET, how do you get a list of all users in the current Windows machine?

In VB.NET, how do you get a list of all users in the current Windows machine? ...

Why isn't the SelectedIndexChanged event firing from a dropdownlist in a GridView?

Hi, I cannot get my SelectedIndexChanged of my dropdownlist to fire. I have the following: <form id="form1" runat="server"> <div> <asp:GridView id="grdPoll" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server"...

How to create a join in an expression tree for LINQ?

I have a Task object that has a collection of Label objects ... in the database the tables are called Task and Label. There are a variety of ways to search for a Task, so using LINQ, I construct my LINQ query in an expression tree ... similar to the below code sample: IQueryable<Data.Task> query = ctx.DataContext.Tasks; if (crit...

Castle Windsor: So what DOES ActAs do?

I noticed that the castle windsor fluent component registration interface has the rather confusing ActAs() method. Googling around for it the only reference I found was at their wiki here. TODO (Stuff that could be documented) what does ActAs() do? Not too helpful. The source doesn't seem to have any unit tests for the...

What's the deal with this Lambda?

Dim count As Func(Of Integer, Boolean) = Function(x As Integer) x = 1 If (count(GetSelectedCount())) Then 'Proceed Else MessageBox.Show("You can only select one item at a time.", "Multiple items selected", MessageBoxButtons.OK) End If GetSelectedCount returns the number of items checkemarked in a grid. ...

Dependency Injection in an n-tier application?

I have a 3-tier .NET service app, which follows the standard approach: Frontend -> Object Model / Business Logic -> Data Access I'm trying to learn about dependency injection along the way, and thus far have found it great (using Autofac). Each of the 3 tiers needs to create an assortment of objects, sometimes with extra configuration...

Avoiding code repetition when using LINQ

Ok so I have a number of methods that look like this:- which sorts a list by artist, album, year etc. public void SortByAlbum(SortOrder sortOrder) { if (sortOrder == SortOrder.Ascending) _list = _list.OrderBy(x => x.Album).ToList(); else if (sortOrder == SortOrder.Descending) ...

Portable / Interoperable WCF Contracts

I was wondering if anybody out there had some good tips/dos and don'ts for designing WCF contracts with a mind for web-service interoperability, both in terms of older Microsoft web service technologies (e.g. WSE) and non-Microsoft technologies such as Java calling WCF web services. For example: are there any special rules that need t...

OleDbPermission in .NET Framework 3.5

I have a windows program in .net framework 3.5 to update an access database, I need to set the permission to full trust level. the client don't have the framework configuration tools installed on their server, so is there any other place that I can make this change? thanks. ...