ContentSelector adContentSelector = new
CommerceContext.Current.TargetingSystem.SelectionContexts["Advertising"].GetSelector();
I do not think it will work
The whole statement (array brackets for example) indicates that
GetSelector() is a method and not a constructor.
So it must be like this.
ContentSelector adContentSelector =
CommerceContext.Current.TargetingSystem.SelectionContexts["Advertising"].GetSelector();
Most likely some of the properties are null and C# throws an error with a
helpful hint to use "new keyword to create an object".
I never worked with Commerce server but my bet would be that
CommerceContext.Current.TargetingSystem.SelectionContexts["Advertising"]
returns a null. Hence you get that exception when trying to call
GetSelector() on null.
George.
Mark Rae said:
When i run the following C# code in Asp.net page, always got error promt
in
VisualStudio:"use the new keyword to create an object instance"
using Microsoft.CommerceServer.Runtime;
..
ContentSelector adContentSelector =
CommerceContext.Current.TargetingSystem.SelectionContexts["Advertising"].GetSelector();
ContentSelector adContentSelector = new
CommerceContext.Current.TargetingSystem.SelectionContexts["Advertising"].GetSelector();