Automatically importing default SalesLogix namespaces for C# code snippets
Nicolas Galler | December 8, 2009When working on web client forms you may have seen this error:
e:\inetpub\wwwroot\PhysicianLiaison\SlxClient\SmartParts\Contact\ContactDetails.ascx(678): error CS0246: The type or namespace name 'IContact' could not be found (are you missing a using directive or an assembly reference?)
For example this happens when you use an unqualified reference in a C# code snippet, such as:
var myContact = (IContact)BindingSource.Current
You can’t add a “using” statement so the work around is to qualify all references:
var myContact = (Sage.Entity.Interfaces.IContact)BindingSource.Current
To save on the typing, you can add a default import to your web.config file. Simply do a search for “<pages>” and add the following under that tag (or if you don’t see a <pages> tag at all, add it under <system.web>):
<namespaces>
<add namespace="Sage.Entity.Interfaces"/>
</namespaces>
Of course this can be used with your custom namespaces as well. If you are using extension methods to define business rules (as explained in Easy Business Rules with Extension Methods) it will let you use those too.





