.net-4.0

Illegal characters in path when loading a string with XDocument

▼魔方 西西 提交于 2019-12-18 12:04:16
问题 I have very simple XML in a string that I'm trying to load via XDocument so that I can use LINQ to XML: var xmlString = @"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?> <person>Test Person</person>"; var doc = XDocument.Load(xmlString); //'Illegal characters in path' error thrown here I get an Illegal characters in path. error thrown when I try to load the XML; could someone please explain why this is happening? Thanks. 回答1: You are looking for XDocument.Parse - XDocument.Load

Does using assembly compiled in older version of .NET framework affects whole performance?

白昼怎懂夜的黑 提交于 2019-12-18 11:55:38
问题 Lets imagine that we have two assemblies: Foo.Logic (compiled on .NET 2.0 framework) Foo.Application (compiled on .NET 4.0 framework) that have reference and uses compiled Foo.Logic. Does it have impact on Foo.Application performance (or have any other drawbacks)? 回答1: In the situation you described in the question, everything will Just Work™ without any problems. A .NET 4.0 application will load a .NET 2.0 library directly into the .NET 4.0 runtime environment. It will not use side-by-side

Support of progress reporting and incremental results in .NET 4.0 “Task Parallel Library”

房东的猫 提交于 2019-12-18 11:48:46
问题 I know that Task Parallel Library is still in Beta and there are likely to be less resources available but from whatever I have read, library gives very special treatment to task scheduling, exception handling and cancellation. But I don't find any references to progress reporting and sending incremental results from tasks. These 2 things seem too important to ignore. Can you throw some light on how to handle these in Task Parallel Library or refer some articles which explains them? 回答1: This

Exception when deploying to IIS: Login failed for user 'IIS APPPOOL\DefaultAppPool'

核能气质少年 提交于 2019-12-18 11:44:34
问题 I'm working through some WCF examples in "Windows Communication Foundation 4 Step By Step". My resulting application runs fine as long as the service is hosted in casini. It fails when I deploy the service to local IIS. When deployed to IIS, I can browse to the svc page in IE. That works. According to the book, page 41, the app pool account needs to be a member of the db_owner role in my database. The author suggests, after verifying the correct address of the service (already did that),

Compacting a WeakReference Dictionary

℡╲_俬逩灬. 提交于 2019-12-18 11:34:23
问题 I've got a class Foo with a property Id . My goal is that there are no two instances of Foo with the same Id at the same time. So I created a factory method CreateFoo which uses a cache in order to return the same instance for the same Id . static Foo CreateFoo(int id) { Foo foo; if (!cache.TryGetValue(id, out foo)) { foo = new Foo(id); foo.Initialize(...); cache.Put(id, foo); } return foo; } The cache is implemented as a Dictionary<TKey,WeakReference>, based on @JaredPar 's Building a

Relay Command can execute and a Task

岁酱吖の 提交于 2019-12-18 11:34:08
问题 i want to start a task when a relay command is called, however i want to disable the button as long as that task is running take this example private ICommand update; public ICommand Update { get { if (update == null) { update = new RelayCommand( param => Task.Factory.StartNew(()=> StartUpdate()), param => true); //true means the button will always be enabled } return update; } } what is the best way to check if that task is running? here is my solution but not sure if its the best way class

Typesafe fire-and-forget asynchronous delegate invocation in C#

懵懂的女人 提交于 2019-12-18 11:32:09
问题 I recently found myself needing a typesafe "fire-and-forget" mechanism for running code asynchronously. Ideally, what I would want to do is something like: var myAction = (Action)(() => Console.WriteLine("yada yada")); myAction.FireAndForget(); // async invocation Unfortunately, the obvious choice of calling BeginInvoke() without a corresponding EndInvoke() does not work - it results in a slow resource leak (since the asyn state is held by the runtime and never released ... it's expecting an

Typesafe fire-and-forget asynchronous delegate invocation in C#

北城余情 提交于 2019-12-18 11:31:15
问题 I recently found myself needing a typesafe "fire-and-forget" mechanism for running code asynchronously. Ideally, what I would want to do is something like: var myAction = (Action)(() => Console.WriteLine("yada yada")); myAction.FireAndForget(); // async invocation Unfortunately, the obvious choice of calling BeginInvoke() without a corresponding EndInvoke() does not work - it results in a slow resource leak (since the asyn state is held by the runtime and never released ... it's expecting an

Client Profile vs Full [duplicate]

我的梦境 提交于 2019-12-18 10:39:24
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Difference between .NET 4 Client Profile and Full Framework download I noticed that you can change the target platform in .NET applications to the Client Profile or the Full profile. What is the difference between the two? How should I choose which is the correct one for my project? 回答1: There is very little point in targeting the client profile for .NET 4.0. The download is 41MB, the full version is 48MB, only

How can I convert a boxed two-dimensional array to a two-dimensional string array in one step?

亡梦爱人 提交于 2019-12-18 09:26:54
问题 Is there a way to convert a boxed two-dimensional array to a two-dimensional string array in one step using C#/.NET Framework 4.0? using ( MSExcel.Application app = MSExcel.Application.CreateApplication() ) { MSExcel.Workbook book1 = app.Workbooks.Open( this.txtOpen_FilePath.Text ); MSExcel.Worksheet sheet1 = (MSExcel.Worksheet)book1.Worksheets[1]; MSExcel.Range range = sheet1.GetRange( "A1", "F13" ); object value = range.Value; //the value is boxed two-dimensional array } I'm hopeful that