.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

Passing a reference type by value and reference

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net

Can somebody explain why this happens ?

1.   If a reference type is passed by reference, the callee may change the values of the object's

     state data as well as the object it is referencing.

2.   If a reference type is passed by value, the callee may change the values of the object's state

     data but not the object it is referencing.


View Complete Post

More Related Resource Links

The type 'DataGrid' was not found. Verify that you are not missing an assembly reference and that

Hi; I'm new to WPF and I was going through the ExpenseIt tutorial on MSDN's website. The tutorial was working fine until I added DataGrid. I got the error message: "The type 'DataGrid' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."     I could not find a clear answer online of which assembly references to fix and how to fix them. Any help would be appreciated. Thanks!     Note: I'm running the following: Windows Vista 32-bit operating system Microsoft Visual Studio 2008 Version 9.0.30729.1 SP Microsoft .NET Framework Version 3.5 SP1

The type 'DropShadowEffect' was not found. Verify that you are not missing an assembly reference a

We created a grid in Expressions Blend but the DropShadowEffect caused an error for a developer who tried to build the solution and did not have Expressions Blend on his machine.  Had to replace with  <Border.BitmapEffect><DropShadowBitMapEffect ... Are there other incompatibilities between Expressions Blend and plain old Visual Studio 2008 development environs? <   UserControl   xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation   xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml   xmlns:d=http://schemas.microsoft.com/expression/blend/2008   xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006   mc:Ignorable="d"   xmlns:igRibbon=http://infragistics.com/Ribbon   x:Class="TestEditor.Ctrl_PR"   x:Name="UserControl"   MaxWidth="450"   d:DesignWidth="450" d:DesignHeight="125">     <Grid x:Name="LayoutRoot" RenderTransformOrigin="0.5,0.5" Width="450" Height="125">   <Border CornerRadius="8" BorderBrush="DarkSlateBlue" BorderThickness="0.5" HorizontalAlignment="Stretch" Grid.ColumnSpan="2">     <Border.Background>       <LinearGradientB

Passing a reference of the workflow to an activity

It there a way to pass in a reference of a workflow into an activity that the workflow is running (as an inargument)  in the Workflow designer?

Circular Reference with Complex Type


I have created a webservice that returns a complex type.  This is the xml that is returned from the webservice:

<NinjaRouteEntity xmlns="http://tempuri.org/">
  <Entity NinjaRouteID="1" xmlns="">
    <EntityCollectionReference PropertyName="PointCollectionViaNinjaRouteVector">
        <Entities />

'Object graph for type 'TYPE' contains cycles and cannot be serialized if reference tracking is d



I have datacontracts as below

  public abstract class ThisClass
    public abstract ThisClass Parent { get; set; }

  public class SomeClass: ThisClass
    public abstract ThisClass Parent { get; set; }


I tried solutions in below blogs


as well as I tried to apply ..[DataContract(IsReferece = true)]

But still i get below error message in SVC trace.

There was an error while trying to serialize parameter http://tempuri.org/:data. The InnerException message was 'Object graph for type 'SomeClass' contains cycles and cannot be serialized if reference tracking is disabled

Anybody has tried above scenario?

Please help, thanks in advance.

Regards, Nakul

using typeof for a reference type


namespace AssemblyA
    public class Product
        private int cinProductID;
        public int ProductID
            get { return cinProductID; }
            set { cinProductID = value; }

        private Array csCategoryName;
        public Array CategoryName
            get { return csCategoryName; }
            set { csCategoryName = value; }

namespace AssemblyA
    public class Categories
        private string csName;
        public string Name

Confused by passing by reference


On the client I want to instantiate an instance of an entity (that has a datacontract on the server side), send it to the server, let the server modify it in some way, and send it back. I'm talking about using standard-issue, ordinary WCF objects with DataContract/DataMember attributes.

The only way I could figure out to accomplish the above is to pass the object by reference.  Is there another way?

In researching this, I found the links below, one of which says it is not possible to pass by ref (yes I realize we are passing a copy, but it is the result I'm interested in.  Perhaps that is what the author is alluding to??).

Sorry for having to ask this but I'm confused (again).




Server code:

Can not add assembly reference and using .dll file from Visual studio 2008 and 2010 Type 'LibraryN


Hi all,

Please tell me the way to solved my problem to looking for a long time.

My System Info:

OS: Windows 7 - Ultimate - 64bit

VS: Visual Studio 2008 - Professional (and problem with my VS2010 installed)


I have a small project and build it to library .dll file with some function util.

From an other website (with diffirence solution). I added reference the .dll before to website.

In website, I declaration to using the function in library (dll file before). But I found error:  Error 1 Type 'LibraryName' is not defined.

And in VS2010 the problem is same.

But, run website on an other computer, it work normally.

Thanks and Best regards.

Service Reference: return type converted to a "ref" parameter



I created a WCF service using Message Contracts. One of the operations in the service takes in an entity (embedded in a message contract) and returns an updated version of the entity:

EWADemo.MessageContracts.CustomersService.SaveCustomersResponseMessage SaveCustomers(EWADemo.MessageContracts.CustomersService.SaveCustomersRequestMessage request);

[MessageContract(WrapperName = "SaveCustomers")]
public partial class SaveCustomersRequestMessage
 public EWADemo.DataContracts.Customers Customers

[MessageContract(WrapperName = "SaveCustomersResponse")]
public partial class SaveCustomersResponseMessage
 public EWADemo.DataContracts.Customers Customers

When I tried creating a s

Parsing string as a Button type reference in Visual c#


So basically, id like to parse the name of a string as an Button reference, and then alter the properties of that particular button with the reference being the same as the string parsed.

something like

Button b101 = new Button();





 private void boxlight(Button obj)
            obj.BackColor = Color.RED;


however explicit type casting for this conversion is not supported.



sharepoint 2010 custom webservice, visual studio 2010, unable to get reference - content type is tex


I followed the MSDN example in how to create a custom webservice that integrates with sharepoint at http://msdn.microsoft.com/en-us/library/ms464040.aspx

I'm able to successfully call the custom webservice it walks you through from internet explorer out of a sharepoint 2010 site using a URL such as http://vm-spproduction/sites/resource/_vti_bin/service.asmx

And, I'm able to successfully call the same custom webservice from internet explorer out of the same sharepoint 2010 server with the URL http://vm-spproduction/_vti_bin/service.asmx

In Visual Studio 2010 (running on the same hardware server as sharepoint 2010), I am able to bring up the same custom webservice in the add web reference using the advanced buttons of the add service reference dialog.  But, when the custom webservice is found, visual studio reports the following error:

The document at the url http://vm-spproduction/sites/resource/_vti_bin/service.asmx was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from '

JavaScript, passing reference to a form element question


I have a simple audio player that is controlled with JavaScript initiated by ASP.NET imagebuttons. When the user clicks on the "play" button the image is switched out for a different button image to make it "light up" while playing; when the player is finished the original image is put back so the button appears dark again. Originally, I was doing this by hardcoding in the client element ids for the image buttons ("ctl00_Middle_Voice1_LoginView1_StartLoad"), but that restricted where I could use the control. So, I have switched it so that in the ImageButton OnClientClick function I pass in 'this' and then refer to that control in the function to change the image source.

This works fine for the initial function called by OnClientClick (Play), but that function in turn calls a second function to determine the timing, control the progress bar, and whether or not the player is done playing yet and if so to swap back the original image. In that second function (Timing), I get a null object reference if I try to pass the element in again as an argument.

I have tried getting the id of the element and passing that instead (and then locating the element from the second function with getElementByID), but get the same error.

<eo:ProgressBar ID="ProgressBar1" runat="server" BorderColor="Black" BorderWidth="1px" IndicatorColor="Red" Hei

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.

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?


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