.net-4.0

Read ini file which does not have any section?

本秂侑毒 提交于 2019-12-06 03:49:35
My ini file does not have any section. It has following data com.ibm.rcp.toolbox.admin/toolboxvisibleChild=false com.ibm.collaboration.realtime.community/defaultAuthType=ST-DOMINO-SSO com.ibm.collaboration.realtime.brokerbridge/startBroker=false com.ibm.collaboration.realtime.webapi/startWebContainer=true I want to use function. [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key,string def, StringBuilder retVal, int size,string filePath); My problems I cannot give section name in the function because I dont have any If I give section name null,

Lock on static object from within a delegate is not working

ⅰ亾dé卋堺 提交于 2019-12-06 03:48:12
How come this isn't working? private static object Lock_HandleError = new object(); public static void HandleError(Exception ex) { lock( Lock_HandleError ) { //IF the UI is processing a visual tree event (such as IsVisibleChanged), it throws an exception when showing a MessageBox as described here: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/44962927-006e-4629-9aa3-100357861442 //The solution is to dispatch and queue the MessageBox. We must use BeginInvoke because dispatcher processing is suspended in such cases. Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate() { lock(

MEF parts configuration, where to store?

烂漫一生 提交于 2019-12-06 03:46:12
问题 In ASP.NET , .NET 4.0 , MEF , I put all parts in a folder and importing them using DirectoryCatalog . Everything is fine. Some of part have related configurations. I don't want put them in web.config . Maybe a good approach be a config file just beside the part with a .config added to the end. What is the best way for storing part configuration ? 回答1: I was able to create a separate config file for each DLL and successfully was able to read the keys. But when I tried to create a custom config

Configuration File in C# default location?

一个人想着一个人 提交于 2019-12-06 03:38:19
I have just created a WPF application and just been wondering where is my app.config file? I looked in the bin/Debug and bin/Release directories and there is just one file "WpfApplication1.vshost.exe" and could not find any app.config file. All I can do is Add->New Configuratin File and this too, doesn't come in debug or Release folder. Can anyone guide me whether I should manually copy and paste it in the debug or Release Folder? So finally: the ANSWER If app.config does not exist, then try creating a new one by "Add->New Item->Application Configuration File" and create a file named "App

In parallel call, limit executions per second

雨燕双飞 提交于 2019-12-06 03:34:51
Using TPL / Parallel.ForEach is there an out-of-the-box way to limit the number of times a method is called per unit of time (i.e. no more than 50 calls per second). This is different than limiting the number of threads. Perhaps there's some simple hack to make this work? SFun28 One solution is to make a thread-safe version of the following https://stackoverflow.com/a/7728872/356790 /// <summary> /// This class limits the number of requests (method calls, events fired, etc.) that can occur in a given unit of time. /// </summary> class RequestLimiter { #region Constructors /// <summary> ///

Using await SemaphoreSlim.WaitAsync in .NET 4

感情迁移 提交于 2019-12-06 03:24:57
问题 My application is using .NET 4. I am using await async using nuget package In my application I want to do an await on sempahore WaitAsync call as follows. SemaphoreSlim semphore = new SemaphoreSlim(100); await semphore.WaitAsync(); However I am getting following compilation error. 'System.Threading.SemaphoreSlim' does not contain a definition for 'WaitAsync' and no extension method 'WaitAsync' accepting a first argument of type 'System.Threading.SemaphoreSlim' could be found (are you missing

Why are these hashcodes equals?

Deadly 提交于 2019-12-06 03:19:06
This test is failing : var hashCode = new { CustomerId = 3354, ServiceId = 3, CmsThematicId = (int?)605, StartDate = (DateTime?)new DateTime(2013, 1, 5), EndDate = (DateTime?)new DateTime(2013, 1, 6) }.GetHashCode(); var hashCode2 = new { CustomerId = 1210, ServiceId = 3, CmsThematicId = (int?)591, StartDate = (DateTime?)new DateTime(2013, 3, 31), EndDate = (DateTime?)new DateTime(2013, 4, 1) }.GetHashCode(); Assert.AreNotEqual(hashCode, hashCode2); Can you tell me why ? Samuel Neff It's kinda amazing you found this coincidence. Anonymous classes have a generated GetHashCode() method that

Function import when sp is changed

落花浮王杯 提交于 2019-12-06 03:11:16
问题 I am using the function import feature of the entity framework to call a stored procedure from .net 4.0 code. However, everytime I change the stored proc result set, I have to delete the function import and add it again. Is there any way, in which I can incorporate the change by changing the code in the entity model, rather than having to delete and add the function import again? Thanks :) 回答1: When using function import some changes are reflected automatically. For example if you add

is it ok to use plinq ForAll for a bulk insert into database?

元气小坏坏 提交于 2019-12-06 03:10:00
问题 I'm doing like this: entities.AsParallel().ForAll(o => repository.Insert(o)); is this good, am I going to have more performance with this ? 回答1: No. This one can be faster, as it leverages the paralellism to the SQL, but in the end the SQL has to make a lock for the table (page), as it makes an insert. therefore each paralell request is executed after another again. If you want to make a bulk insert, than make a SP accepting all entries (e.g. a table with SQL 2008.) or do it with Linq2SQL.

Is it possible to retrieve data from Active Directory by impersonating a Windows authenticated user in ASP.NET?

佐手、 提交于 2019-12-06 02:55:58
问题 I've been trying to solve this problem all day, and I've read some conflicting information within the standard google message board answers. What I'm trying to do is retrieve a domain user's (that is, the currently logged in user's) email address from active directory. My ASP.NET 4 website is setup for Windows Authentication and everything works fine until the active directory calls. When I do the following, I get a COMException on the search.findAll() line. The exception message is "An