.net-4.0

Comparing IDataObject from the Clipboard

霸气de小男生 提交于 2019-12-11 03:38:33
问题 My WPF application checks the data on the clipboard to see if it can work with the data or not. Because I set some buttons to be enabled/disabled based on the data (via an ICommand implementation), this code is called frequently. The work to determine if my application can work with the data can be non-trivial at times, and thus is causing my application to "hang" randomly. I don't believe I can push this work off to another thread since the WPF runtime is expecting a response quickly. In

C# dynamic support?

不羁的心 提交于 2019-12-11 03:35:40
问题 After reading this post and links I still have 2 questions Question #1 What is the criteria so that I would be able to execute dynamic code in c# ? must the target classes/objects rely on .net clr ? I mean if someone gives me a Pascal DLL , I guess I won't be able to use its code via dynamic ( or will ? )..so: What are the requirements for dynamic to work ? Question #2 For example : In script object - in order to increase an int the code should be : Scriptobj.SetProperty("Count", ((int

How to avoid cascading error messages

天大地大妈咪最大 提交于 2019-12-11 03:34:46
问题 I'm trying to design an application error handler that resolves any unhandled exceptions, but there are some cases of undesired behaviour that I can't seem to get around. Application_DispatcherUnhandledException will get called whenever a thread outside of the UI runs into trouble. This will in turn call App.HandleError - a static method which will log the issue, display a message to the user, and if something critical is wrong, initiate a shut down of the application. My main issue seems to

Why does IEnumerable<T> only have the “out” covariant flag and not “in” c#?

拜拜、爱过 提交于 2019-12-11 03:29:49
问题 I was wondering , why does IEnumerable<T> has ONLY the out and not the in contravariant flag ? public interface IEnumerable<out T> I can understand the out by this example : IEnumerable<string> strings = new List<string>(){"a","b","c"}; IEnumerable<object> objects = strings; object is bigger than string , so the compiler afraid that well do something like: objects = objects.First().Select(x=>5);// ( we cant insert int to string...) fine and understood. but what about if i want to use the

WCF Generic Class

痞子三分冷 提交于 2019-12-11 03:29:37
问题 How can this work as a WCF Service? public class BusinessObject<T> where T : IEntity { public T Entity { get; set; } public BusinessObject(T entity) { this.Entity = entity; } } public interface IEntity { } public class Student : IEntity { public int StudentID { get; set; } public string Name { get; set; } } I want to expose the BusinessObject <T> class and the all the class that inherits the IEntity interface in the WCF Service. My code is in C#, .NET Framework 4.0, build in Visual Studio

Recursively listing of files and folders in C# [closed]

≡放荡痞女 提交于 2019-12-11 03:26:30
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I wrote this code to recursively list files and folders in c#. var filesInTheCurrentDirectory = System.IO.Directory.GetFiles(rootFolder); if (!filesInTheCurrentDirectory.Any() && !System.IO.Directory.GetDirectories(rootFolder).ToList().Any()) { return; }

Converting a BGR bitmap to RGB

末鹿安然 提交于 2019-12-11 03:23:47
问题 I am getting bitmaps from a buffer from a net cam. When I assign these to a PictureBox the red and blue are reversed. What can I do to the bitmap or to the PictureBox to get the red and blue in their proper places? 回答1: The following code does the needed conversion: public static void RGBtoBGR(Bitmap bmp) { BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); int length = Math.Abs(data.Stride) * bmp.Height; unsafe { byte*

How to Cache Real-time Data?

女生的网名这么多〃 提交于 2019-12-11 03:23:08
问题 I'm working on a windows forms application (.NET 4.0). My form contains a 'Fast Line' chart using the Microsoft chart control included in VS2010. The chart gets filled with about 20,000 datapoints. My application then starts receiving market data from a server via DDE (Dynamic Data Exchange) in real-time and adds it the chart. Note: I have no control over the server and so I have to deal with DDE only even though it's an outdated technology. VS doesn't support DDE anymore and so I use the

Creating different GUID for same lowercase and upper case strings

。_饼干妹妹 提交于 2019-12-11 03:15:20
问题 When I try to create GUIDs like this Guid guid1 = Guid.Parse("aaaaaaaa-bbbb-cccc-eeee-ffffffffffff"); Guid guid2 = Guid.Parse("AAAAAAAA-BBBB-CCCC-EEEE-FFFFFFFFFFFF"); Both are creating same GUID object. Is it possible to create unique GUIDs for lower case and upper case version of same string? Any ideas are welcome. 回答1: GUIDs are actually bytes parsed from hexadecimal. That is not possible. You should not use GUIDs to store arbitrary data. 回答2: Your strings are hexadecimal representations of

Discussion - Client Server Application architecture

为君一笑 提交于 2019-12-11 03:11:43
问题 I want to develop a client-server based desktop application using .Net 4, C# and SQL Server. Please refer to the image for what i am thinking about. There will be a server application accessing windows service or web service. The client application will have Multiple Document Interface. Below are my points that what i am thinking about - The client application will use socket connectivity with server application so as to get authenticated from server, and also to track record of client