Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
The exception that is thrown when attempting to operate on a SpecificationSearch object with an invalid handle.
Namespace: Microsoft.CommerceServer.Catalog
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Class InvalidSearchHandleException _
Inherits SearchException
'Usage
Dim instance As InvalidSearchHandleException
[SerializableAttribute]
public class InvalidSearchHandleException : SearchException
[SerializableAttribute]
public ref class InvalidSearchHandleException : public SearchException
public class InvalidSearchHandleException extends SearchException
Remarks
The InvalidSearchHandleException derives from the SearchException, which is the exception that is thrown when a search fails. The InvalidSearchHandleException is thrown because you are using an invalid handle to a SpecificationSearch object.
Examples
public CatalogContext GetCatalogContext()
{
CatalogContext catalogContext = null;
CatalogServiceAgent catalogServiceAgent = null;
try
{
if (config.InitializationMode == ConnectionMode.Agent)
{//AGENT MODE
if ((config.UserName == null) || (config.UserName.Equals(
Environment.GetEnvironmentVariable("USERDOMAIN") + @"\" +
Environment.GetEnvironmentVariable("USERNAME"))))
{
// Default case when nothing is specified
// Uses the user's default credentials when anonymous is not allowed
catalogServiceAgent = new CatalogServiceAgent(config.WebServiceURL, ServiceAgent.DefaultAuthMethods);
catalogContext = CatalogContext.Create(catalogServiceAgent);
}
else if (config.UserName != null)
{
// Create custom
CredentialCache credentials = new CredentialCache();
NetworkCredential networkCredential = new NetworkCredential();
//create new uri with web service url
System.Uri uri = new System.Uri(config.WebServiceURL);
//add the user name, password, and domain to the network credential
int index = config.UserName.IndexOf(@"\");
networkCredential.UserName = config.UserName.Substring(index + 1);
networkCredential.Password = config.Password;
networkCredential.Domain = config.UserName.Substring(1, index - 1);
//add the network credential to the credential cache collection
credentials.Add(uri, "NTLM", networkCredential);
catalogServiceAgent = new CatalogServiceAgent(config.WebServiceURL, ServiceAgent.DefaultAuthMethods);
catalogServiceAgent.Credentials = credentials;
catalogContext = CatalogContext.Create(catalogServiceAgent);
}
else
throw new System.InvalidOperationException("Cannot perform this operation without initialization");
}
else
{//INPROC MODE
CatalogSiteAgent csa = new CatalogSiteAgent();
csa.AuthorizationMode = config.AuthorizationMode;
csa.AuthorizationPolicyPath = config.AzManXmlFileStore;
csa.IgnoreInventorySystem = config.IgnoreInventorySystem;
csa.SiteName = config.SiteName;
catalogContext = CatalogContext.Create(csa);
}
}
catch (Exception e)
{
Console.WriteLine("Error getting CatalogContext: " + e.Message);
throw e;
}
if (catalogContext != null)
inventoryContext = catalogContext.InventoryContext;
return catalogContext;
}
Inheritance Hierarchy
System..::.Object
System..::.Exception
Microsoft.CommerceServer..::.SearchException
Microsoft.CommerceServer.Catalog..::.InvalidSearchHandleException
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.