.net-4.0

Should “or” work with .Net4 Hasflags: enum.HasFlag(AccessRights.Read | AccessRights.Write)

瘦欲@ 提交于 2019-12-30 04:05:48
问题 I am trying out the new HasFlags features, and was wondering if the following should work: enum.HasFlag(AccessRights.Read | AccessRights.Write) ... because it doesn't seem to... DBAccessRights rights = (DBAccessRights)permission.PermissionFlags; if (rights.HasFlag(DBAccessRights.WikiMode)) { // works } if (rights.HasFlag(DBAccessRights.WikiMode | DBAccessRights.CreateNew)) { // Doesn't work } DBAccessRights flags = DBAccessRights.WikiMode | DBAccessRights.CreateNew; if (rights.HasFlag(flags))

Impersonation in ASP.NET web application does not work when running on IIS

痴心易碎 提交于 2019-12-30 03:32:07
问题 I am working on ASP.NET 4.0 MVC3 web application that works in intranet environment. The application makes use of Windows authentication. Its application pool is run by domain user that has spn set on a domain controller. Authentication works using Kerberos (on IE and Firefox after some additional configuration). Now I want to upload files to sharepoint, but it's important for me to upload the file as the user currently logged in into the application (so the file is created on Sharepoint with

WCF DataContract with readonly properties

江枫思渺然 提交于 2019-12-30 02:45:06
问题 I'm trying to return a complex type from a service method in WCF. I'm using C# and .NET 4. This complex type is meant to be invariant (the same way .net strings are). Furthermore, the service only returns it and never receives it as an argument. If I try to define only getters on properties I get a run time error. I guess this is because no setters causes serialization to fail. Still, I think this type should be invariant. Example: [DataContract] class A { [DataMember] int ReadOnlyProperty

C# UTC to Users Local Time

徘徊边缘 提交于 2019-12-30 02:33:04
问题 I have a site where users can make posts. The users can be from all over the globe so when they post, I am storing the posted date as DateTime.UtcNow. I am using the JQuery time ago plug in to show the posted dat similar to stack overflow (1 min ago etc...) But I am not sure how to convert to date I have stored in the system to the users local time? Here is what I am using: public static MvcHtmlString ConvertToLocalTime(this HtmlHelper htmlHelper, DateTime date) { DateTime convertedDate =

Multipage PDF document from predefined template

天大地大妈咪最大 提交于 2019-12-30 00:48:07
问题 I have a requirement to generate invoice reports in PDF using some predefined company templates. I am able to create/generate SINGLE PAGE PDF reports using iTextSharp. Problem: The problem comes when the invoice statement spans MULTIPLE PAGES . I am not able to extend the report(invoice statement) to next(2nd) page. If all the data can not be accommodated on one page it should be written on 2nd page, while still using the company template. The template is present at following path:

C# parse XML File

喜夏-厌秋 提交于 2019-12-29 09:04:51
问题 I've a problem to parse my XML File (RSS Feed) in C#. I just want to read out the "entry" entries (the root parent - "feed" - is not relevant). All "entry" entries are almost even, except the part "state". Some entries doesn't have that entry. So i just want to read out the following: "entry" nodes: updated expires title summary state (if exists) Any suggestions? Thank you very much. <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <updated>2011-01-01T00:00:00

connecting to FTP server - The remote server returned an error: (550)

我们两清 提交于 2019-12-29 08:48:12
问题 I'm getting the error " The remote server returned an error: (550) File unavailable (e.g., file not found, no access). " when I call my function sendFile2FTP Function sendFile2FTP(fileNameLocal As String, fileNameServer As String, user As String, password As String) As String Dim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create(fileNameServer) ftpRequest.Credentials = New Net.NetworkCredential(user, password) ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFile Try Dim ficheiro()

Can anyone recreate the following bug I'm experiencing in routes with 2 or more optional parameters, in .NET 4.0 / MVC3?

三世轮回 提交于 2019-12-29 07:44:05
问题 I know that if you think you found a bug in the .NET framework you are most likely wrong, but that's why I'm writing this question, so please hear me out. I am fairly certain that there is a difference between the routes in .NET 3.5 and .NET 4.0 when it comes to optional parameters. Specifically if you have more than one optional parameter in your route. I have not been able to find this breaking change noted in any release notes of either .NET 4.0 or MVC 3 so thats why I call it a bug. EDIT:

WPF: Xaml, create an observable collection<object> in xaml in .NET 4.0

夙愿已清 提交于 2019-12-29 07:35:32
问题 the web site says you can in .NET 4.0 I cant seem to do it though, what assesmbly references and xmlns' do i need the following does not work xmlns:coll="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib" <coll:ObservableCollection x:TypeArguments="x:Object"> <MenuItem Command="ApplicationCommands.Cut"/> <MenuItem Command="ApplicationCommands.Copy"/> <MenuItem Command="ApplicationCommands.Paste"/> </coll:ObservableCollection> 回答1: ObservableCollection<T> is defined in the System

Entity Framework 4 Multiple Object Delete(RemoveAll)

流过昼夜 提交于 2019-12-29 06:45:08
问题 I read that the new Entity Framework will include a method to delete multiple items (Linq to SQL has DeleteAllOnSubmit()) but I can't find the function/method to do that. Is this in Beta 2 or do I have to make my own? UPDATE: This is what I'm using now: public void DeleteObjects(IEnumerable<object> objects) { foreach (object o in objects) { DeleteObject(o); } SaveChanges(); } 回答1: EF 4 allows you to execute TSQL statements against an object context: using (var context = new