Often when adding custom code to SalesLogix you need to reference Assemblies that are not included by default in Code Snippets or action items. This problem will often manifest itself with an error when building like “The type or namespace name ‘Data’ does not exist in the namespace ‘System’ (are you missing an assembly reference)”
This article will show you how to add an assembly reference to your code. If you look at either a Business Rule/Event or a Code Snippet Action item, both have a Reference Assemblies property. In the code editor within Application Architect you will see comments at the top of the code that show the included referenced assemblies like so:
So how does one add a referenced assembly? Well it is fairly easy, though do to a glitch in the interface the actual process is kind of hidden. With the code page visible, open the properties window. In the drop down at the top of the property window you should see Sage.Platform.Entities.Orm.Entities.CodeSnippetHeader. If you choose this then you should see an AssembliesReference collection. This is the avenue for adding assembly references.
On some version of the Application Architect, the Sage.Platform.Entities.Orm.Entities.CodeSnippetHeader is not visible to be selected in the drop down. To get it to appear, you need to do the following:
- Click the CodeSnippet property in the properties window (should be the first one)
- Click into the Code itself.
- Click on the drop down in the properties window. You should now see the choice Sage.Platform.Entities.Orm.Entities.CodeSnippetHeader.
Once you can correctly see the property window, click the Assembly References Collection property. (There should be an ellipse to choose.)
This will open up the Assembly Reference dialog. It should show you what the default assemblies that are included in every event/snippet are.
If you click Add, you can add a new reference. You will need to enter the AssemblyName at a minimum. This should be the full file name of the assembly (i.e. System.Data.dll). If the assembly is part of the .Net global assembly cache you should not need to enter a hint path. If the assembly is not in the GAC, you will need to add the hint path which is the location the assembly is physically located so it can be accessed to validate during the build. I would recommend using the base build path’s assemblies sub folder. This requires copying your assembly into that location so it is available. See this post for some more info on where assemblies need to be to build successfully. The HintPath should be the full path, plus the full file name.
While you are defining your assembly reference you may receive errors. Just click OK. They are basically just a warning that the assmbly reference isn’t fully defined (which it won’t be until you are done defining). As long as you can build successfully after you add your reference you should be fine.