.net-4.0

Timeout.InfiniteTimespan in .Net 4.0?

旧街凉风 提交于 2019-12-05 00:51:53
I actually do know that Timeout.InfiniteTimespan does not exist in .NET 4.0. Noticed, there's also Timeout.Infinite which does exist in .NET 4.0 I am calling those two methods: // the Change-Method public bool Change( TimeSpan dueTime, TimeSpan period ) // the Constructor of Timer public Timer( TimerCallback callback, Object state, TimeSpan dueTime, TimeSpan period ) in some cases, the dueTime Parameter needs to be infinite, which means the Event is not fired. I know I could simply use an other overload, but I feel like something has to be more simple. I already tried using new TimeSpan(0, 0,

C# Determine remote desktop login user's computer name

让人想犯罪 __ 提交于 2019-12-05 00:49:27
问题 I have been researching for a couple of weeks now, on and off, on how to determine the computer name of the user that is logged in via remote desktop. I have an application that users run on a terminal server environment, and I would like to capture and store the name of the computer that they are using to connect to the terminal server with. So far, I have not been able to find code or create my own that can do this, and I think I am just not asking the right questions. Any assistance would

Why don't object reference error exceptions in .net tell me which object was null?

萝らか妹 提交于 2019-12-05 00:47:49
Maybe asking the question betrays my lack of knowledge about the process, but then again, there's no better reason to ask! Tracking these down can be frustrating because stack traces can help me know where to start looking but not which object was null. What is going on under the hood here? Is it because the variable names aren't bundled in the executable? .NET code built with full optimizations and no debug info: your local variable names are gone, some local variables may have been eliminated entirely. .NET code built with full optimizations + PDB (or full debug): most local variable names

EF4 Audit changes of many to many relationships

女生的网名这么多〃 提交于 2019-12-05 00:47:02
问题 I am in the process of adding auditing into my EF4 (model first) application. I can get the details about the structural properties on entities that have changes. I can also see when there have been changes on a many to many relationship. I can see the name of the types involved and what happened (add or remove) but what I'd really like is the Id's of the entities that are involved in the relationship change. Here is what I currently have for tracking changes to many to many relationships:

Microsoft ReportViewer Web Control Requiring a ScriptManager

佐手、 提交于 2019-12-05 00:31:15
I'm trying to render the report viewer programmatically within a custom Page placed in an IHttpHandler context ReportViewer rv = new ReportViewer(); ReportDataSource rds = new ReportDataSource(); rds.Name = "Report"; rv.LocalReport.ReportPath = "Report.rdlc"; rds.Value = SomeReportObject; rv.LocalReport.DataSources.Add(rds); rv.LocalReport.Refresh(); ScriptManager scriptHandler = new ScriptManager(); MyPage p = new MyPage(); p.Controls.Add(scriptHandler); p.Controls.Add(rv); using (TextWriter myTextWriter = new StringWriter()) { using (HtmlTextWriter myWriter = new HtmlTextWriter(myTextWriter)

Can I use a .NET 4 feature while targeting .NET 3.5 SP1?

丶灬走出姿态 提交于 2019-12-05 00:16:49
问题 I would like to use some of the features in .NET 4.0 but still target .NET 3.5 within Visual Studio 2010. Basically I want to have something like: if (.NET 4 installed) then execute .NET 4 feature This is an optional feature, and I would just like it to run if the system has .NET 4.0 installed. If the system only has .NET 3.5 then the feature would not execute as is it not something that is critical to the application. 回答1: First of all, you have to target the 3.5 version of the framework but

Error code 5100 when installing .NET framework as part of a ClickOnce application deployment via Visual Studio 2010

╄→гoц情女王★ 提交于 2019-12-05 00:13:25
Inside Visual Studio 2010, I've set my application to target version 4 of the .NET Framework and for "All CPUs". As some of our users are 64-bit while others are 32-bit, I assume one would choose All CPUs. Is that correct? On a particular user's 32-bit Windows 7 SP1 machine, the framework installation (via ClickOnce) is failing with an error code 5100, which according to this MSDN article , indicates that The user's computer does not meet system requirements . The user's PC is 32-bit Windows 7 SP1, so I wonder if the command argument 'FullX64Bootstrapper' is correct in the first place? This

Is Regex instance thread safe for matches in C#

爱⌒轻易说出口 提交于 2019-12-04 23:44:23
I have this regex which I am using in a Parallel.ForEach<string> . Is it safe? Regex reg = new Regex(SomeRegexStringWith2Groups); Parallel.ForEach<string>(MyStrings.ToArray(), (str) => { foreach (Match match in reg.Matches(str)) //is this safe? lock (dict) if (!dict.ContainsKey(match.Groups[1].Value)) dict.Add(match.Groups[1].Value, match.Groups[2].Value); }); Regex objects are read-only, and therefore are thread safe. It's their returns, the Match objects that could potentially cause problems. MSDN confirms this : The Regex class itself is thread safe and immutable (read-only). That is, Regex

Can I develop asp.net 3.5/2.0 projects using Visual Studio 2010?

为君一笑 提交于 2019-12-04 23:41:33
Can I develop asp.net 3.5/2.0 projects using Visual Studio 2010? Or I will be stick on .Net Framework 4.0? From MSDN VS 2010 The multi-targeting feature of Visual Studio lets you specify the version of the .NET Framework, or its profile, that is required for your application. The key benefit of multi-targeting is that you can use the current version of Visual Studio to create and develop projects that target earlier versions of the .NET Framework. For example, you can continue to develop projects that were created in Visual Studio 2008 without adding new .NET Framework dependencies. Shoban Yes

Thread.CurrentPrincipal in .NET console application

蹲街弑〆低调 提交于 2019-12-04 23:38:00
Here is a trivial console application that i run in command prompt: using System; using System.Threading; namespace Test { internal class Runner { [STAThread] static void Main(string[] args) { Console.WriteLine(Thread.CurrentPrincipal.GetType().Name); Console.WriteLine(Thread.CurrentPrincipal.Identity.Name); } } } The output is 'GenericPrincipal' and empty string as identity name. Why the run-time constructs GenericPrincipal instead of WindowsPrincipal ? How do i force it to construct WindowsPrincipal from the security token of the starting process (cmd.exe in my case)? You have to tell your