.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

how to find the nearest element in a sorted set?

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :.NET Framework
.NET provides a lot of functionality for sorted collections, in particular the generic classes: SortedSet<T> SortedList<Tk key, Tv Value>,  SortedDictionary<Tk key, Tv Value>,  A common task when dealing with sorted sets, is to find the closest key in the sorted collection to a given key (above or below) E.g. SortedSet<int> ss = new SortedSet<int>() {1,3,5,7} int i = 4 is there a function that tells me that i=4 is between the second and the third element of the set ss? something like ss.FindHighestBelow(i) or ss.FindLowestAbove(i) Similarly with SortedList and SortedDictionary (find the closest key to a given one, above or below...) Clearly one could implement explicitly, but given the generic nature of the task and the large amount of functionality already in .NET, I suspect it is already there, somehow... thank you in advance, alberto

View Complete Post

More Related Resource Links

Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap



I created 2 projects in my solution:

  1. Classic asp.net web service (asmx)
  2. Class library project which references service
  3. web site project which references class library project
  4. Windows app project which references service.

Both projects were created in 3.5 framework and in Visual Studio 2008 Beta 2.

I added web service reference to Class library project. When it asked for namespace I typed "CurrencyProxy". Projects build ok, but when I run web app, Class library throws an error: Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I believe it has something to do with app.config in Class library project. Here is part from app.config:

<binding name="CurrencyServiceSoap" closeTimeout=

Help: Could not find schema information for the element 'microsoft.web.services2'

(Sorry I may have posted this in a wrong forum earlier) Hi, I've got this problem, trying to add a simple user authentication feature to my web service. I added the code directly copy-paste from MSDN as well as trying load of other ideas why this might happen... I've been getting these "information messages" that practically disables my client application from connecting to the web service. (I'm developing this on my PC, visual web developer 2005) Adding the microsoft.web.services2 section results in: Could not find schema information for the element 'microsoft.web.services2' Could not find schema information for the element 'security' Could not find schema information for the element 'securityTokenManager' Could not find schema information for the element 'type' Could not find schema information for the element 'qname' HELP PLEASE!!! web.config (relevant parts only, I cut out system.web and other sections): <?xml version="1.0"?> <configuration> <configSections> <section name = "microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </configSections> <microsoft.web.services2> <security> <securityTokenManager type="ServiceNameSpace.User,ServiceNameSpace" xmlns:wsse="ServiceNameSpace"

Encountered "Could not find schema information for the element 'microsoft.web.services3'"

Hi  , I have tried to close my web.config and reopen in VS2005 to re-compile but I still encountered this error :Could not find schema information for the element 'microsoft.web.services3' . I have added in the configSection and any reference for the web.service3. Appreciate anyone who can assist me.  Below are my parts of my web.config : <configSections> <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </configSections> <webServices> <soapExtensionImporterTypes> <add type="Microsoft.Web.Services3.Description.WseExtensionImporter, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </soapExtensionImporterTypes> <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </webServices> </system.web> <microsoft.web.services3> <security> <securityTokenManager> <add type="Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35&qu

Could not find default endpoint element that references contract


There are so many questions floating around here on this topic and here is one more. I am consuming a customer's webservice through a class library and this class is referenced from a web application. When I save a form on the web page, it will call the class which will consume this webservice and send data across. But I am getting the error when I save the form. I have a feeling that their service is on https instead of http.

Could not find default endpoint element that references contract 'xxx.InboundServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.  

<?xml version="1.0" encoding="utf-8" ?>





                <binding name="InboundServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"

                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCo

External Content Type - Read List Operation - "Cannot find a collection element of a supported type.


I'm trying to define External Content Type Operations for an External Content Type. I can add a Connection, Type "WCF Service" no problem. And I can define a "New Read Item Operation" using that connection.

But I can't define a "Read List Operation". I get the following error message, in the Return Parameter Configuration: "Cannot find a collection element of a supported type..." it goes on to say - see the help documentation for supported types. I can't find any help documentation on this.

I've tried returning different types in the provider web service but keep getting the same error. What are the supported types the web service can return?

The reading I've done suggests that you can connect to a non-MS web service using a connection type of "WCF Service". Is this correct? If it is what's the best soap format the web service provider should use - Doc/Literal?



Could not find default endpoint element that references contract IService1 in the ServiceModel clien



I am getting the above error. When I try to generate the proxy using svcutil, I get an error  as:

"There was an error importing a wsdl:binding that the wsdl:port is dependent on"..

But the proxy .cs file is generated.

The host is running perfectly and I can view the wsdl.

Can someone help me out with this ?

Also is there any example available somewhere that I can use. I tried using MSDN Virtual lab example but I am getting the same error with it too.



Akhil Jindal

ConfirmButtonExtender and ModalPopupExtender Server Control with Master Page Failed to find element


I am in the process of building a server control that contains a ConfirmButtonExtender. This is my code:

The Master Page:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="CBC_MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <asp:ContentPlaceHolder id="head" runat="server">
    <form id="form1" runat="server">
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

Could not find endpoint element with name...


Okay so here's the setup:

I have 4 projects in my solutions thus far: Types, Repositories, Services, Web.

The Services project only contains the implementation of the WCF service, the contracts sit in the Types library.  Also (don't know if it makes a difference), the WCF project is a WCF Servic Library project and not a WCF Service Application project.

In the web project, I'm trying to create a ChannelFactory to use with my WCF Service.  It looks like this:

Call to method:

var reviewService = GenericFactory<IReviewService>.GetChannelFactory("ReviewService");


public static T GetChannelFactory(string endpoint)
            return new ChannelFactory<T>(endpoint).CreateChannel();

Here's what the config looks likes:

        <!-- use base address provided by ho

"Could not find default endpoint element that references contract " @ Expression Blend @ Design Time


so, in Expression Blend, and only there, during design time i get an error:

"System.InvalidOperationException was unhandled by user code

Could not find default endpoint element that references contract 'GBAUploadService.IGBAUploadService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

this doesn't happen in Visual Studio 2010, and of course the service itself works flawlessly.

any ideas?


the code triggering the exception is part of a ObjectDataProvider, which consumes a web service in code-behind:


  public class FileGroupsDataProvider
    public BaseUploadJob[] GetFileGroups()
      if (Assembly.GetEntryAssembly() != null)
        using (GBAUploadServiceClient gbaUploadServiceClient = new GBAUploadServiceClient())
          BaseUploadJob[] baseUploadJobs = gbaUploadServiceClient.GetFileGroups();
          return baseUploadJobs;
      return null;

How to write the Web service in asp.net for Windows mobile application which find the nearest Restu


hi , i am developing the window mobile application in Asp.net, which will find the nearest Restaurant map on window mobile, but i am new to asp.net ,

  how to write the web service  in which i send my location address and  through window mobile and the web serivce find the neareset Restaurant map on window mobile ,

can this is possible ?

please help me

i dont know how to write the web service for this problem ,


please help me


many thanks in advacne


Find the nearest date before Saturday, Sunday and holidays with Linq


 var tecaji = (from xml in doc.Descendants(slazhnmaespace + "tecajnica")
                      where xml.Attribute("datum").Value == "2010-10-158"
                      select xml).Elements().Where(a => a.Attribute("oznaka").Value.Equals("TRY")).Select(n => n.Value).SingleOrDefault();

I have dates that are not in the XML file, but value still has to show.

In the table there is no value for the date of 23.10.2010, 24.20.2010. How do you show value for the date 10/22/2010?

Finding the appropriate date, which is najbluzjemu to that in the table.

In this XML table is not displayed dates (Saturday - Sunday).

Therefore, to find the nearest date before Saturday and Sunday.

If it is Saturday, the date "02.10.2010" shall be the date of "01/10/2010.

How do I get to that solution?


How to find the xy coordinate of an element in a pixel array ?


Lets say that we copy the pixels of an image to an array as follows:


//Copy the pixels to the array
ImgSource.CopyPixels(PixelData, Stride, 0);


Now we have the image as a one dimensional array in PixelData. Is there a way to find out the (x,y) coordinate of each element in this array ?

I need this in order to determine which points in the array are within a specific x,y region.



$("#id", context) does not find element in the site



I have a form element which submits some data to a server. The server responds with a new version of a page.

I added jquery code to hijack the form: validate it (using jquery validate) and if correct send post request. The success function then should find one div and one span elements (they have id's set ("board" and "calcSpan")) in the returned html-page and replace the old one's with the received elements.

For some reason it finds only the second div, the result of the search for the first div is jquery-object containing no html.

Here is the javascript-code:

$(function() {
        submitHandler: function (form) {
            if ($(form).find("input").attr("name") == "numberOfHands")
            return false;
        focusInvalid: false,
        focusCleanup: true,
        rules: {
            numberOfHands: {
                required: true,
                number: true,
                min: 2,
                max: 4
        messages: {
            numberOfHands: "??????! ????????? ???????? ?? 2 ?? 4-? ???????"

How to Find First Element?



I would like to get rid of the root element of my sample xml.<NewDataSet> element is NOT needed to I would like to remove it in my code.Actually I m trying to send this XML via web service.

The below code works for console application BUT not for web project. How can I fix this?


I tried this way but did not succeded!


Thanks in advance.

Best Regards.

Sample XML:

  <Descriptions Draw="698" Revision="22">
    <Event ID="463" Description="">


Round off time to the nearest minute

How would you round this up to the nearest minute? There isn't a built in function to do this so you have to use a little bit of maths to get there. There are 60 seconds in a minute. We already have 38 seconds on the clock. So we need to add on 60 - 38 = 22 more seconds.

UpdatePanel is not a known element - message when upgrading to 1.0 ajax


It worked on one of my old pages.  I change the web.config, renamed all the <asp.

On some aspx page it doesn't recognize the updatepanel.  It only does on one page.  If I create a new aspx page with a different name - then it works.

Should I just create a new web project ajax - then copy all my code into there?  Or is there a way to get those old pages to recognize the new ajax controls?

find a Control inside a GridView using jQuery


I have databound GridView in my page and I have a hidden DIV in all rows. Each row contains a Button that I want it to make the DIV visible for me! how can I use that with jQuery?!

here is the code page: 

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                                EnableModelValidation="True" GridLines="None" ShowHeader="False" Width="100%">
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend