Using Rhino3dm to Read 3dm in AWS Lambda C# Function

Hey guys!

I have created a fairly simple AWS lambda function, written in C# and .NET 6.0, to read a 3dm file and return some simple information about the objects in the document (object name, layer name, bounding box). Currently I am reading the 3dm file into a byte array and then encoding that byte array into a string and passing the string into the lambda as input. Inside the lambda I decode the string back into a byte array and then call File3dm.FromByteArray. In the future the files will likely be uploaded to S3 and I’ll read them directly from that.

I’m receiving the following error back from AWS and it seems to be struggling with a DLL dependency?

	"errorType": "DllNotFoundException",
	"errorMessage": "Unable to load shared library 'librhino3dm_native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibrhino3dm_native: cannot open shared object file: No such file or directory",
	"stackTrace": [
		"at UnsafeNativeMethods.ONX_Model_FromByteArray(Int32 length, Byte[] buffer)",
		"at Rhino.FileIO.File3dm.FromByteArray(Byte[] bytes)",
		"at LambdaTestRhino3dm.Function.FunctionHandler(TestFile testFile) in C:\\svn\\3DStuff\\RenderService\\LambdaTestRhino3dm\\Function.cs:line 43",
		"at lambda_method1(Closure , Stream , ILambdaContext , Stream )",
		"at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145",
		"at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 56",
		"at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176"

Any suggestions what I am doing wrong or if what I’m trying to do is even possible?

Hello. Which version of rhino3dm are you using? How are you referencing it in your project?

My project is consuming the Rhino3dm (version 7.14.0) NuGet package.

I think we are building a specific version of rhino3dm that targets the .net version used in AWS Lambda. I’m investigating this and will get back to you when I get further info.

The dotnet version we build for linux is targeting dotnet Core SDK 3.1.302. Is there a way you could use a dotnet core 3.1 environment and see if you still get issues?

Another issue might be the .net runtime. We aren’t building for arm64. Is there a way to specify x86_64?