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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

What are the situations where a WcfClient is not generated by Add Reference

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :WCF

I have a simple service published to my local machine.  I create a new project and create a Service Reference to the service.

It is basicHttp service, on port 8580, and exposes several methods.  Written using 4.0 framework, VS2010, basic database front end stuff.

I just get data I don't get the client when I create reference to it.   What is the cause of this?  If I create reference within the project it creates a false illusion that my service is fine because I get the client!!!???? 

I also ran the service through SVCUTIL to see what gets generated.  All I get are data objects I do not get the client and I do not get those objects returned by the service.

View Complete Post

More Related Resource Links

Serializing / Storing VS2010 generated WCF Proxy Class reference in SQL SessionState



I have a WCF 4 service being consumed by an ASP.NET 3.5 (SharePoint 2010 actually) application.

Because we have implemented session support in the WCF service (ws2007HttpBinding) to maintain some objects that are very expensive to intialize, I'm also trying to keep my service client reference persisted on the ASP.NET consumer-side. However in order to persist it across post-backs, I need to add it to the session (using SharePoint's SQL SessionState provider), and this causes serialization (binary serialization) of the WCF service referece.

The ASP.NET application is throwing an error, because it cannot serialize the WCF service reference.

Any thoughts?

Reference to a non-shared member requires an object reference in code generated by ASP.NET



I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:

<%@ Page Language="VB" AutoEventWireup="true" CodeBehind="diff.view.aspx.vb"  Inherits="MR.ControlApp.diffview" MasterPageFile="~/Site1.Master"%>

<asp:Content ID="Header1" ContentPlaceHolderID="head" runat="server">

    Page: <select onchange="sel(this);">
        Dim j As Integer = 0
        While j < pageCount
           <option <%= IIf(currentPage = ( j + 1 ), "selected", "")  %> value="<%= j+1 %>"><%= j + 1 %></option>
        <%j = j + 1
        End While
    <% 'Print(); %>
    <div style="font-family: verdana; font-size: 10pt; font-weight: bold">
        MDM Data Inconsiste

Modify reference to ItemsSource Ilist collection to ItemsSource collection generated from XMLDataPro


Hello, I am trying to modify a code where the content generated with ObservableCollection to collection generated with XMLDataprovider. I am able to generate the content with XMLDataProvider successfully. The problem I am trying to solve now is to modify the code where it is referenced to the content generated from ObservableCollection. Any time I run the method below, my application is getting frozen. It looks like IList is not appropriate reference to XML collection. What should be used instead?

The sample I have works with ObservableCollection, I need to genenerate content with XMLDataProvider. The method above is the portion of the code from drag and drop sample found here: bea.stollnitz.com/blog/?p=53. Please let me know if I answered to your question

Thank you in advance.

public static void InsertItemInItemsControl(ItemsControl itemsControl, object itemToInsert, int insertionIndex) 
    if (itemToInsert != null) 
      IEnumerable itemsSource = itemsControl.ItemsSource; 
      if (itemsSource == null) 
        itemsControl.Items.Insert(insertionIndex, itemToInsert); 
      // It looks like IList is not appropriate reference to XML collection     
      else if (itemsSource is IList) 

A better way to reference your wizard steps using named steps

Note: this article uses the plain vanilla but the concepts apply equally well to its popular counterpart .

By far the most common way that I see wizard steps reference in code snippets is by their index.

Compiler-generated scopes for local variable declarations

I was tasked with understanding and fixing a bug on error reporting with foreach iteration variables the other day, and it got me thinking about local variable scoping rules in C# in general. First, the bug.

reference from menubuttons to text parts in article on the same page


Hi, I'm searching now for hours but couldn't find it.Cry

In my menu i have several buttons which (by a <a href..) should go the a part of an article that is in the same form.

Menu button : What is a database should go to the page default.aspx and in there is an article published.
A part of this article is having a piece of text about "what is a database"

Menu button: how to make a query should go to this same article in the same page but then to the part that is have the piece about the query. The next could be an example of what i'm doing:

    <li><a href="default.aspx ?????>what is a database</a></li>
    <li><a href="default.aspx ?????>what is a query</a></li>

Where my question marks are, there should be a connection to that particular piece of text.
In each article part there is an ID="text1" and the second part id="text2"

How shoudl i do that, Should i use a question mark.
Please give me some guidance how to structure the <li> statement or a pointer where I can read about it.


Reference HttpApplication from a separate HttpApplication


I want to create a website that can monitor the status of other websites running on the same server. Is this possible? How do I get a reference to a site's HttpApplication context from a separate HttpApplication?

Registering controls of current assembly object reference NOT set error


Hi There,

I have created a simple ASP.net Web Application (2.0) and have added a web user control.

Now in my page I have added this control but I have registered like this,

<%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

Which means I want to access all the controls in my current Web Application project

Then I have added my user control like this,

<Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

Note that My Control has,

1) Public property PublicProperty as String

2) 1 Label control

In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).

I don't want to register my control using Src, TagPrefix etc. Any ideas?


Charset Problem with dynamically generated Word Document


in my asp.net web application i am dynamically generating a word documnet out of a sql data. I have set the char set UTF-8 during the doument creation in code but still when i open the generated document and check it char set .. it is always windows-1252 not the one that i have set. My sql data in the document have special characters whihc can only be understandable using the UTF-8 charset otherwise its always ?T written in place of an apostrophy . Pasting my code here..

         HttpContext.Current.Response.ContentType = "application/msword";
         HttpContext.Current.Response.ContentEncoding = System.Text.UnicodeEncoding.UTF8;
         HttpContext.Current.Response.Charset = "utf-8";
         string strFileName = "Details" + ".doc";
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
        StringBuilder strHTMLContent = new StringBuilder();
        string strMessage = " ";
        DataView abstractview = (DataView)dsAbstract.Select(DataSourceSelectArguments.Empty);
        foreach (DataRowView row1 in abstractview)
            strMessage += "<table border='1' cellspacing='0' cellpadding='5' width

Page.FindControl Causing Null Reference Exception


Hi guys,

I developed a page in VWD 2008 and it works perfectly locally, but when I deployed it on the server every Page.FindControl() call is causing the NullReference Exception "Object reference not set to an instance of an object. " Can anyone help me out? Code is below


Mike Marshall

            For i As Integer = 1 To 10
                If (CType(Page.FindControl("last_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("first_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("dob_" & i), TextBox).Text.Length > 0) Then
                    Dim person_entry(7) As String
                    person_entry(0) = info_list.Count - 1
                    person_entry(1) = CType(Page.FindControl("last_" & i), TextBox).Text
                    person_entry(2) = CType(Page.FindControl("first_" & i), TextBox).Text
                    person_entry(3) = CType(Page.FindControl("dob_" & i), TextBox).Text
                    person_entry(4) = CType(Page.FindControl("appear_" & i), TextBox).Text
                    person_entry(5) = CType(Page.FindControl("mental_" & i), TextBox).Text
                    person_entry(6) = CType(Page.FindControl("behave_" & i), TextB

LINQ Sorting After Goup w/ Table Reference


Having a little trouble here.  I am taking a table (Articles) and grouping all the results by the key that references another table (ArticleSectionCategories).  I then want to sort these results by the OrderBy field of the referenced table (ArticleSectionCategory.OrderBy).  This is what I am using right now but it is not working.  Any thoughts?


                var GroupedArticles = from A in DC.Articles
                                     where A.PackagesId == packageId
                                     group A by A.ArticleSectionCategoriesId into G
                                     select G.OrderBy(C => C.ArticleSectionCategory.OrderBy);


Custom tool error: Failed to generate code for the service reference 'CompanyService'. Please che


A little background because I feel I have an out of the ordinary architecture in place and don't know if this is contributing to the problem. 

We have an existing ASP.net application that is undergoing expansion.  The new functionality is all written in Silverlight 4.  As part of that expansion I gutted all the old Linq to SQL and put Entity Framework 4 into place.  To do this I created a standard .net Class Library and added my edmx files there.  Naturally, the business entities created by this cannot be used in Silverlight.  So I created a Silverlight Class Library and added all the business entities to that Silverlight Class Library as linked files.  I changed the name space to be the same.

So I have the following assembly / namespaces

Company.Project.Dal.csproj / Company.Project.Entities (.net 4 class library)

Company.Project.Entities.csproj / Company.Project.Entities (SL4 class library)

With this architecture I was able to share my business entities with my SL enabled web services, my asp.net projects, my silverlight projects.  Really it's a beautiful thing.

Once this was done I added "message" classes to Company.Project.Dal and again shared them with the other entites using linked files.  These messages are things like MyObjectRequest; they are class

FileUpload error: Object reference error


I have a FormView with a FileUpload to upload an image in a database.

I keep getting an object reference error.(view code)

I am using this same script to upload the image to the database, but when I try to update the file upload I get the error.    

string strFilePath=Server.MapPath("\\images\\"+fupdImage.FileName);

        Byte[] image=null;
        HttpPostedFile imgVid=FileUpload.PostedFile;

        image=new Byte[imgVid.ContentLength];//Object reference not set to an instance of an object.

        if(FileUpload.HasFile) {
        string imageFile=FileUpload.PostedFile.FileName;
        int index=imageFile.LastIndexOf(".");
        string fileFormat=imageFile.Substring(index+1);


How to reference a listbox from a procedure


I have a listbox that gets loaded from a couple of different places on my web form.

I would like to put the code to load the listbox in one place, rather than have two copies of it.

The problem is, I can't figure out how to reference the listbox control successfully from within a procedure.

Would anyone know how to do this?

My code looks like this:

private static bool LoadSubscriptionListBox(System.Web.UI.Page Page)
        bool bReturn = false;

        // Clear the listbox

        // Load the listbox



Generated controls - skipping focus event - C# + JS


Ok, here is my senario.

A random (6-15) amount of textboxes are generated. Each textbox represents only one character. From those textboxes, three of them (at a random position) are enabled and the rest disabled.


When I put a character in any enabled textbox, it must put the focus on the next enabled textbox.


Textbox IDs go from 'char0' to 'char15' OR 'char0' to 'char12' OR ...

All the textboxes are generated so I can't set up specific focus events for each textbox because the designated control is unknown at design time.

Here is my attempt:


<script type="text/javascript">
    function abc(nextfocus)


for (int i = 0; i < focusableControls.Length-1; i++)
focusableControls[i].ClientSideEvents.KeyDown = "abc(" + focusableControls[i + 1].ID + ")";


focusableControls is an array with all the textboxes in that can get focus. It is also in the right order.

Things I want to find out:

How will I send the textbox out of focus

Errors when interacting with WorkFlow generated tasks through ISA Server


I have a MOSs environment that I have published through ISA Server 2006 and i am getting really strange behavior whentrying to interact with WorkLFow generated tasks when I have connected through ISA. This also seems to affect InfoPath Forms Services. I was wondering if anyone out there is seeing any problems when using ISA Server to interact wih Forms or WorkFlows?


The error I get simply states:

the form cannot be submitted to the web server either because your computer is offline or because the host server is currently unavailable.


Any help would be appreciated.





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