Thursday 4 March 2010

Biztalk gotcha?

BTS 2006

Exception type: TypeInitializationException
Source: MyNS.MyService

Additional error information: Field not found: 'ReferencedAssembly_.Type.Method'.

Exception type: MissingFieldException
at MyNS.MyService..cctor()

****

Biztalk Assembly 1: Assm1.dll
Biztalk Assembly 2: Assm2.dll

Assm1 references Assm2

Assm2 contains a "web reference" to a service, but in this scenario Assm1 has referenced Assm2 to access a shared type, it doesn't care about the web ref.

Now, say I updated the web ref and build Assm1, which will in turn cause Assm2 to be built...

I need to ensure *both* assemblies get deployed...

Because the web service "proxy" will have been propogated into Assm1.

This isn't a problem until the web service contract is changed - a breaking change, say a method is added.

If this happens and only Assm1 is deployed, then I'll get a missing field exception in the Assm1 constructor as the proxy definition there will be expecting a field in the proxy which doesn't yet exist on the target machine!
In order to deal with this, I'd need to deploy both assemblies.

A better idea would be to have an assembly wrapping the web reference and nothing else, so I'm only referencing this assembly if I actually need the web proxy!

Snippet of constructor in Assm1

static MyType()
{
__access = 1;
__execable = false;
_serviceId = HashHelper.HashServiceType(typeof(MyType));
_lockIdentity = new object();
_portInfo = new PortInfo[] { new PortInfo(new OperationInfo[] {
Assm2WebProxy.Method1, Assm2WebProxy.Method2, Assm2WebProxy.Method3 ....