我有一个azure函数,代码看起来像这样。我用的是.Net 6
[FunctionName("CarCounterFunc")]
public void Run(
[BlobTrigger("input/{name}.xml")] Stream inputBlob,IBinder binder,string
name,ILogger log)
{
XmlDocument doc = new XmlDocument();
doc.Load(inputBlob);
string json = jsonHandling.Convert(doc);
json = jsonHandling.Clean(json);
List<CarCounter> myList = JsonSerializer.Deserialize<List<CarCounter>>(json);
}
只要我加上这一行
List<CarCounter> myList = JsonSerializer.Deserialize<List<CarCounter>>(json);
我得到这些错误
[2023-05-15T16:07:48.680Z] Executing 'CarCounterFunc' (Reason='New blob detected(LogsAndContainerScan): input/a9909523-a23b-47ed-9732-40ea4535c82f.xml', Id=68bf0483-5f36-4325-8d82-01e02c0b3361)
[2023-05-15T16:07:48.689Z] Trigger Details: MessageId: b427a04e-620b-44db-8948-d5d9cc25145a, DequeueCount: 1, InsertedOn: 2023-05-15T16:07:47.000+00:00, BlobCreated: 2023-05-15T16:07:46.000+00:00, BlobLastModified: 2023-05-15T16:07:46.000+00:00
[2023-05-15T16:07:48.955Z] Executed 'CarCounterFunc' (Failed, Id=68bf0483-5f36-4325-8d82-01e02c0b3361, Duration=627ms)
[2023-05-15T16:07:48.957Z] System.Private.CoreLib: Exception while executing function: CarCounterFunc. CarCounterprj: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Det går inte att hitta filen.
感谢Tony Johansson
1条答案
按热度按时间wqsoz72f1#
从我的端复制后,我收到了相同的错误,你得到当我安装
System.Text.Json
包.但在我卸载了软件包后,我可以使这个工作。这是因为.NetCore 3.0及以上版本安装了内置包,其中包括
System.Text.Json
。有关更多信息,请参阅Rich Lander发布的.NET Core 3.0。出于演示目的,我直接使用了一个示例JSON。下面是为我工作的完整代码。