I ran into some pretty strange behavior` today in BizTalk. I use different projects in my solution for things like schemas, mappings, orchestrations, etc., the BizTalk Software Factory way so to say. For this blogpost I created a new project, which can be downloaded here.
The problem arose, when I wanted to use a distinguished field in my orchestration. I went ahead and created a new schema, created the distinguished field, built my schemas project, and finally added the assembly to the GAC (my development machine is also my test machine at this customer, so there is no way around having the assemblies in the GAC at some point).I then created an orchestration, added a message in my orchestration of the specific schema type, added the plumbing like receive shape, port and an Expression shape in which I assign the value of the distinguished field to a variable. At this point, I get an error stating “identifier ‘SubNode’ does not exist in ‘msgIncoming’”. Everything else is working, the schema is of the correct type, and if you have any promoted properties in your schema, you can access these in the filter on your receive shape.
After some (actually, quite a bit) searching, I found out what the problem was. When you create a new BizTalk project, by default a reference is added to the Microsoft.BizTalk.TestTools assembly. Since we didn’t use this assembly, we removed the reference (along with some other references).Now, the removal of this assembly reference is at the base of our problem, so one solution would be not to remove the reference. I did however wonder why this assembly reference would cause these problems. After some more digging, I found out that if you remove this reference, you also should go to your schema project’s properties, go to the Deployment tab, and set Enable Unit Testing to False. Then rebuild the project, and add it to the GAC.
You will now notice the error on the orchestration’s expression is gone, and this project can be built as well. I am still unsure why this behavior occurs, but it can be reproduced by setting Enable Unit Testing to True again, so it does seem something happens in the background.