locked
Specified argument was out of the range of valid values. Parameter name : Policy is not configured in the system RRS feed

  • Question

  • Hi, my friends.

    I have a problem now, and I list the details as following.

     

    I am testing my web service. On the client side, I add web reference in a dll, after compiled, it generates a dll, for example, its name is ServiceAgent.dll, and I add a reference to this dll, then run my program it will throw out the error:

     

    Exception in WSE - "Specified argument was out of the range of valid values.Parameter name: Policy

    (Line:19)

     

    But if I remove the mid-layer ServiceAgent library project, use the external web service directly in the client project, it works fine. And do not know why!  After I searched on the internet, some friends have the same problem, they think, .Net DLL can't read the configuration file.

     

    My client side code are listed below:

    1.        public Quote RequestQuote(string symbol)

    2.        {

    3.            Quote q = null;

    4.

    5.            // Request a Quote from the external service

    6.            QuoteExt qe;

    7.            StockTraderSecureServiceWse serviceProxy = new StockTraderSecureServiceWse();

    8.

    9.            // Get the permission to the external web service

    10.           serviceProxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

    11.

    12.           // Create user name token

    13.           UsernameToken token = new UsernameToken("admin", "ADMIN", PasswordOption.SendPlainText);

    14.

    15.           // Append token to the proxy

    16.           serviceProxy.SetClientCredential<UsernameToken>(token);

    17.

    18.           // Set client side policy;

    19.           serviceProxy.SetPolicy("UsernamePolicy");               //  ********   at this place error happens.

    20.

    21.           qe = serviceProxy.RequestQuoteExt("MSFT");

    22.

    23.           // Create a local Quote object (from the StockTraderTypes namespace)

    24.           q = new Quote();

    25.

    26.           // Map the external QuoteExt object to the local Quote object

    27.           // This requires some manual work because the types do not map exactly to eachother

    28.           q.Symbol = symbol;

    29.           q.Company = qe.Company_Ext;

    30.           q.DateTime = qe.DateTime_Ext.ToString();

    31.           q.High = qe.High_Ext;

    32.           q.Low = qe.Low_Ext;

    33.           q.Open = qe.Open_Ext;

    34.           q.Last = qe.Last_Ext;

    35.           q.Previous_Close = qe.Previous_Close_Ext;

    36.           q.Change = (qe.Last_Ext - qe.Open_Ext);

    37.           q.PercentChange = q.Change / q.Last;

    38.           q.High_52_Week = qe.High_52_Week_Ext;

    39            q.Low_52_Week = qe.Low_52_Week_Ext;

    40.

    41.           return q;

    42.        }

     

     

    Any help would be gratefully appreciated.  

     

    • Edited by Leo Liu - MSFT Tuesday, January 25, 2011 5:44 AM Font-size is too small, improved.
    • Moved by Leo Liu - MSFT Wednesday, January 26, 2011 11:56 AM Off-topic (From:Visual C# Language)
    Monday, January 24, 2011 7:31 AM

Answers

All replies