Generating early bound classes is often one of the first steps developers take when working on Dynamics 365 CE customizations in C#. However, the process isn’t always straightforward. Whether you're using CrmSvcUtil.exe or the XrmToolBox Early Bound Generator, you may run into issues ranging from missing references to naming collisions and build failures.
This post lists common issues and fixes that can save hours of head-scratching.
1. CrmSvcUtil: Assembly Load or Strong Name Errors
Issue:
When using a merged assembly (like with ILMerge) or registering an early-bound assembly as a plugin, you get:
The assembly is not strongly named.
Fix:
- Use sn.exe to generate a strong name key (
sn -k key.snk
) and sign your assembly inAssemblyInfo.cs
or project settings. - ILMerge with
/keyfile:key.snk
to preserve strong name. - Do not register early-bound classes directly as plugins. Instead, reference them in your actual plugin project.
2. Missing OptionSet Enum Definitions
Issue:
You might see errors like:
The type or namespace name 'Account.AccountCategoryCode' could not be found.
Fix:
- This typically happens if OptionSet enums were not generated or referenced correctly.
- Ensure you're checking the “Generate OptionSet enums” setting in the XrmToolBox tool or using the correct
/generateOptionSetEnums:true
parameter with CrmSvcUtil. - In XrmToolBox, go to Early Bound Generator > Advanced Settings and select Create One File for All Option Sets.
3. Classes Split into Multiple Files
Issue:
You end up with hundreds of .cs
files – one per entity – which clutters your project.
Fix:
- In XrmToolBox, under File Options, choose “Single file output” or “One file per type in a folder” to organize better.
- Alternatively, after generation, consolidate manually or via build scripts.
4. IntelliSense Errors After Adding Generated File
Issue:
Visual Studio throws errors like:
EntityOptionSetEnum does not contain a definition for 'GetMultiEnum'
Fix:
- This usually happens when generated files are not compiled properly or option sets and entity classes are out of sync.
- Regenerate both entity and OptionSet files together using the same metadata snapshot.
- If using partial classes or extending base entities, ensure namespaces are aligned.
5. Plugin Class Not Found After Deployment
Issue:
Plugins referencing early bound classes fail after deployment, even though they work locally.
Fix:
- Make sure the early bound DLL is deployed with your plugin assembly.
- If using ILMerge, verify that all dependencies are properly merged and signed.
- In Azure DevOps pipelines, use tasks to include the merged DLL or
.cs
files during build.
6. Missing Using Directives
Issue:
Compilation errors like:
'Account_AccountRatingCode' could not be found
Fix:
- Add the appropriate
using
directive manually (e.g.,using MyNamespace.Entities;
) - Or wrap the generated file with the correct namespace before compiling.
Bonus Tips
- Use the Early Bound Generator plugin for ease of use and GUI-based customization.
- Keep a clean backup of generated classes under version control. If Dataverse schema changes, regenerating early bound classes helps avoid surprises.
- Add these generated files to a separate project in your solution (e.g.,
MyOrg.Crm.Entities
) and reference it wherever needed.
Final Thoughts
Whether you're building plugins, console apps, or integration services, early bound classes simplify working with Dynamics 365 data models. But like any automated code generation, things can break. Keep these fixes in your toolkit to avoid common pitfalls.
Follow me for more tips on Dynamics 365, Power Platform, and DevOps workflows.