.net-4.0

How to play SWF file in .NET 4.0 C# WinForms application?

微笑、不失礼 提交于 2019-12-11 10:35:06
问题 I have a SWF file which i want to be usable offline aswell. I have searched for how to play SWF files. But it doesn't work when i put a WebBrowser component ( it displays a save file dialog.. ). I have also seen that can use the AxShockwaveFlash COM component ( I myself used it in an application for .net 3.5 , AxShockwaveFlash doesnt show up when i browse for it in the .NET 4.0 application). cant find anything else for .NET 4.0 回答1: Actually AxShockwaveFlash works, it didnt show up because of

.net 4 - run code from string - in C# / F# / IronRuby / IronPython

感情迁移 提交于 2019-12-11 10:18:19
问题 What ways do I have in .net to run code from string? Console.WriteLine(Compile("1 + 2 * 3")); // results is 7. What other options do we have? C# - Compile the code on runtime? IronRuby / IronPython? F#? 回答1: So, the dynamic languages like IronRuby and IronPython make it very easy to do what you want. Create a script engine and execute the string. Easy as that. C#, it is possible, using the Code DOM... but it it compiles the code every time into a DLL. This is a costly behavior and can cause

Is it possible to set the request/response format in web.config?

社会主义新天地 提交于 2019-12-11 09:54:43
问题 I have quite a few endpoints on my WCF REST Service. They all have the same body style, request format and response format. [WebGet(BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = xxx)] Is there anyway to set those attributes in the web.config? 回答1: You can set the default value for the body style and for the outgoing response format (not for the request format) in the <webHttp> endpoint behavior (see below).

Monitoring Domain Connectivity Status

孤街浪徒 提交于 2019-12-11 09:46:02
问题 Is there any way to monitor the availability of a domain, when the server is unknown at runtime? NetworkChange.NetworkAvailabilityChanged , does not provide consistent results across framework versions/operating systems. I'm dealing with mobile units on a domain, that are going to consistently lose and re-acquire domain connectivity; and I need to detect in code, when this happens. I've tried Google, Bing, and MSDN and come up with nothing. 回答1: Try using p/Invoke NetWkstaUserGetInfo System

How can I create a function that attaches multiple event handlers to multiple controls?

空扰寡人 提交于 2019-12-11 09:45:01
问题 Question: How can I create a function that attaches multiple event handlers to multiple controls? Intent: I am using C# to develop a windows forms application. I want to create a function that takes a collection of controls and a collection of event handlers. This function will attach the event handlers to the controls. What would be the most elegant, and reusable way to do this. I have a pretty ugly way to do this with delegates, but it is a but it is less work for me to just throw this into

How to read audio (mp3) tags (Duration and Subtitle), when I use TagLib?

南楼画角 提交于 2019-12-11 09:34:12
问题 I am using TagLib (UltraID3Lib couldn't read every MP3 file). Maybe TagLib will do. And I couldn't find properties like Subtitle or Duration or Time? How do I find this kind of tags? Example: "Ondertitel" means Subtitle The second question is: And how can I find the tag Subtitle by using TagLib? 回答1: This way, you can get the duration: var file = TagLib.File.Create(@"xyz.mp3"); Console.WriteLine(file.Properties.Duration); 来源: https://stackoverflow.com/questions/13089205/how-to-read-audio-mp3

Binding exception with dynamic keyword in c#

耗尽温柔 提交于 2019-12-11 09:27:58
问题 I am loading my assemblies at run time and I am also using Instance Activator to get the code at the runtime. Following code will summerize what I am doing: dynamic powerTool; System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom( @"C:\Users\c_desaik\Desktop\PowerTool.exe"); Type type = assembly.GetType("PowerTool.Automation"); powerTool = Activator.CreateInstance(type); Now, as you have noticed, Powertool has been declared as dynamic because I do not want my code to fail

.NET - Multiple Timers instances mean Multiple Threads?

不问归期 提交于 2019-12-11 09:05:30
问题 I already have a windows service running with a System.Timers.Timer that do a specific work. But, I want some works to run at the same time, but in different threads. I've been told to create a different System.Timers.Timer instance. Is this correct? Is this way works running in parallel? for instance: System.Timers.Timer tmr1 = new System.Timers.Timer(); tmr1.Elapsed += new ElapsedEventHandler(DoWork1); tmr1.Interval = 5000; System.Timers.Timer tmr2 = new System.Timers.Timer(); tmr2.Elapsed

The underlying provider failed on ConnectionString

拟墨画扇 提交于 2019-12-11 08:54:50
问题 I am getting the following error trying to connect to DB2 Entity with .Net 4.0 The underlying provider failed on ConnectionString. I get it on this line within the generated code of my entity cs file public DOCUMAKRContainer() : base("name=DOCUMAKRContainer", "DOCUMAKRContainer") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } My App.config (which is created when you create entity the looks like this <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections

Unrecognized attribute 'targetFramework'. in 4.0 Site with 2.0 sub folder?

一个人想着一个人 提交于 2019-12-11 08:38:57
问题 I have recently upgraded a site to .net 4.0. I changed the app pool and almost everything is working properly. However the admin section of the site which is in an 'admin' subfolder with its own web.config is still running under 2.0 for some reason. When I left click the sub directory in IIS and check the ASP.net tab of properties it get ASP.NET version 2.0.50727. If i click 'Edit Configuration' I get this error "An error has occured attemping to read the configuration." The error message is: