I have an Azure Web Role linked to a Worker Role via an internal endpoint for the purpose of using the worker role to serve up data to the web role, maintaining isolation between the web-role and the database [which contains sensitive data]. There is a Class Library project that contains all the necessary Data Contracts which is referenced by both the Worker Role and the Web Role.
In the development environment everything is fine and it works a treat. As soon as I upload to Azure the Worker Role failes to start. The error message being:
Message string Failed with ExceptionSystem.IO.FileNotFoundException: Could not load file or assembly 'ReadOnly_DC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'ReadOnly_DC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Signature.GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.get_Signature()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at System.ServiceModel.Description.ServiceReflector.ValidateParameterMetadata(MethodInfo methodInfo)
at System.ServiceModel.Description.TypeLoader.CreateOperationDescriptions(ContractDescription contractDescription, ContractReflectionInfo reflectionInfo, Type contractToGetMethodsFrom, ContractDescription declaringContract, MessageDirection direction)
at System.ServiceModel.Description.TypeLoader.CreateContractDescription(ServiceContractAttribute contractAttr, Type contractType, Type serviceType, ContractReflectionInfo& reflectionInfo, Object serviceImplementation)
at System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation)
at System.ServiceModel.Description.ContractDescription.GetContract(Type contractType, Type serviceType)
at System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts)
at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
at DA_Worker.WorkerRole.StartWS_Host() in C:\Users\grant.roy\Documents\Visual Studio 2010\Projects\CraigAzure\DA_Worker\WorkerRole.cs:line 80
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
; TraceSource 'WaWorkerHost.exe' event
It seems that it cannot open the Data Contract class Library "ReadOnly_DC".
The reference to ReadOnly_DC is set to copy local and I have tried "Copy Local" on all the references that go along with the Data Contract class library to no avail.
Any suggestions gratefully recieved!
Grant
OK - I can't believe this is the answer but this is how I got it to work. I moved all the logic from the various class libraries directly into my Worker Role project and, not surprisingly, it could then find the various methods and Data Contracts that it needed and the Worker Role began, well, working!!
In order to share the "shared" resources with the Web Role I addded the necessary classes [Data Contracts, YubiKey-Class and the IWebService itself] to the Web Role via the "add existing item" function in Solution Explorer, adding them as "links" rather than having duplicate copies of the files.
So this maintains seperation of all the secret stuff [connection strings and shared storage access keys] in my [hidden] woker role from my web role which is exposed to the internet.