.net-4.5

Not allowed to load assembly from network location

戏子无情 提交于 2019-12-09 05:27:49
问题 I've recently set up a new Windows Server 2012 R2 environment and installed Visual Studio 2012 . Now I'm having a problem with multiple .NET 4.5 project's I migrated from my old server, a Windows Server 2008 machine. This never occurred on the old server. When trying to load an assembly from a network location, I run into the following issue: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET

How can I await an async method without an async modifier in this parent method?

∥☆過路亽.° 提交于 2019-12-09 04:41:08
问题 I have a method that I want to await but I don't want to cause a domino effect thinking anything can call this calling method and await it. For example, I have this method: public bool Save(string data) { int rowsAffected = await UpdateDataAsync(data); return rowsAffected > 0; } I'm calling: public Task<int> UpdateDataAsync() { return Task.Run(() => { return Data.Update(); //return an integer of rowsAffected } } This won't work because I have to put "async" in the method signature for Save()

VS2012 $(exists) only accepts scalar values

耗尽温柔 提交于 2019-12-09 04:37:21
问题 Okay, this is more of a build error than a programming error. I have never had much reason to get my hands dirty with builds, so this error is baffling me. I have tried googling this error with little results, the responses are either nonexistent, incomprehensible or not applicable. The error is: The "exists" function only accepts a scalar value, but its argument "$(PackageSourceManifest)" evaluates to "[same path];[same path]" which is not a scalar value. C:\Program Files(x86)\MSBuild

What is the best way to return completed Task?

偶尔善良 提交于 2019-12-09 03:58:28
问题 What is the best way to return a completed Task object? It is possible to write Task.Delay(0), or Task.FromResult<bool>(true) whatever. But what is the most efficient way? 回答1: Answer from Stephen Toub (MSFT): If you want a new Task object each time, Task.FromResult is the most efficient. Task.Delay(0) in its current implementation will return a cached task, but that's an implementation detail. If you want to use a cached task, you should cache one yourself, e.g. private static readonly Task

Garbage tags showing up in MVC views after installing VS 2013 + .Net 4.5.1

不问归期 提交于 2019-12-09 03:43:53
问题 In my ASP.Net MVC 4 application, there are several places where we are either manually rendering a view to a string or intercepting some part of the rendering pipeline. For example: public static string RenderPartialViewToString(Controller controller, string viewName, object model) { controller.ViewData.Model = model; try { using (System.IO.StringWriter sw = new System.IO.StringWriter()) { var viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName); var

how to prevent going back to previous page

北慕城南 提交于 2019-12-09 03:24:52
问题 For a windows phone 8 app I'm developing, I had to load some data at the starting of the app. For that matter I designed a page called SplashScreen.xaml that loads the data and after all the loading is done I navigate to the MainPage.xaml using: NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); Now when the user is in the main page and taps the back button on the phone instead of going out of the app(which is the default gesture) goes back to the SplashScreen.xaml ,

.Net 4.5 Svcutil generates two operations with the same name (Method and MethodAsync)

烈酒焚心 提交于 2019-12-09 02:24:30
问题 I am consuming a predefined wsdl with svcutil a la: svcutil some_service.wsdl one of the methods generated has the following signature: [System.ServiceModel.OperationContractAttribute(Action="http://ws.example.org/SubmitData", ReplyAction="*")] SubmitDataResponse SubmitData( SubmitDataRequest request ) While scvutil from VS2010/.net35 generates only the above and VS has no problem lanuching the service, the svcutil program that is part of VS2012/.net45 also generates a method with the

Place holder or watermark in TextBox windows 8

佐手、 提交于 2019-12-09 02:22:07
问题 I want to show a placeholder text in TextBox when user hasn't typed anything and TextBox is idle. In Andriod it can be done using android:hint="some Text" In iPhone it can be done as textFild.placeholder = "some text"; How can I do it in windows 8 metro apps? Thanks 回答1: Edit for windows-8.1 they have introduced a new property <TextBox x:Name="UserName" PlaceholderText="User Name"/> Please see Sergey Aldoukhov's answer For me this is the working solution that I got. If any one has better

How to change progressbar value when async task running

前提是你 提交于 2019-12-09 01:40:13
问题 i am using async await task to run this code and i want to change the progress bar when extracting public async Task<string> DownloadAndExtractFile(string source, string destination, string ItemDownload) //source = File Location //destination = Restore Location { string zPath = @"C:\Program Files\7-Zip\7zG.exe"; ProcessStartInfo pro = new ProcessStartInfo(); pro.WindowStyle = ProcessWindowStyle.Hidden; pro.FileName = zPath; pro.Arguments = "x \"" + source + "\" -o" + destination; await Task

Why does Task.Delay() allow an infinite delay?

人走茶凉 提交于 2019-12-09 00:28:37
问题 After my application froze I tracked down the cause to a thread waiting on a task created by Task.Delay() (or TaskEx.Delay() in .NET 4.0) for which it provided a computed TimeSpan that, due to a bug, was on occasion computed to a TimeSpan with a TotalMilliseconds of less than or equal to -1 and greater than -2 (i.e. anywhere between -10000 to -19999 ticks, inclusive). It appears that when you pass a negative TimeSpan that is -2 milliseconds or lower, the method correctly throws an