.net-4.0

Should methods that return Task throw exceptions?

丶灬走出姿态 提交于 2019-12-05 13:09:25
问题 The methods that return Task have two options for reporting an error: throwing exception right away returning the task that will finish with exception Should the caller expect both types of error reporting or is there some standard/agreement that limits task behavior to the second option? Example: class PageChecker { Task CheckWebPage(string url) { if(url == null) // Argument check throw Exception("Bad URL"); if(!HostPinger.IsHostOnline(url)) // Some other synchronous check throw Exception(

ClickOnce manifest

夙愿已清 提交于 2019-12-05 12:52:38
We are currently deploying a WPF 4 application via ClickOnce and there is a scenario when the installation fails. If the user does not have .NET 4.0 Full install and attempts to install our application the framework installs fine, but the application fails to install. If we re-run the installation again the application installs fine. Here is a copy of the log: PLATFORM VERSION INFO Windows : 6.1.7600.0 (Win32NT) Common Language Runtime : 2.0.50727.4927 System.Deployment.dll : 2.0.50727.4927 (NetFXspW7.050727-4900) mscorwks.dll : 2.0.50727.4927 (NetFXspW7.050727-4900) dfdll.dll : 2.0.50727.4927

Entity Framework: Alternate solution to using non primary unique keys in an association

妖精的绣舞 提交于 2019-12-05 12:45:52
问题 I know the entity frame work does not allow you to generate a model from a database using non primary unique keys as a Foreign Key association. Can I modify the EDMX manually? If so, can someone provide me an example or reference? If not, are there any other possibilities? Easiest Example: Here is the DDL for the tables. You will notice I have a foreign Key from PersonType.TypeCode to Person.TypeCode CREATE TABLE [dbo].[PersonType]( [PersonTypeId] [int] NOT NULL, [TypeCode] [varchar](10) NOT

How do I get the ID of the current logged in user?

喜你入骨 提交于 2019-12-05 12:37:51
I'm working on a sample project built from the ASP.NET Web Application template (web forms, not MVC). After a user logs in, I want to grab the user's ID and store it in a session variable so I can pass it between pages. How do I get the user's ID from the ASP.NET membership provider? By user's ID, I'm referring to the GUID in the membership database. Is there a method to get the user's ID? I'm using the default database schema and have it deployed to my server. Thanks! Try this: MembershipUser membershipUser = Membership.GetUser(); string UserID = membershipUser.ProviderUserKey.ToString(); You

DLR and Javascript interpretation in c# 4?

社会主义新天地 提交于 2019-12-05 12:10:26
I want to execute a javascript code from c# using DLR. So I wrote a simple code using c# and Jint : var script = @" function show( ) { return parseInt('123asd'); //in js it's 123 }; return show();"; var result = new JintEngine().Run(script); Console.WriteLine(result); parseInt('123asd') in javascript is : 123 But the result I get is : Maybe I don't see the whole picture, but if a programmer on the other side of the world sends me his script file, I (and him) expect the result to be consistent! If I was mistaken, in what scenario would I use running other code on .Net? (I will have to be very

CLR 2.0 vs 4.0 performance?

房东的猫 提交于 2019-12-05 12:06:55
Will a .NET program compiled for CLR 2.0 run faster if running unden CLR 4.0? app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" /> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> Typically, no - it will be identical. By default, the CLR 4 runtime will load the CLR 2 runtime to execute your CLR 2 code base. Forcing execution under CLR 4 requires setting useLegacyV2RuntimeActivationPolicy in your app.Config. If you add that flag, then it will run in v4 of the

URL rewriting in .NET 4?

回眸只為那壹抹淺笑 提交于 2019-12-05 11:53:41
I heard that in Visual Studio 2010 give built-in functionality for URL rewriting using its URL Routing engine. I did URL rewriting in earlier version of visual studio by using plug in like intelligencia urlrewrite. Can any one explain me or guide me to understand that? Want to implement dynamic and custom url rewriting in my website. Are you refering to .net 4.0 URL Routing ? URL routing was a capability we first introduced with ASP.NET 3.5 SP1, and which is already used within ASP.NET MVC applications to expose clean, SEO-friendly “web 2.0” URLs. URL routing lets you configure an application

IDisposable implementation - What should go in 'if (disposing)'

你离开我真会死。 提交于 2019-12-05 11:39:18
问题 I have been fixing some memory leak issues in a winforms application and noticed some disposable objects that are not Disposed explicitly (developer hasn't called Dispose method). Implementation of Finalize method also doesn't help because it doesn't go in if (disposing) clause. All the static event unregistering and collection clearing have been put in if (disposing) clause. The best practice is calling the Dispose if the object is disposable, but unfortunately this happens sometimes If

InvalidOperationException in my Lazy<> value factory

寵の児 提交于 2019-12-05 11:16:19
问题 I have a class containing something like the following: public static class Config { private static Lazy<ConfigSource> _cfgSrc = new Lazy<ConfigSource>( () => { /* "ValueFactory" here... */ }, true); public static ConfigSource ConfigSource { get { return _cfgSrc.Value; } } } In accessing the ConfigSource property, I encountered this InvalidOperationException : ValueFactory attempted to access the Value property of this instance. I don't see anything in my "value factory" method that accesses

IIS complaining about Identity Impersonation using LDAP Authentication

爷,独闯天下 提交于 2019-12-05 10:33:17
问题 I followed a tutorial to implement LDAP authentication in an ASP.NET/C# 4.0 web application. I did so in Visual Studio 2010. The site runs fine in debug mode through Visual Studio, but when I publish this site in IIS7, it is failing with the following error: HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. Most likely causes: system.web/identity@impersonate is set to true. In fact, part of the tutorial