.net-4.0

How to remove the www. prefix in ASP.NET MVC

[亡魂溺海] 提交于 2019-12-21 20:57:32
问题 How do I remove the www. from incoming requests? Do I need to setup a 301 redirect or simply just rewrite the path? Either way, what's the best way to do it? Thanks! 回答1: I believe it would be more appropriate to do that with IIS' URL rewriting module. If you have access to IIS' management tool, there's a GUI to set up rewrite rules, in the "IIS" section of your site's settings. If you choose "Add Rule(s)..." from there (in the right column menu), choose the "Canonical domain name" rule in

How to set a binary attribute when using a AccountManagement Extension Class?

主宰稳场 提交于 2019-12-21 20:56:44
问题 I am using a custom class to expose some custom schema in Active Directory. I am storing a binary blob, per the project requirements this data must be stored in the AD, I can not use a external store (I would if I could). When I create the user it stores the blob fine. I also can retrieve the blob back out fine too and get all my data. The issue is if I need to update the value and I am getting errors Small example program: using System; using System.DirectoryServices.AccountManagement;

Can't load FSharp.Core version 4.0.0 in infer.net fun // hard link dependency in a dll ?

雨燕双飞 提交于 2019-12-21 20:14:07
问题 I am trying Infer.Net (An F# Library for Probabilistic Programming) And running the examples in VS11 Beta lead to the error : Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. If I open the dlls used the infer.net samples in Reflector, one, probcomp.dll, says it can not find automatically "FSharp.Core, Version=4.0.0.0"and that I need to select the location by

Legacy Security Policy in Visual Studio 2010 and COM References

半城伤御伤魂 提交于 2019-12-21 19:58:13
问题 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

Is there T4 templates available for generating c# classes from xsd?

一个人想着一个人 提交于 2019-12-21 17:56:45
问题 Is there T4 templates available for generating c# classes from xsd? 回答1: Not that I know of, but take a look at LINQ to XSD (http://linqtoxsd.codeplex.com/). You can use LinqToXsd.exe to generate strongly typed classes based on your schema. And then you have full LINQ support as well. Very handy. You could also set up a pre-build event on your project that looks something like: "$(ProjectDir)Lib/LinqToXsd/LinqToXsd.Exe" "$(ProjectDir)MySchema.xsd" /fileName:MySchema.cs And that would generate

MVC, WCF ASP.NET 4.0 & JQUERY

可紊 提交于 2019-12-21 17:49:48
问题 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

TextReader and peek next line

橙三吉。 提交于 2019-12-21 17:36:09
问题 I read a data from a text file using TextReader TextReader reader = new StreamReader(stream); string line; while ((line = reader.ReadLine()) != null) { //....... } Sometimes I need to peek next line ( or a few next lines ) from reader. How do I do that? 回答1: EDIT: Updated to allow any number of peeks: public class PeekingStreamReader : StreamReader { private Queue<string> _peeks; public PeekingStreamReader(Stream stream) : base(stream) { _peeks = new Queue<string>(); } public override string

WPF 4 multi-touch drag and drop

坚强是说给别人听的谎言 提交于 2019-12-21 17:19:16
问题 I have a WPF 4 application where I have implemented Drag and Drop using the standard DragDrop.DoDragDrop approach, but Im doing it using touch instead of Mouse events. My XAML for my Grid (that Im dragging) is as follows: <Grid x:Name="LayoutRoot" ManipulationStarting="ManipulationStarting" ManipulationDelta="ManipulationDelta" ManipulationCompleted="ManipulationCompleted" IsManipulationEnabled="True"> <!-- children in here --> </Grid> Now the code behind is like this: private void

Structuremap in Singleton returning multiple instances

ぃ、小莉子 提交于 2019-12-21 13:02:30
问题 I have registered 5 derived classes for the same interface using named instances. All these classes are registered as Singleton For<IBaseInterface>().Singleton().Use<DerivedClass1>().Named("Derived1"); For<IBaseInterface>().Singleton().Use<DerivedClass2>().Named("Derived2"); For<IBaseInterface>().Singleton().Use<DerivedClass3>().Named("Derived3"); There is a static class which resolves the instance based on input. However I observed that every call to ObjectFactory.GetInstance returns new

Construct Task from WaitHandle.Wait

时光总嘲笑我的痴心妄想 提交于 2019-12-21 12:31:19
问题 I chose to return Task<T> and Task from my objects methods to provide easy consumation by the gui. Some of the methods simply wait for mutex of other kind of waithandles . Is there a way to construct Task from WaitHandle.Wait() so that I don't have to block one treadpool thread for that. 回答1: There is a way to do this: you can subscribe to WaitHandle using ThreadPool.RegisterWaitForSingleObject method and wrap it via TaskCompletionSource class: public static class WaitHandleEx { public static