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 Local
doesn'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.