0

I'm trying to create a simple azure function which will listen my service bus topic:

var test = new PhotoStatsChange();//OK
var entity = message.GetBody<PhotoStatsChange>(new NetDataContractSerializer());//Exception here

Could not load file or assembly 'PhotoManager.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

PhotoManager.Domain is the assembly where PhotoStatsChange is defined. But I'm totally confused by error message(there is no inner exception): how the assembly cannot be found if it's used in line above?

Actually PhotoManager.Domain.dll is present in /bin/Debug/net461/bin folder.

Brokered message text:

<?xml version="1.0" encoding="UTF-8"?>
<PhotoStatsChange 
    xmlns="http://schemas.datacontract.org/2004/07/PhotoManager.Domain.Caching" 
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" 
    z:Id="1" 
    z:Type="PhotoManager.Domain.Caching.PhotoStatsChange" 
    z:Assembly="PhotoManager.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
   <CacheRebuilt>false</CacheRebuilt>
   <InstanceNum z:Id="2">IN_0</InstanceNum>
</PhotoStatsChange>

Update

I created a simple example with assembly which contains a single POCO class and doesn't have any external dependencies(only those that are added by default like System, System.Data etc). And even in this case I have the same exception.

Some notes

  • Setting Copy Localdoesn't help
  • The issue is not present when using default serializer(Microsoft.ServiceBus.Messaging.DataContractBinarySerializer)

So it seems like there is an issue when using NetDataContractSerializer inside Azure Functions.

Roman Koliada
  • 2,972
  • 1
  • 16
  • 48
  • Could it be `one of its dependencies`? – Ian Oct 09 '18 at 13:07
  • @Ian I'm not sure. I didn't find anything useful in exception details. Is it possible to determine which dependency might cause a problem? – Roman Koliada Oct 09 '18 at 13:13
  • Here https://stackoverflow.com/questions/1091853/error-message-unable-to-load-one-or-more-of-the-requested-types-retrieve-the-l is a code how to retrieve loader message – lukaszberwid Oct 10 '18 at 07:58

0 Answers0