iot: .NET Core 3.0 Raspberry Pi 3 Install - FileNotFoundException
Apologies if this is not the right place but I feel that I’m missing something simple.
What I’m trying to do is test out razor components and .NET core 3.0 with System.Device.Gpio, developing on Windows in visual studio and running the app on a raspberry pi. I have been following this guide to get started.
I have installed the .NET core 3.0 SDK on the raspberry pi, mounted the solution folder and run dotnet restore and dotnet run - the default project works great.
However when I add System.Device.Gpio library from here, the runtime on the pi is unable to find the library (I ran dotnet restore again) and throws an exception as soon as I try to load a page. On my windows machine the page loads fine.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Device.Gpio, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'System.Device.Gpio, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNetCore.Components.ComponentResolver.EnumerateAssemblies(AssemblyName assemblyName, Assembly blazorAssembly, HashSet`1 visited)+MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at Microsoft.AspNetCore.Components.ComponentResolver.EnumerateAssemblies(AssemblyName assemblyName, Assembly blazorAssembly, HashSet`1 visited)+MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Microsoft.AspNetCore.Components.Routing.RouteTable.Create(IEnumerable`1 types)
at Microsoft.AspNetCore.Components.Routing.Router.SetParametersAsync(ParameterCollection parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterCollection parameters)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()
at Microsoft.AspNetCore.Components.Rendering.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderHandle.Render(RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
Is there something I am missing here? I have tried re-installing the library on the pi using dotnet add package, and it still throws this error. I feel like this is something simple =\
Thanks
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 43 (27 by maintainers)
Created dotnet/core-setup#5728 to get this fixed in the host.
Correct: NuGet selects independently by asset type. If the host does not that is a bug.
I’m guessing that folks don’t often both cross-compile the assembly by RID (SDK doesn’t support it) and provide a native asset: usually if folks invent a PAL they do it in one place. System.Device.Gpio has two, or rather, it has a managed PAL as well as a native helper. ML.NET might hit this too: can’t recall if it cross-compiles any managed components an includes native in the same package.
We still need to fix this in the host, just explaining why folks may not have noticed in the past.
-r linux-armshould work because it won’t create aruntimesfolder on build / publish as we know the specific RID being targeted and can copy the assets into a flat structure.It shouldn’t be required to explicitly target the RID in this case and the host should be able to resolve these assets at runtime from the
runtimes/directory.FYI, when you build with a target RID, it defaults to a self-contained deployment which includes the entire .NET Core runtime; use
--self-contained falsewhen publishing to create a framework-dependent deployment (does not include the .NET Core runtime assets).This should be fixed in nightly. I’m at a happy hour with Microsoft employees in Portland, but I can dig up the issue when I get back.
winscp can also keep a remote directory up to date without synching all files too. thats what i use (setup and run in the background)
It is worth noting that we will be removing the need of System.Device.Gpio.Native.so from our package, since we will now PInvoke directly into libgpiod.so. When we do that, then this problem will go away.
Maybe @vitek-karas can offer thoughts.
@IVData I think I have an idea what the issue might be.
Your
dotnet --infoon RPi showsRID: linux-x64- this seems incorrect (must have missed that earlier - probably skipped through that when I noticedraspbian). it should have printedlinux-arm- how did you install .NET Core on RPi? is this the ARM32 package/zip from: https://dotnet.microsoft.com/download ?Note:
System.Device.Gpio.Nativeis OOB nuget package (OOB meaning that it doesn’t ship with .NET Core and is a seperate package) - that means that you won’t have native dependencies unless you restore that package for linux-arm or deploy your app with linux-arm specific binaries (i.e. *.so files).could you try passing correct runtime to dotnet run? (
dotnet run -r linux-arm)If you have installed correct binaries and it still shows that I’d recommend creating issue in https://github.com/dotnet/core-sdk/