.net-4.0

Is this PInvoke code correct and reliable?

旧城冷巷雨未停 提交于 2019-12-29 05:43:06
问题 In this question I have searched for a simple solution to unblock files. Thanks to all the comments and answer, I have found a simple solution by PInvoking DeleteFile . It works, but because I've never used file-operations through PInvoke (Win32), I don't know if there are some pitfalls or if there is another method of calling DeleteFile to delete the alternate stream of a file. What I also don't know is if I have to wrap the call in a try/catch or if it is enough just to look the at the

Does .Net Framework 4.0 have features for connecting to DB2

巧了我就是萌 提交于 2019-12-29 03:25:41
问题 I need to know is there any feature of connecting to DB2 database from .net in .Net framework 4.0 EDIT:- I like to know if there is any DB2 provider 回答1: Yep, the family of IBM.Data.DB2 drivers (collectively found in IBM.Data.DB2.dll, I believe) should work just fine with .NET, providing you install the drivers on your development machine. Additionally, I was able to get it to work successfully with VS2010Beta and EF4Beta2, despite the lack of Visual Studio Add-ins for VS2010 (as of this date

When executing an application on .net 4.0, compiled under .net 2.0

大憨熊 提交于 2019-12-29 03:06:06
问题 Assuming that: The C# source code below is compiled under .NET 2.0 (CLR 2.0); and The above application uses the app.config listed below; and Only .NET 4.0 (CLR 4.0) is installed on the environment of the client executing the application, then which version of .NET is internally loaded to execute the application on the client's environment? Description The console application below will simply show that its CLR version is v4.0.30319 in the console, but @Reed Copsey's answer of the stack (CLR

Databind repeater using Linq with group by

ぃ、小莉子 提交于 2019-12-29 01:45:57
问题 I need to bind a repeater with hierarchical data as follows: Category1 - Item1 - Item2 Category2 - Item3 - Item4 I currently have a single dataset with the items as well as the category that each item belongs to. I'm trying to learn Linq and was wondering if there was a way I can do the same using Linq? Below is what I tried: var groupbyfilter = from dr in dtListing.AsEnumerable() group dr by dr["Category"]; DataTable dtFinal = dtListing.Clone(); foreach (var x in groupbyfilter) x

C# external library (Lua) call problem

我怕爱的太早我们不能终老 提交于 2019-12-29 01:01:27
问题 I'm new to programming in C# (VS2010) .Net (4.0) and I'm encountering I couldn't solve by myself since some days already. I'm using an external scripting language (Lua) in my C# code. To do so I use LuaInterpreter built for .Net 4.0 First try: The project is a console application -> the program works fine when I try to call a Lua class. Second try: The project is a class Librrary COM used from Excel -> The class library compile fine and my user defined functions work fine within Excel. But

.NET 4 RTM MetadataType attribute ignored when using Validator

我的未来我决定 提交于 2019-12-28 21:48:52
问题 I am using VS 2010 RTM and trying to perform some basic validation on a simple type using MetadataTypeAttribute. When I put the validation attribute on the main class, everything works. However, when I put it on the metadata class, it seems to be ignored. I must be missing something trivial, but I've been stuck on this for a while now. I had a look at the Enterprise Library validation block as a workaround, but it doesn't support validation of single properties out of the box. Any ideas?

Why can't I assign List<int> to IEnumerable<object> in .NET 4.0

元气小坏坏 提交于 2019-12-28 20:37:32
问题 I try to do this: IEnumerable<object> ids = new List<string>() { "0001", "0002", "0003" }; it works great! But when I try to do this: IEnumerable<object> intIds = new List<System.Int32>() { 1, 2, 3 }; Visual Studio tells me: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?) Why is that? 回答1: int is a value type and can only be boxed to object - it doesn't inherit from object .

How to serialize property of type Object with XmlSerializer

天大地大妈咪最大 提交于 2019-12-28 18:06:25
问题 I have a property: public object Tag but it can contain finite number of types, unfortunately without base type (except object type). But when I serialize the object with this property, it doesn't get serialized. Is there a way to instruct XmlSerializer with possible types? 回答1: I don't recommend this, but yes, you can use [XmlElement] etc to tell it about multiple candidate types for a member: public class Test { private static void Main() { var ser = new XmlSerializer(typeof (Test)); var

How to get cookies info inside of a CookieContainer? (All Of Them, Not For A Specific Domain)

試著忘記壹切 提交于 2019-12-28 13:19:07
问题 Please see the code below: CookieContainer cookieJar = new CookieContainer(); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com"); request.CookieContainer = cookieJar; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); int cookieCount = cookieJar.Count; How can I get cookies info inside cookieJar ? (All of them, not just for a specific domain.) And how can I add or remove a cookie from that? 回答1: reflection can be used to get the private

What 130 second timeout is killing my WCF streaming service call?

时光毁灭记忆、已成空白 提交于 2019-12-28 11:54:46
问题 Just recently I started to investigate a tricky problem with WCF streaming in which a CommunicationException is produced if the client waits for any longer than 130 seconds in between sends to the server. Here is the full exception: System.ServiceModel.CommunicationException was unhandled by user code HResult=-2146233087 Message=The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying