.net-2.0

WCF consumed as WebService adds a boolean parameter?

别说谁变了你拦得住时间么 提交于 2019-12-04 01:54:50
I've created the default WCF Service in VS2008. It's called "Service1" public class Service1 : IService1 { public string GetData( int value ) { return string.Format("You entered: {0}", value); } public CompositeType GetDataUsingDataContract( CompositeType composite ) { if ( composite.BoolValue ) { composite.StringValue += "Suffix"; } return composite; } } It works fine, the interface is IService1: [ServiceContract] public interface IService1 { [OperationContract] string GetData( int value ); [OperationContract] CompositeType GetDataUsingDataContract( CompositeType composite ); // TODO: Add

Unique List<T> in .NET 2

血红的双手。 提交于 2019-12-04 01:38:20
What is a preferably generic; unique (IComparable/IEquitable) valued collection of objects for .NET 2 ? ( à la List<T> , or an equivalent of HashSet<T> from .NET 3.5, but without ordered items) Unfortunately, the first good framework class for this is the HashSet , which you will only get access to with .Net 3.5. If you are stuck in previous versions., the options are not as nice. The most common is to usea Dictionary type where the Key is the value that you are trying to store. You can wrap this in your own class fairly easily. If you are willing to go outside the framework all together,

Getting a path of a running process by name

允我心安 提交于 2019-12-04 01:17:36
问题 How can I get a path of a running process by name? For example, I know there is a process named "notepad" running, and I want to get the path of it. How to get the path without looping through all other processes? Not this way! using System.Diagnostics; foreach (Process PPath in Process.GetProcesses()) { if (PPath.ProcessName.ToString() == "notepad") { string fullpath = PPath.MainModule.FileName; Console.WriteLine(fullpath); } } 回答1: Try something like this method, which uses the

Is there a way to make Strongly Typed Resource files public (as opposed to internal)?

China☆狼群 提交于 2019-12-03 23:51:11
问题 Here's what I'd like to do: I want to create a library project that contains my Resource files (ie, UI Labels and whatnot). I'd like to then use the resource library both in my UI and in my Tests. (Ie, basically have a common place for my resources that I reference from multiple projects.) Unfortunately, because the StronglyTypedResourceBuilder (the .Net class which generates the code for Resources) makes resource files internal by default, I can't reference my strongly typed resources in the

Visual Studio 2012 Test Project Mixed Mode Runtime

拥有回忆 提交于 2019-12-03 23:31:08
I'm currently working in the Visual Studio 2012 RC with a test project. I have included the following assemblies: Microsoft.SqlServer.Smo Microsoft.SqlServer.SmoExtend Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Management.Sdk.Sfc These assemblies are build in version 2.0.50727 and I have a test project in .NET 4.0. So based on this information I have added an app.config file into the project with the following lines: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> <

.net construct for while loop with timeout

纵然是瞬间 提交于 2019-12-03 22:29:06
I commonly employ a while loop that continues to try some operation until either the operation succeeds or a timeout has elapsed: bool success = false int elapsed = 0 while( ( !success ) && ( elapsed < 10000 ) ) { Thread.sleep( 1000 ); elapsed += 1000; success = ... some operation ... } I know there a couple of way to implement this, but the basic point is that I repeatedly try some operation with a sleep until success or I've slept too long in aggregate. Is there a built-in .net class/method/etc to save me from re-writing this pattern all over the place? Perhaps input is an Func(of bool) and

Comparing two generic lists on a specific property

不羁岁月 提交于 2019-12-03 21:52:47
I'm using VB.NET with .NET 2.0. I have two lists, and I want to compare the lists on a specific property in the object, not the object as a whole, and create a new list that contains objects that are in one list, but not the other. myList1.Add(New Customer(1,"John","Doe") myList1.Add(New Customer(2,"Jane","Doe") myList2.Add(New Customer(1,"","") Result in the above example would contain one customer, Jane Doe , because the identifier 2 wasn't in the second list. How can you compare these two List<T> or any IEnumerable<T> in .NET 2.0 (lacking LINQ)? Here's the C# version, VB coming up shortly..

The right data structure to use for an Excel clone

天大地大妈咪最大 提交于 2019-12-03 21:08:46
Let say I'm working on an Excel clone in C#. My grid is represented as follows: private struct CellValue { private int column; private int row; private string text; } private List<CellValue> cellValues = new List<CellValue>(); Each time user add a text, I just package it as CellValue and add it into cellValues. Given a CellValue type, I can determine its row and column in O(1) time, which is great. However, given a column and a row, I need to loop through the entire cellValues to find which text is in that column and row, which is terribly slow. Also, given a text, I too need to loop through

How to deal with this C# hang invloving SystemEvents.OnUserPreferenceChanged

折月煮酒 提交于 2019-12-03 20:51:09
My WinForm application having a hang problem. What happen is that client sometime leave the application running overnight and when they comeback in morning application is typically in a hang state. This is what I see in dump file on the main thread. What I don't understand is what could make SystemEvents.OnUserPreferenceChanged event to be invoked, although I don't think I am doing anything that is invoking this event. 0024e480 770496f4 System.Threading.WaitHandle.WaitOneNative(Microsoft.Win32.SafeHandles.SafeWaitHandle, UInt32, Boolean, Boolean) 0024e52c 702c68af System.Threading.WaitHandle

Separate threads in a web service after it's completed

萝らか妹 提交于 2019-12-03 20:38:32
If this has been asked before my apologies, and this is .NET 2.0 ASMX Web services, again my apologies =D A .NET Application that only exposes web services. Roughly 10 million messages per day load balanced between multiple IIS Servers. Each incoming messages is XML, and an outgoing message is XML. (XMLElement) (we have beefy servers that run on steroids). I have a SLA that all messages are processed in under X Seconds. One function, Linking Methods, in the process is now taking 10-20 seconds, it is required for every transaction, however is not critical that it happens before the web service