.net

object -> treeview -> selected object in my object.

Ok here is my question: f.ex I have data structure something like this: String name - List<String> subNames; - List<String> subSubNames; I can easily populate tree view with the data. But how I should get vise versa stuff on this. for example: I select some subSubName in the treeview, what is the easiest way to get Name,...

Is this use of a static queue thread-safe?

The msdn documentation states that a static generic Queue is thread-safe. Does this mean that the following code is thread-safe? In other words, is there a problem when a thread Enqueues an int and another thread Dequeues an int at the same time? Do I have to lock the Enqueue and Dequeue operations for thread-safety? class Test { pu...

Linq Group By With Having

Here is my example: class test{ public DateTime dt; public double value; public int id; } i have: IEnumerable<Test> TestList; I want select rows from it, with group by id, with max(dt). my query: var q = from p in TestList group p by p.id into g select new { id = g.Key, dt = g.Max(w => w.dt) })...

replace a string within a range in C#

I have a string, myString, that is about 10000 in length. If I do myString.Replace("A","B"); It will replace all instances of A to B. How can I do that not to the entire string but only to character 5000-5500? ...

Consume Java Web Service that returns a hash table in .NET

Hi, I want to consume a web service built in Java from a .NET application. The web service returns a hash table in one of the methods and when I run soapUI against that method I can see that it works. But when I add the web service as a Service Reference in VS2008 the hash tables are converted into arrays... Could I configure the servi...

Forcing initialization of a HwndHost

In my WPF application, I host Win32 content using HwndHost. However, creating a HwndHost does not create the native window. Rather, this is done in the overridden BuildWindowCore() method which is called sometime later by WPF. My hosted content needs the window handle of the native window for its own initialization. Unfortunately, there...

Net Runtime Bug : .NET Runtime 2.0 Error - Event Id: 1000 Crashed my program. What caused this?

Hi, I have a new program which has been running 24/7 for over 2 weeks now but last night it crash/went down with no Fatal log exception in my log4net file ...the process appears to have been killed by someting .... and when I looked in the Windows Event Viewer Application log it contained an error for the programs process saying '.NET R...

What CMS: Sitecore, KEntico, EPIServer or multiple?

At this point we are developing Sitecore websites and we are gaining experience every day. This means that we know how to adjust our approach to different types of customers and that we are able to build our applications quicker every project we do. Offcourse Sitecore is not the only W-CMS around and we have looked into other W-CMS's. Wh...

alternative way to explore .net framework source code

While developing with Java in Eclipse it was very handy: you can attach sources and explore core java code just like your own. In Visual Studio I know about watching at the .net source code is possible only when debugging (and I can't say this feature works well). Are there any alternatives of exploring .net source code? ...

NHibernate: Is it possible to use stored proc when updating/deleting/inserting a class mapped on view?

Here is the preamble: I have a SQL View and mapped NHibernate C# class I only allowed to modify SQL View data through some stored procedures (Insert/Update/Delete) How to denote such logic in mapping file? Is it possible with only specific mapping or i need some supplementary code? ...

How do I open a file from multiple processes?

Hi, Hopefully more of a "What am I doing wrong?" than "How do I?" but there you go... Basically, I'm trying to get a program to behave in the following way: First instance of the program opens up on PC1, opens a file for Read/Write access and then acts as the master program, doing a bunch of work on some other files I don't want a wh...

LINQ: take a sequence of elements from a collection

Hi there, I have a collection of objects and need to take batches of 100 objects and do some work with them until there are no objects left to process. Instead of looping through each item and grabbing 100 elements then the next hundred etc is there a nicer way of doing it with linq? Many thanks ...

Is it possible to display a command window inside a windows form?

Instead of spawning a separate command window as a child window, is it possible to host a command console as a child control of a form? Example: ...

How to upload files to Amazon S3 (official SDK) that are larger than 5 MB (approx)?

I am using the latest version of the official Amazon S3 SDK (1.0.14.1) to create a backup tool. So far everything works correctly if the size of the file I'm uploading is below 5 MB, but when any of the files is above 5 MB the upload fails with the following exception: System.Net.WebException: The request was aborted: The request ...

Need to validate configuration property - must be 20 digits number

Hi, The user of my .NET application must provide 20-digit account number in the application configuration file. I am derived class from ConfigurationSection to work with custom sections. [ConfigurationProperty("RECEIVED_ACCOUNT", IsRequired = true)] public string RECEIVED_ACCOUNT { get { return (string)this["RECEIVED_ACCOUNT"]; } ...

How to restrict user for checking null for singelton instance in C#, .NET?

I don't want that end programmer can user == or != operator against my singelton class. End user can't do if( SingleInstace == null) I have overloaded != and == operator but it doesn't help. I have a scenario in which I want to dispose of the singleton instance and initialize it with different parameter. For example my singelton in...

Call method directly, or Raise event to call the method (event handler)?

I just bumped into some kind of code and got quite a bit of shock: Code snippet 1: Class ABC Private Event Event123() Private Function ParentMethod() RaiseEvent Event123() End function Private Function ChildMethod() Handles Event123 ... code here End function End class (Note the functions and eve...

== vs Equals in C#

What is the difference between the evaluation of == and Equals in C#? For Ex, if(x==x++)//Always returns true but if(x.Equals(x++))//Always returns false Edited: int x=0; int y=0; if(x.Equals(y++))// Returns True ...

Enumerable.ElementAt vs foreach

I have a dictionary which I need to keep updated with incoming data, after parsing the incoming data I have to check if there are any entries in the dictionary which are not present in the incoming data (incoming data when parsed is a list and I need to map it with the dictionary entries). To avoid multiple loops to removed the entries,...

How to configure sharepoint timer job to run multiple times a day?

How can I configure a sharepoint timer job to run multiple times a day. For example: Daily between the intervals 14:00-16:00 and 20:00-24:00 I want to do it using SharePoint object model. ...