How to Create an OrderContext Object Outside a Web Application
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
In certain circumstances, you might have to use the objects in the Microsoft.CommerceServer.Runtime.Orders namespace from outside a Web application. For example, you might write a test that runs a pipeline, and run the test automatically from a console application.
The OrderContext object is the root object in the Orders System runtime. When you create a Commerce Server Web application, Commerce Server instantiates the OrderContext for you. When you want to access the Orders System runtime classes from outside a Web application, you must create the OrderContext object yourself.
To create an OrderContext object from outside a Web application
Add using directives for the following namespaces:
Create an OrderContext object by calling the Create method of the OrderContext class and passing the name of your site.
Example
The following code sample creates an OrderContext object.
using System;
using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Orders;
namespace console_pipeline
{
class Program
{
static void Main(string[] args)
{
// In the following line, replace "StarterSite"
// with the name of your site.
OrderContext orderContext = OrderContext.Create("StarterSite");
}
}
}
Compiling the Code
To run this code example, create a console application and add a reference to the Microsoft.CommerceServer.Runtime.dll assembly.
See Also
Other Resources
Working with Orders Runtime Objects Outside a Web Application