When working with EDI documents with BizTalk Server, the EDI components promote several details inside default or custom pipelines, details that we sometimes like to grab and use inside our orchestrations.
When doing exactly that, I was surprised, or not, by the following error:
Error CS0234
The type or namespace name ‘Unb21’ does not exist in the namespace ‘SandroPereira.EDI’ (are you missing an assembly reference?) SandroPereira.EDI.Orchestrations C:\Users\Administrator\Source\Repos\SandroPereira.EDI\SandroPereira.EDI.Orchestrations\obj\Debug\BizTalk\XLang\File0.cs 597 Active

After quickly analyzing my orchestration, I verified that the error was related to accessing the EDI properties promoted in the message context, as you see in the picture below:

It should be noted that the image only illustrates the problem that was occurring in the real project.
Cause
First, you need to know that if you want to access the EDI context properties inside the orchestrations, you need to reference the following DLL, otherwise the EDI properties are not visible:
- Microsoft.BizTalk.Edi.BaseArtifacts.dll
But I knew that I had done that! The DLL was referenced, and the EDI properties were accessible through the Visual Studio Expression. So, the biggest question was why I was getting this error.
After another quick analysis, the problem was related to the project/solution default namespace. That was, in my case, composed by:
- Client Name: SandroPereira
- EDI
- Type of artifact: Orchestrations:
That means: SandroPereira.EDI.Orchestrations.
When I was trying to access the UNB2.1 value inside the orchestrations by using the following expression:
- msgSample(EDI.Unb21);
The compiler was trying to find it inside my default solution namespace, SandroPereira.EDI, not inside the Microsoft.BizTalk.Edi.BaseArtifacts assembly.
EDI is a reserved word, and you shouldn’t use it in your BizTalk solution namespaces!
Solution
Solving this issue is quite simple, but depending on the size of your solution, it may be a little tedious and time-consuming. You just need to change your solution’s namespaces.
In my case, I renamed it to SandroPereira.EDI_Processing.Orchestrations
After doing that, I was able to successfully compile the solution.
Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can buy (or help me buy) my son a Star Wars Lego!