.net-4.0

Setting an Event to Null

不羁岁月 提交于 2019-12-04 10:26:41
问题 I have a code like this: public class SomeClass { int _processProgress; public int ProcessProgress { get { return _processProgress; } set { _processProgress = value; if (ProcessProgressChanged != null) ProcessProgressChanged(value); } } public delegate void ProcessProgressChangedEventHandler(int progressPercentage); public event ProcessProgressChangedEventHandler ProcessProgressChanged; public void ClearProcessProgressChangedEvent() { this.ProcessProgressChanged = null; } } Will it

Legacy Security Policy in Visual Studio 2010 and COM References

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 10:05:44
I have a project using DevExpress 8.3 (2008.3) which I just recently upgraded to use VS 2010. After doing so, everything compiled fine but I got errors trying to use the designer. I resolved this as described here: NetFx40_LegacySecurityPolicy in design-time mode by adding <NetFx40_LegacySecurityPolicy enabled="true"/> to my devenv.exe.config. Designer works fine now, but some of the projects in the solution which have COM references no longer compile, with the exception: The "ResolveComReference" task could not be instantiated from "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral

Updating deployment manifest for a ClickOnce application programmatically results in missing <compatibleFrameworks> element, required in 4.0

蹲街弑〆低调 提交于 2019-12-04 09:37:36
问题 I'm working on automating the installer for a .NET 4.0 ClickOnce WPF application, which needs a few items to be set in the app.config file. I've gone through the thorny process of finding specific steps I must follow using Mage.exe (that is, update and re-sign application and deployment manifests) and now am trying to automate it for installation. I opted to use .deploy extension to minimize issues with IIS/Internet Explorer security mechanisms, so essentially the algorithm is as follows

.Net why does Threading.Task.Task still block my UI?

冷暖自知 提交于 2019-12-04 09:21:16
问题 I'm currently writing an application that will control positioning of a measurement device. Because of the hardware involved I need to poll for the current position value constantly while running the electric motor. I'm trying to build the class responsible for this so that it does the polling on a background thread and will raise an event when the desired position is reached. The idea being that the polling won't block the rest of the application or the GUI. I wanted to use the new Threading

MVC, WCF ASP.NET 4.0 & JQUERY

余生长醉 提交于 2019-12-04 09:20:20
I've spent the past few days getting frustrated with WCF, so I've decided to post for help on here because.. well.. I don't have a clue where to start!.. any help would be appreciated! Firstly: When creating a WCF Service in .Net 4.0, which template should I use if I want to be able to create a service that will accept data from an AJAX POST using JQuery? (I'd like to be able to have a Global.asax if possible). Secondly: My service works fine in the WCF Test Client, however when I manage to get it to accept GET requests, the Test Client stops showing the service methods. POST methods just seem

Left outer join and group by

丶灬走出姿态 提交于 2019-12-04 09:14:31
I have the following class definition: public class MyData { public DateTime Expiration { get; private set; } public string Name { get; private set; } public double Price { get; private set; } public double Quantity { get; private set; } } I need to join this with a list of years: IEnumerable<int> years= Enumerable.Range(1, 20); The result will be ultimately be displayed in a grid with the y-axis representing the Name field and the x-axis representing the years. Each cell will be the aggregated Quantity * Price for the Name and year. I am currently struggling with the syntax. I started off by

How to conditionally run a code asynchonously using tasks

萝らか妹 提交于 2019-12-04 09:13:57
问题 I have a class in charge of retrieving resources which also caches them for quick access. The class exposes an asynchronous method for retrieving a resource: public Task<object> GetResourceAsync(string resourceName) { return Task.Factory.StartNew<object>(() => { // look in cache // if not found, get from disk // return resource }); } The client code then looks like this: myResourceProvider.GetResourceAsync("myResource") .ContinueWith<object>(t => Console.WriteLine("Got resource " + t.Result

LogonUserIdentity.Name vs. User.Identity.Name

末鹿安然 提交于 2019-12-04 09:05:14
I have an ASP.NET Web Forms Application project that is running upon the 4.0 framework. I'm very familiar with Web Applications, but not so much with Web Forms Applications. I ran into a notable difference between the two of them today, and I'm confused at why this difference even exists. Typically, in a Web Application, if I want to determine who the current user of the page is then I just retrieve their domain log-in from User.Identity.Name . So, I was quite perplexed when I hit F5 to run my solution (my Web Forms Application!) in my debug environment and found that the User.Identity.Name

Is it necessary to create ASP.NET 4.0 SQL session state database, distinct from existing ASP.NET 2.0 ASPState DB?

假装没事ソ 提交于 2019-12-04 09:05:06
问题 Is the ASP.NET 4.0 SQL session state mechanism backward-compatible with the ASP.NET 2.0 schema for session state, or should/must we create a separate and distinct session state database for our ASP.NET 4.0 apps? I'm leaning towards the latter anyway, but the 2.0 database seems to just work, though I'm wondering if there are any substantive differences between the ASPState database schema / procedures between the 2.0 and 4.0 versions of ASP.NET. Thank you. 回答1: There was no quick answer on

MEF parts configuration, where to store?

China☆狼群 提交于 2019-12-04 08:52:56
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 ? 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 section, I was not able to read from the DLL's app config. It always wanted to read from the MEF Consumer