.net-4.0

Random 401 errors on an auto compiled asp.net site when updated pages are pushed

荒凉一梦 提交于 2019-12-04 17:01:10
We have an asp.net web site that is deployed on several IIS servers. The site is compile-on-demand as opposed to a pre-compiled web application. Normally deployments go fine but every now and again we get a 401 for one of the deployed pages on one of the servers. There is nothing special about which page or which server apart from the fact that it's generally the higher traffic pages that it happens to. The only way to rectify this is to deploy the same page again. The ACLs look fine on the files themselves so the thought is that there is a file locking issue in the Temporary ASP.NET Files

Where are my System.Management.* classes?

折月煮酒 提交于 2019-12-04 16:54:57
问题 I just installed Visual Studio 2010 with .NET Framework 4.0 and C# and I can't find anything under the System.Management namespace except for System.Management.Instrumentation . All the online documentation at MSDN about WMI keeps telling me that I have to use classes such as System.Management.ManagementObjectSearcher or System.Management.ManagementScope but I don't see those classes. What happened to those classes and how can I access them? 回答1: You need to add a reference to System

Equivalent of Task.FromResult() from .NET 4.5 in .NET 4.0

Deadly 提交于 2019-12-04 16:53:45
I cant find information about retargeting my code from .NET 4.5 to 4.0. I have to install this application on Windows XP. my code in .NET 4.5 public async Task <IXLWorksheet> ImportFile(string fileToImport) { ... return await Task.FromResult<IXLWorksheet>(Sheet1) } In .NET 4.0 method FromResult does not exist. Someone knows how it should looks in .NET 4.0?? You're returning the awaited result of a task, which is constructed on a result. The solution is rather simple - drop the await : return Sheet1; The async keyword in the method declaration will take care of wrapping it in a task. If, for

'System.Web.Extensions' trouble deploying .Net Framework 4 Website on IIS7

微笑、不失礼 提交于 2019-12-04 16:44:29
问题 I am trying to deploy a .Net framework 4 website on IIS7 server. I have already changed the application-pool's target framework to .Net 4, but the app is still showing me the error: "The configuration section 'system.web.extensions' cannot be read because it is missing a section declaration" I am guessing that has something to do with the new feature of .Net4 that lets me have a compact Web config file. I think for some reason IIS7 is not happy with this. What can I do to deploy this app

The primary reference could not be resolved because it was built against a higher version of the .NET framework than the currently targeted framework

二次信任 提交于 2019-12-04 16:29:42
问题 I am trying to build a project that references a 3rd party SlingshotClient.dll. The project builds fine on other developers workstations. However, I am getting the error below. One difference that I could imagine is contributing to my issue is that I also have VS 2012 and .NET Frameworks 4.5 installed on my machine. I believe the other developers that can build this successfully, don't have those installed. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5):

.NET 4 ObjectCache - Can We Hook Into a “Cache Expired” Event?

女生的网名这么多〃 提交于 2019-12-04 16:20:37
问题 I've got a simple object being cached like this: _myCache.Add(someKey, someObj, policy); Where _myCache is declared as ObjectCache (but injected via DI as MemoryCache.Default ), someObj is the object i'm adding, and policy is a CacheItemPolicy . If i have a CacheItemPolicy like this: var policy = new CacheItemPolicy { Priority = CacheItemPriority.Default, SlidingExpiration = TimeSpan.FromHours(1) }; It means it will expire in 1 hour. Cool. But what will happen is that unlucky first user after

Having Trouble Setting Window's Owner in Parent's Constructor

 ̄綄美尐妖づ 提交于 2019-12-04 16:19:03
问题 Is there anything wrong in WPF with setting the Owner property of a window to its parent in that parent's constructor? There shouldn't be, right? So why am I getting an XamlParseException from the following code? public partial class MainView : Window { private readonly OwnedWindow owned; public MainView() { InitializeComponent(); owned = new OwnedWindow(); owned.DataContext = DataContext; var window = GetWindow(this); owned.Owner = this; //Setting to window causes the same error ... } I

'foreach' failing when using Parallel Task Library

丶灬走出姿态 提交于 2019-12-04 16:09:24
The following code creates the correct number of files, but every file contains the contents of the first list. Can anyone spot what I've done wrong please? private IList<List<string>> GetLists() { // Code omitted for brevity... } private void DoSomethingInParallel() { var lists = GetLists(); var tasks = new List<Task>(); var factory = new TaskFactory(); foreach (var list in lists) { tasks.Add(factory.StartNew(() => { WriteListToLogFile(list); })); } Task.WaitAll(tasks.ToArray()); } The reason why is down to the way C# evaluates anonymous methods, they're not true closures. It really has

Creating a class like ASP.NET MVC 3 ViewBag?

烈酒焚心 提交于 2019-12-04 16:06:38
问题 I have a situation where I would like to do something simular to what was done with the ASP.NET MVC 3 ViewBag object where properties are created at runtime? Or is it at compile time? Anyway I was wondering how to go about creating an object with this behaviour? 回答1: Use an object of type dynamic . See this article for more information. 回答2: I created something like this: public class MyBag : DynamicObject { private readonly Dictionary<string, dynamic> _properties = new Dictionary<string,

Why does this line cause a VerificationException when running under .NET 4?

这一生的挚爱 提交于 2019-12-04 15:56:41
问题 Help me out folks - why does this code cause a VerificationException when run under .NET 4.0? public T parseEnum<T>(string value, T defaultValue) { //Removing the following lines fixes the problem if (!typeof(T).IsEnum) throw new ArgumentException("T must be an enumerated type"); return defaultValue; } I ran peverify on the .net 2.0 assembly and got the following message: ImageResizer.Util.Utils::parseEnum[T]][offset 0x0000000A] The 'this' parameter to the call must be the calling method's