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

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

Hashtable as parameter to a method

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :.NET Framework

I ma using vb.net 3.5

I make  a function that accept a Hashtable as parameter. 

when I call that function with a Hash table, that hash table showing nothing in that function.

what is the reason for that ?

how to solve this.


Arindam Banerjee

View Complete Post

More Related Resource Links

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Why request parameter added to client side code in each method while using svcutil.exe

Hi, I am using WCF services in my project and want to call WCF methods asynchronously. I am hosting WCF service programmatically in windows app as follows svc = New ServiceHost(GetType(Service1), New Uri("net.tcp://localhost:8806/")) Dim svcMDB As New ServiceMetadataBehavior svc.Description.Behaviors.Add(svcMDB) svc.AddServiceEndpoint(GetType(Service1), New NetTcpBinding(), "MyBusiness/MyBusinessService/") svc.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "MyBusiness/MyBusinessService/mex") svc.Open() Me.Text = "Service started...." and I am generating client side proxy using svcutil.exe as follows. svcutil /n:net.tcp://localhost:8806/MyBusiness/MyBusinessService,MyService net.tcp://localhost:8806/MyBusiness/MyBusinessService/mex /a /language:vb   The result of this command is as :   Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152] Copyright (c) Microsoft Corporation.  All rights reserved.   Attempting to download metadata from 'net.tcp://localhost:8806/MyBusiness/MyBusi nessService/mex' using WS-Metadata Exchange. This URL does not support DISCO. Generating files... D:\Prabodh\New C2k\Test Projects\DataTableToArray\MyHost\bin\Debug\MyBusinessSer vice.vb D:

Parameter names ending with "specified" added to web service method call

Hello,I am new to WCF. I created a wcf web service and the generated web method exposed by wcf has some additional boolean parameters with names that end with "Specified".I am trying to understand why are these additional parameters necessary and how to get rid of them. Thanks!David

Input Parameter in Finder Method BDC Model

Hi Guys, I know it is possible to create a Finder method with an input parameter, but I am trying to figure out how to pass the parameter to the method. Here's my isssue:   I have created a BDC Model in VS2010, my finder needs to have an input parameter. This input parameter is available on a list that is already available on my site. What are my options to pass this parameter to my finder method and display the results?   My intention (not sure if it makes sense) is to create and action for the model of the list that is already available, so I can capture the variable and pass it in a query string to  a list that I create for the Finder method that requires an input parameter. The problem is I dont know how to do this or even if it the best way to go about solving the problem. Using a business data list and business data related list while possible is really not an option.   Thanks  

passing messageContract object to a WCF Service method using Soap - not as a method parameter

i want a web application to create a service reference to my WCF service, insert information to the header of the soap call and call my WCF method. my WCF supports soap operations (also there is an endpoint in the config). i read about MessageContract attribute and declared one in the interface file: [ServiceContract] public interface IBasicService { [OperationContract] [WebGet(UriTemplate = "GetData?value={value}")] // Add support for HTTP GET Requests string GetData(int value); } [MessageContract] public class BasicServiceHeader { [MessageHeader] public string myString; } the implementation of the contract : public class BasicService : IBasicService { public string GetData(int value) { return string.Format("You entered: {0}", value); } } i don't want the BasicServiceHeader to be passed as a parameter of GetData function , i want to keep the function signature as it is (without a BasicServiceHeader parameter) and to extract the BasicServiceHeader inside the function, (just like using soapHeader) can i do that ?

References parameter in $create() method



Could someone please explain what exactly the references parameter of the $create() method does? my understading from reading the docs is you can pass in a reference to an already created (javascript ?)object that can then be referenced by the object being created. Is this correct? If so, how do I reference the objects passed in using this parameter in the class in question.

This page http://www.asp.net/ajax/documentation/live/clientreference/Sys/ComponentClass/ComponentCreateMethod.aspx mentions it, but does not expand on usage

Cheers Si

pass a dynamic parameter in a WCF method on HTTP GET


i have a WCF method with 2 known parameters and another one thats supposed to include a Key:Value pairs (dynamic parameter that will include an unknown number of key:value pairs).

the first question is :

i don't want to use XML as the dynamic parameter. what is the common way to pass the dynamic parameter in a WCF method? Dictionary<string,String>? json string? array of complex types? or other? ( my client - the one that uses my service, doesn't have Framework 3.5, so i suggested a framework 2.0 ways to send the parameter)

the second question :

the method  supports HTTP GET , should a dynamic parameter be passed in the URL itself or in the Header? i prefer the URL itself....


thank guys, please help ....

Get method parameter's values using reflection


By writing the following code I can get the method parameters metadata.


        void test(int x, string s)
            StackTrace st = new StackTrace(true);

            foreach (StackFrame sf in st.GetFrames())
                MethodBase mb = sf.GetMethod();
                foreach (ParameterInfo pi in mb.GetParameters())


I need the parameters value (the value that was passed to the method).

Can I get it in C#?


Thanks Gil

Read web method input parameter in UTF-8 encoding



I have a web service written in ASP.NET 2.0 using Visual Studio 2005. The web service contains a web method which takes in a string parameter:


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
    public Service()

        //Uncomment the following line if using designed components 

    public string DoProcess(string input)
        // Do some processing...
        // ....           
        return result;


The web.config file contains the <globalization> tag.


This web method will be called by a third-party client, which will be sending data in UTF-8 encoding. But during development, I created my own test client to test the web method. The client passes in the Unicode characters in UTF-8 as input to the web service method.

I discovered that if the HTTP headers in

reposted with no help: passing a string parameter to a web method


I have a web form (html) and I'm trying to pass a single string as a parameter to my web method, (this should be simple but no one can seem to answer me)

<script type="text/javascript" language="javascript">
        var qs = new Querystring();
        var v1 = qs.get("TorVName");
        //var jsonData = JSON.stringify(v1);  
        //var list = v1;
        //var jsonText = JSON.stringify({ list: list });
        $().ready(function() {
                type: "POST",
                url: "Default.aspx/GetColumns?TorVName=" + v1,
                data: {},
                contentType: "application/json; charset=utf-8",

passing values to object properties of action method parameter


I have an action method that accepts a single parm.

That parm is an object with multiple properties. MVC correctly maps values from the querystring
to properties in the parm object by matching property name to querystring value name. 
Problem is, properties in the action method parm object which are themselves objects with
properties, are not assigned their matching values from the querystring. The class object has a
constructor which accepts a single string parameter.

How do I assign to properties of an action method parameter which are themselves class objects?



                <%: Html.ActionLink("Edit", "ProductMasterEdit", 
                       new { ProdKey=item.ProductKey.Value, 
                       ProductKey = item.ProductKey.Value })%> 

    public ViewResult ProductMasterEdit(ProductMaster Item)

  public partial class ProductMaster

    public ProductKey ProductKey
      get { return new ProductKey(this.ProdKey); }
      set { this.ProdKey = value.Value; }


Write Unit Test for method with parameter


I'm trying to build my first MVC site and also write unit test for the first time.  I can't figure how to write unit test for methods that take parameters.  How do I write a test method for this controller action?

public class CustomerController : Controller

        public ActionResult Details(int id)
            var customerDetails = (from c in _entities.Customers
                                  where c.PK == id
                                  select c).FirstOrDefault();

            return View(customerDetails);


SOAP as input parameter in a web service method


I have a webservice method which needs to accept SOAP as input parameter. I've worked webservices between .NET clients but I've never worked using raw SOAP so I don't know what to do. The format of the input like this:

<?xml version="1.0" encoding="utf-8"?>
<S:Envelope xmlns:S = "http://schemas.xmlsoap.org/soap/envelope/">
    <ns2:RemoteService xmlns:ns2 = "some.ns.url">
        <param2>Asd Qwe</param2>
        <param3 xsi:nil = "true" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"/>
    </ns2:RemoteService >

How should my method input be to accept this SOAP as parameter?

I'm using ASP.NET web services not WCF.

Parameter is not valid exception on image.fromstream() method



      i have written a code for resizing the images and its working good except for some images that too the issue is occuring only on locolhost(IIS). I have asynchronous file upload contorl and two button  controls. when clicked on first button  the asynchronous file upload control is saved in session using the following code

Session["myupload"] = AsyncFileUpload1.PostedFile;

The image is resized and saved in a folder when second button clicked. The following code will execute when clicked the second button.

HttpPostedFile hif = (HttpPostedFile)Session["myupload"]                        
                        if (hif.ContentLength <= 20000000)
                            if (checkfiletype(hif.FileName))
                                string spacefileName = hif.FileName;                                
                                string storePath = Server.MapPath("~") + "/Docs";
                                //MemoryStream source = hif.InputStream;
                                Stream source = hif.InputStream;
                                //source =(MemoryStream)hif.InputStream;
                                byte[] input=new byte[hif.ContentLength

Calling a Page method with complex parameter using jason.stringfy() method

The article Calling a Page method with complex parameter using jason.stringfy() method was added by binary_fiddle on Wednesday, March 30, 2011.

Most of the time when i tried to search for executing server side static page methods using jquery I came across simple example which explained how to call page methods which took parameters of simple types like string and integer.However none of the

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Enterprize library 4.1 getting output parameter after adding record in db, plz guide



I need to get output parameter (flag) from db after saving record in database. I am using Microsoft Enterprise Library 4.1 for DB. I am inserting record using I Data reader.

Please guide


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