在 Azure Functions 上使用 Box SDK 时出错
Error using Box SDK on Azure Functions
我在 Azure Functions 中遇到 "Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified" 错误。关于问题可能是什么的任何想法?
我正在使用 package.json 文件让 Azure Functions 引入引用并将它们全部连接起来,如文档中所述。
When you upload a project.json file, the runtime gets the packages and automatically adds references to the package assemblies. You don't need to add #r "AssemblyName" directives. Just add the required using statements to your run.csx file to use the types defined in the NuGet packages.
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp
我的 package.json 文件:
{
"frameworks": {
"net46":{
"dependencies": {
"BouncyCastle": "1.8.1",
"BouncyCastle-PCL": "1.0.0.6",
"Box.V2": "2.14.0",
"Box.V2.JWTAuth": "1.2.0",
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168",
"Microsoft.Bcl.Build": "1.0.14",
"Microsoft.Net.Http": "2.2.29",
"Newtonsoft.Json": "6.0.2",
"Nito.AsyncEx": "2.1.3",
"System.IdentityModel.Tokens.Jwt": "4.0.2.206221351"
}
}
}
}
run.csx 使用语句:
using global::Box.V2;
using global::Box.V2.Config;
using global::Box.V2.Exceptions;
using global::Box.V2.JWTAuth;
using global::Box.V2.Models;
完全异常:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.GetTelogisFormInstancePdf ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
at Submission#0.Run(HttpRequestMessage req,TraceWriter log) at : 84
End of inner exception
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture)
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)
at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??…
错误明确指出找不到程序集:
System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
虽然您在 .csx 中显示您有 using 语句来包含名称空间,但您没有在哪里显示您实际上 reference the external assemblies
如上述链接文档中所述:
If you need to reference a private assembly, you can upload the assembly file into a bin folder relative to your function and reference it by using the file name (e.g. #r "MyAssembly.dll").
确保路径正确;我必须确保 bin
文件夹在我的函数所在的路径内——共享程序集方法对我不起作用。
我还建议,也许比处理 csx 和引用程序集更简单的方法是将 csx 一起抛弃,并使用此 blog post 中描述的预编译函数。然后,您将获得程序集的完整编译时间分辨率和 CSX 文件无法获得的正确智能感知。
此错误具有误导性,我不得不最终覆盖 BoxJWTAuth 以使其正常工作。可以在此处找到此错误的详细信息:https://github.com/box/box-windows-sdk-v2/issues/297
我在 Azure Functions 中遇到 "Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified" 错误。关于问题可能是什么的任何想法?
我正在使用 package.json 文件让 Azure Functions 引入引用并将它们全部连接起来,如文档中所述。
When you upload a project.json file, the runtime gets the packages and automatically adds references to the package assemblies. You don't need to add #r "AssemblyName" directives. Just add the required using statements to your run.csx file to use the types defined in the NuGet packages.
https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp
我的 package.json 文件:
{
"frameworks": {
"net46":{
"dependencies": {
"BouncyCastle": "1.8.1",
"BouncyCastle-PCL": "1.0.0.6",
"Box.V2": "2.14.0",
"Box.V2.JWTAuth": "1.2.0",
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168",
"Microsoft.Bcl.Build": "1.0.14",
"Microsoft.Net.Http": "2.2.29",
"Newtonsoft.Json": "6.0.2",
"Nito.AsyncEx": "2.1.3",
"System.IdentityModel.Tokens.Jwt": "4.0.2.206221351"
}
}
}
}
run.csx 使用语句:
using global::Box.V2;
using global::Box.V2.Config;
using global::Box.V2.Exceptions;
using global::Box.V2.JWTAuth;
using global::Box.V2.Models;
完全异常:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.GetTelogisFormInstancePdf ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
at Submission#0.Run(HttpRequestMessage req,TraceWriter log) at : 84
End of inner exception
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture)
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)
at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??…
错误明确指出找不到程序集:
System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
虽然您在 .csx 中显示您有 using 语句来包含名称空间,但您没有在哪里显示您实际上 reference the external assemblies
如上述链接文档中所述:
If you need to reference a private assembly, you can upload the assembly file into a bin folder relative to your function and reference it by using the file name (e.g. #r "MyAssembly.dll").
确保路径正确;我必须确保 bin
文件夹在我的函数所在的路径内——共享程序集方法对我不起作用。
我还建议,也许比处理 csx 和引用程序集更简单的方法是将 csx 一起抛弃,并使用此 blog post 中描述的预编译函数。然后,您将获得程序集的完整编译时间分辨率和 CSX 文件无法获得的正确智能感知。
此错误具有误导性,我不得不最终覆盖 BoxJWTAuth 以使其正常工作。可以在此处找到此错误的详细信息:https://github.com/box/box-windows-sdk-v2/issues/297