.net-4.0

C# How to maximize chance that particular section of code will have no context switch?

China☆狼群 提交于 2019-12-10 19:37:43
问题 I have time-critical piece of code in my app. I made the thread which runs it Highest priority - that's the most I could do. Is there any suggestions on how to make part of the code run in this thread to be interrupted as few times as possible (less context switch occurred) ? The code is not complicated. I replaced all the method calls with inlined code and I don't use anything of high level (like no LINQ). The most of operations are arithmetic. There is only one comparison of strings (I am

.net 4 string[] parameter default value setting

China☆狼群 提交于 2019-12-10 19:34:03
问题 I'm trying to do like this: public int Insert(object o, string[] ignore = new string[] {"Id"}) but it tells me that I can't do that ? why is that so ? 回答1: The problem is that the default arguments must be constants. Here you are dynamically allocating an array. As with declaring const variables, for reference types only string literals and nulls are supported. You can achieve this by using the following pattern public int Insert(object o, string[] ignore = null) { if (ignore == null) ignore

Webservices vs WCF

岁酱吖の 提交于 2019-12-10 19:24:48
问题 I am working on an asp.net application (.net 4 framework) design and was wanting to know what are the pros and cons and best practices for using webservices vs WCF techology? This application will eventually be used by outside clients to consume data. When would you use WebServices and when would you use WCF? Is one more scalable than the other? 回答1: I would use WCF because it can do everything webservices (asmx) does; while giving you the flexibility to extend much further. You can setup a

using forms authentication with my own tables

ⅰ亾dé卋堺 提交于 2019-12-10 19:22:19
问题 I have a small db, nothing fancy just 5 tables. I would like to use forms authentication but it creates its own db to do its stuff. I don't need anything fancy, and I certainly don't need the added infrastructure, but I'd like the security forms authentication provides. I have a person table, with a login and password field. how can I make it so forms uses these fields and returns my users id? is this even possible with forms? if not, how can I make it so forms creates it's infrastructure on

Visual Studio 2010 Conversion issue not recognizing prefix 'asp'

眉间皱痕 提交于 2019-12-10 19:07:48
问题 I just converted a project from Visual Studio 2008 to 2010 and all of my asp controls have a warning stating.. Unrecognized tag prefix or device filter 'asp'. It also is not showing any intellisense, anyone else experiencing similar issues? Is it possible my conversion did not go through correctly? Thank you. 回答1: I too was having this issue, I resolved it by deleting the C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\10.0 folder 来源: https://stackoverflow.com/questions/3772901

How can I see me expensive methods in PerfView

爷,独闯天下 提交于 2019-12-10 19:03:55
问题 I have created a simple console app and execute it from PerfView via Run Command -> PerfMonTest.exe I get the log file and see the process of the app. It is expensive as expected (99% CPU ), but when I want to drill down into the expensive methods they are not shown in the list of expensive methods. Is there something I can do to make them visible? Here is the view when I selected the process. I would expect CallExpensive and CallCheap in the list: Selecting the Main Methods doesnt give me

Possible to overwrite items in IEnumerable<T> using Reflection?

风流意气都作罢 提交于 2019-12-10 18:25:18
问题 Disregarding any sane reason to do this, and simply out of curiosity Is it possible to take any given IEnumerable(T) and overwrite the contained items? For example, given an IEnuemrable(String) is it possible to completely replace all strings within the IEnumerable? 回答1: As other people have said, if the IEnumerable is something concrete like a List or a Collection, Set, etc, then you can do this without reflection - just cast it to that type and mess with it. What if the IEnumerable is

Can't add items to the collection in the second round

天大地大妈咪最大 提交于 2019-12-10 18:15:51
问题 Basically I have a blockingcollection in my windows service application, each time I want to add 4 items to the collection then processing it. The first round is okay, but the second round failed. The error is The BlockingCollection has been marked as complete with regards to additions. My code: public static BlockingCollection<Tuple<ChannelResource, string>> bc = new BlockingCollection<Tuple<ChannelResource, string>>(); public static List<string> list = new List<string>(); // then add 100

Covariance Also in 3.5 / 2.0?

女生的网名这么多〃 提交于 2019-12-10 18:05:20
问题 weird problem... Ive implemented covariance from example . My target FW is 4.0. How ever . I wanted to see if it fails on 3.5 /2 -> but it wont. It cant be since covariance is from FW4.0. After changing to 3.0 i Build and see : (+wont fail on runtime) 回答1: Covariance was supported in framework 3, but not implemented in the compiler. You are using compiler 4 targeting framework 3. This is mentioned in an Eric Lippert blog post, I'll see if I can find it.. EDIT To further clarify,: The Common

Get source property type from BindingExpression

拜拜、爱过 提交于 2019-12-10 17:57:05
问题 I am trying to find out the source property type of a binding expression. I want to do this because I want to use the UpdateSourceExceptionFilter to provide a more useful error message than just the generic “couldn’t convert”. In .NET 4.5 I use ResolvedSource and ResolvedSourcePropertyName with reflection to get the source property type like this: PropertyInfo sourceProperty = expr.ResolvedSource.GetType().GetProperty(expr.ResolvedSourcePropertyName); Type propertyType = sourceProperty