2013-01-04 143 views
0

爲了使用工作者角色將數據提供給Web角色,維護Web角色和Web角色之間的隔離,我通過內部端點將Azure Web角色鏈接到工作者角色數據庫[包含敏感數據]。有一個類庫項目,其中包含工作者角色和Web角色都引用的所有必需的數據合同。Shared DataContract工作者角色/ Web角色

在開發環境中一切都很好,它可以工作。只要我上傳到Azure,工作者角色就會失敗開始。錯誤信息是:

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 

看來它無法打開Data Contract類庫「ReadOnly_DC」。

對ReadOnly_DC的引用被設置爲複製本地,並且我已經對所有與Data Contract類庫一起使用的引用嘗試了「Copy Local」,但無濟於事。

任何建議感激地收到!

格蘭特

回答

0

好的 - 我不能相信這是答案,但這是我如何運作的。我將來自各種類庫的所有邏輯直接轉移到了我的工作者角色項目中,並且毫不奇怪,它可以找到它需要的各種方法和數據契約,並且工作者角色開始工作了!

爲了與Web角色共享「共享」資源,我通過解決方案資源管理器中的「添加現有項目」功能將必要的類[數據合同,YubiKey類和IWebService本身]添加到Web角色中,將它們添加爲「鏈接」而不是具有文件的重複副本。

因此,這從我暴露在互聯網上的Web角色維護了我隱藏的woker角色中所有祕密東西[連接字符串和共享存儲訪問鍵]的分離。

0

確保類庫中選擇「項目依賴......」當你右鍵點擊在Solution Explorer中的輔助角色項目。

+0

Data Contract類庫被設置爲依賴項,但是有一個Yubikey(安全令牌)類庫,我忘記將它設置爲依賴項。我已經做到了,現在正在重新發布以防萬一! - 感謝您的建議。 –