.net-4.0

Does PostedFile.FileName work differently in .Net 4.0?

a 夏天 提交于 2019-12-10 10:19:42
问题 I'm working on an ASP.Net site which allows users to link documents using a UNC path. This site is used by a customer of ours for internal processes, so all users on their domain should have access to the UNC path. When a user wants to add a linked document, they select the file using a FileUpload control. Previously in .Net 2.0, the control's PostedFile.FileName property returned the filename and the full UNC path. Now we are using .Net 4.0 and it only returns the filename. Here's my main

How to convert PNG to BMP at runtime?

 ̄綄美尐妖づ 提交于 2019-12-10 10:17:57
问题 I need to convert PNG file to BMP file on runtime. I can't do it like Image dummy = Image.FromFile("image.png"); dummy.Save("image.bmp", ImageFormat.Bmp); because i can't save the bmp image on the local disk as a file. Thanks for any help. 回答1: You can save to stream using(MemoryStream stream = new MemoryStream()) { Dummy.Save(stream, ImageFormat.Bmp); } 回答2: Precise answer given here. Image Dummy = Image.FromFile("image.png"); Dummy.Save("image.bmp", ImageFormat.Bmp); Since you don't want to

Serializing cyclic object references using DataContractSerializer not working

戏子无情 提交于 2019-12-10 10:17:11
问题 I'm building an XNA game and I'm trying to save game/map etc. state completely, and then be able to load and resume from exactly the same state. My game logic consists of fairly complex elements (for serializing) such as references, delegates etc. I've done hours of research and decided that it's the best to use a DataContractSerializer that preserves the object references. (I also got around for delegates but that's another topic) I have no problem serializing and deserializing the state, re

WCF Service exception error when try to host in ASP.NET Web Site

随声附和 提交于 2019-12-10 10:13:42
问题 The following error occurs when trying to browse my .svc file. An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.NullReferenceException: Object reference not set to an instance of an object. at System.ServiceModel.Description.WsdlExporter.CreateWsdlBindingAndPort(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, Port& wsdlPort, Boolean& newBinding, Boolean& bindingNameWasUniquified) at System.ServiceModel.Description.WsdlExporter

.NET4.0: Thread-Safe Manner of Updating A Dictionary and Its Values

情到浓时终转凉″ 提交于 2019-12-10 10:07:38
问题 I have a static Dictionary that I want to safely update. Initially, the dictionary will be empty, but over the lifetime of app, it will have new values added to it. Also, the integer values will act as individual counters that can increment and decrement. private static Dictionary<string, int> foo = new Dictionary<string, int>(); public static void Add(string bar) { if (!foo.ContainsKey(bar)) foo.Add(bar, 0); foo[bar] = foo[bar] + 1; } public static void Remove(string bar) { if (foo

WPF Binding Path=/ not working?

别来无恙 提交于 2019-12-10 10:05:29
问题 I've set up my DataContext like this: <Window.DataContext> <c:DownloadManager /> </Window.DataContext> Where DownloadManager is Enumerable<DownloadItem> . Then I set my DataGrid like this: <DataGrid Name="dataGrid1" ItemsSource="{Binding Path=/}" ... So that it should list all the DownloadItems, right? So I should be able to set my columns like: <DataGridTextColumn Binding="{Binding Path=Uri, Mode=OneWay}" Where Uri is a property of the DownloadItem . But it doesn't seem to like this. In the

How can I write a custom WorkFlow 4 Code Activity that includes a “Body Block”?

十年热恋 提交于 2019-12-10 09:43:37
问题 Is this possible? I know it is for MS since they have WF activity packs but I'm not sure how it's done. It would be nice to be able to have Activities with Body blocks to insert other activities, buttons, etc. If not too much trouble and/or time consuming that is. 回答1: Its easy enough if you follow a few rules. Here's an example of a NativeActivity that has a child: [Designer(typeof(MyActivityDesigner)), ContentProperty("Child")] public sealed class MyActivity : NativeActivity,

CLR 2.0 vs 4.0 performance?

半世苍凉 提交于 2019-12-10 07:54:13
问题 Will a .NET program compiled for CLR 2.0 run faster if running unden CLR 4.0? app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" /> <supportedRuntime version="v2.0.50727"/> </startup> </configuration> 回答1: Typically, no - it will be identical. By default, the CLR 4 runtime will load the CLR 2 runtime to execute your CLR 2 code base. Forcing execution under CLR 4 requires setting

Forms Authentication adding additional information along with ReturnUrl

守給你的承諾、 提交于 2019-12-10 07:47:08
问题 With Forms Authentication when the app needs to redirect to sign-in page is there an event or any extensibility point that will let me do additional work to the request before it redirects to the sign-in page? I would like to send additional information in the query string that could vary such that it wouldn't work to just statically embed that in the link in the loginUrl node in the web.config. Edit: For clarification, I want to intercept the request prior to being redirected TO the login

ClickOnce manifest

大城市里の小女人 提交于 2019-12-10 06:31:40
问题 We are currently deploying a WPF 4 application via ClickOnce and there is a scenario when the installation fails. If the user does not have .NET 4.0 Full install and attempts to install our application the framework installs fine, but the application fails to install. If we re-run the installation again the application installs fine. Here is a copy of the log: PLATFORM VERSION INFO Windows : 6.1.7600.0 (Win32NT) Common Language Runtime : 2.0.50727.4927 System.Deployment.dll : 2.0.50727.4927