EDN Admin
Well-known member
The line is here where it is happening:
_dataCollection = System.Configuration.ConfigurationManager.AppSettings;
I have this code working in a prepackaged sample project from the NetSuite Developer Portal. When I try to create my own project I am getting the error message in the subject line of this post. In order to create my new project I was instructed to add a
web reference which I did. The web reference shows up in my right toolbar. Do I need to build the Web Reference somehow? Is that why the assembly can not be found?
Here is some code:
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1.com.netsuite.webservices;
using System.Data;
using System.Net;
using System.Xml.Serialization;
using System.Xml;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
/// <summary> Proxy class that abstracts the communication with the NetSuite Web
/// Services. All NetSuite operations are invoked as methods of this class.
/// </summary>
private NetSuiteService _service;
/// <value>Utility class for logging</value>
private Logger _out;
/// <value>A NameValueCollection that abstracts name/value pairs from
/// the app.config file in the Visual .NET project. This file is called
/// [AssemblyName].exe.config in the distribution</value>
private System.Collections.Specialized.NameValueCollection _dataCollection;
/// <summary> Requested page size for search
/// </summary>
private int _pageSize;
/// Set up request level preferences as a SOAP header
private Preferences _prefs;
private SearchPreferences _searchPreferences;
private String PENDING_APPROVAL_STRING = "_salesOrderPendingApproval";
private String PENDING_FULFILLMENT_STRING = "_salesOrderPendingFulfillment";
private String PRICE_CURRENCY_INTERNAL_ID = "1";
private String BASE_PRICE_LEVEL_INTERNAL_ID = "1";
private String ITEM_TYPE = "_inventoryItem";
private String TRANSACTION_TYPE = "_salesOrder";
public Program()
{
// Setting pageSize to 5 records per page
_pageSize = 5;
// Instantiate the NetSuite web services
_service = new NetSuiteService();
_service.Timeout = 1000 * 60 * 60 * 2;
_out = new Logger("info");
// Reference to config file that contains sample data. This file
// is named App.config in the Visual .NET project or, <AssemblyName>.exe.config
// in the distribution
_dataCollection = System.Configuration.ConfigurationManager.AppSettings;
// Prepare login credentials for request level login
_service.passport = prepareLoginPassport();
}
static void Main(string[] args)
{
Console.ReadKey();
}
/// <summary>
/// Demonstrates how to use the request level login on each operation with attached passport object.
/// </summary>
/// <remarks>The following field values used for the login are obtained
/// from the config file or the user is prompted:
/// <list type="bullet
/// <item>
/// <description>email</description>
/// </item>
/// <item>
/// <description>password</description>
/// </item>
/// <item>
/// <description>role</description>
/// </item>
/// <item>
/// <description>account</description>
/// </item>
/// </list>
/// </remarks>
private Passport prepareLoginPassport()
{
// Populate Passport object with all login information
Passport passport = new Passport();
RecordRef role = new RecordRef();
// Determine whether to get login information from config
// file or prompt for it
if ("true".Equals(_dataCollection["promptForLogin"]))
{
_out.writeLn("nPlease enter your login information: ");
_out.write(" E-mail: ");
passport.email = _out.readLn();
_out.write(" Password: ");
passport.password = _out.readLn();
_out.write(" Role internal ID (press enter for default role): ");
String roleEntry = (_out.readLn()).Trim();
if (roleEntry.Length > 0)
{
role.internalId = roleEntry;
passport.role = role;
}
_out.write(" Account: ");
passport.account = _out.readLn();
}
}
}
}
[/code]
<br/>
Much Thanks!
View the full article
_dataCollection = System.Configuration.ConfigurationManager.AppSettings;
I have this code working in a prepackaged sample project from the NetSuite Developer Portal. When I try to create my own project I am getting the error message in the subject line of this post. In order to create my new project I was instructed to add a
web reference which I did. The web reference shows up in my right toolbar. Do I need to build the Web Reference somehow? Is that why the assembly can not be found?
Here is some code:
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1.com.netsuite.webservices;
using System.Data;
using System.Net;
using System.Xml.Serialization;
using System.Xml;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
/// <summary> Proxy class that abstracts the communication with the NetSuite Web
/// Services. All NetSuite operations are invoked as methods of this class.
/// </summary>
private NetSuiteService _service;
/// <value>Utility class for logging</value>
private Logger _out;
/// <value>A NameValueCollection that abstracts name/value pairs from
/// the app.config file in the Visual .NET project. This file is called
/// [AssemblyName].exe.config in the distribution</value>
private System.Collections.Specialized.NameValueCollection _dataCollection;
/// <summary> Requested page size for search
/// </summary>
private int _pageSize;
/// Set up request level preferences as a SOAP header
private Preferences _prefs;
private SearchPreferences _searchPreferences;
private String PENDING_APPROVAL_STRING = "_salesOrderPendingApproval";
private String PENDING_FULFILLMENT_STRING = "_salesOrderPendingFulfillment";
private String PRICE_CURRENCY_INTERNAL_ID = "1";
private String BASE_PRICE_LEVEL_INTERNAL_ID = "1";
private String ITEM_TYPE = "_inventoryItem";
private String TRANSACTION_TYPE = "_salesOrder";
public Program()
{
// Setting pageSize to 5 records per page
_pageSize = 5;
// Instantiate the NetSuite web services
_service = new NetSuiteService();
_service.Timeout = 1000 * 60 * 60 * 2;
_out = new Logger("info");
// Reference to config file that contains sample data. This file
// is named App.config in the Visual .NET project or, <AssemblyName>.exe.config
// in the distribution
_dataCollection = System.Configuration.ConfigurationManager.AppSettings;
// Prepare login credentials for request level login
_service.passport = prepareLoginPassport();
}
static void Main(string[] args)
{
Console.ReadKey();
}
/// <summary>
/// Demonstrates how to use the request level login on each operation with attached passport object.
/// </summary>
/// <remarks>The following field values used for the login are obtained
/// from the config file or the user is prompted:
/// <list type="bullet
/// <item>
/// <description>email</description>
/// </item>
/// <item>
/// <description>password</description>
/// </item>
/// <item>
/// <description>role</description>
/// </item>
/// <item>
/// <description>account</description>
/// </item>
/// </list>
/// </remarks>
private Passport prepareLoginPassport()
{
// Populate Passport object with all login information
Passport passport = new Passport();
RecordRef role = new RecordRef();
// Determine whether to get login information from config
// file or prompt for it
if ("true".Equals(_dataCollection["promptForLogin"]))
{
_out.writeLn("nPlease enter your login information: ");
_out.write(" E-mail: ");
passport.email = _out.readLn();
_out.write(" Password: ");
passport.password = _out.readLn();
_out.write(" Role internal ID (press enter for default role): ");
String roleEntry = (_out.readLn()).Trim();
if (roleEntry.Length > 0)
{
role.internalId = roleEntry;
passport.role = role;
}
_out.write(" Account: ");
passport.account = _out.readLn();
}
}
}
}
[/code]
<br/>
Much Thanks!
View the full article