Could not load file or assembly or one of its dependencies. Reference assemblies should not be loaded for execution

After taking a look, i see noting specific in System.Buffers that would let me decide to not copy-local it, compared to other packages. The only thing i coukld tink of woukd be to hard-exclide any packages that start with System. (or any .dlls that do) from Copy-Local.

Could you confirm for me (because I’m on Mac, so whats missing here does count, per se, and also, I cant be sure if my minimal test app would trigger the right code paths) if the app runs fine if you delete all System.*.dll files from the output folder? IOW, does ever System.* named dll get found in the core framework?

thanx!
marc

I dont think we should be doing that.

Did you want an example that uses references inside system.buffers ?

I have a web app that uses ServiceBus with framework 4.7, it runs fine without system.buffers in the bin folder.

Probably not — bit it begs the question: how am I (is EBuild) supposed to know, from a set of some ~20 direct and indirect packages that are pulled in, which files should be copy-local’ed and which should not?

Thats also built with Elements? But yeah, the whole problem is that System.Buffers is in the bin folder, no? so it’d make sense that an app that doesnt have it works. Question is — why doesnt that one get it copied, also?

I found this page https://docs.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies

Says that ref assemblies are in the ref folder separate from the lib folder. They also use a ReferenceAssembly attribute.

Yes I built everything using Fire. I never discovered this problem because I was developing on my mac, running with mono and deploying to Azure. When deploying to azure I just copy the minimum required assemblies. ie I try and run the web app and if it complains about missing assemblies, I copy whatever it wants.

Think I got a solution, but its fairly involved, so I’ll keep it out of the upcoming official build, and send you a separate one later today.

What was the solution ?

Two parts, for one, I’ll reference .dlls for compile only from the ref folder, but copy local (and not use in the compile at all) only from the lib folder. Also, it seems I should not (at least for lib, not sure about ref) fall back to netstandard2.0, when there’s no net4x folder (coz that too brings back the Buffer .dll)

with the current setup I get:

                  Reference: /Users/mh/Code/Elements/Bin/References/Echoes/NET/Echoes.dll
                  Reference: /Users/mh/Code/Elements/Bin/References/Echoes/NET/Elements.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/mscorlib.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.Core.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.Data.DataSetExtensions.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.Data.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.Xml.dll
                  Reference: /Users/mh/Code/Fire Support/_NETFramework/v4.7/System.Xml.Linq.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.buffers/4.5.0/ref/net45/System.Buffers.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.io/4.3.0/ref/net462/System.IO.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.http/4.3.4/ref/net46/System.Net.Http.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.websockets.client/4.3.2/ref/net46/System.Net.WebSockets.Client.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.websockets/4.3.0/ref/net46/System.Net.WebSockets.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.numerics.vectors/4.5.0/ref/net46/System.Numerics.Vectors.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime.compilerservices.unsafe/4.6.0/ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime.serialization.primitives/4.3.0/ref/net46/System.Runtime.Serialization.Primitives.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime/4.3.1/ref/net462/System.Runtime.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.algorithms/4.3.1/ref/net463/System.Security.Cryptography.Algorithms.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.encoding/4.3.0/ref/net46/System.Security.Cryptography.Encoding.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.primitives/4.3.0/ref/net46/System.Security.Cryptography.Primitives.dll
                  Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.x509certificates/4.3.2/ref/net461/System.Security.Cryptography.X509Certificates.dll
                  Reference: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/gac/RemObjects.Elements.Cirrus/10.0.0.2458__3df3cad1b7aa5098/RemObjects.Elements.Cirrus.dll

D:             Generated Files for 'ServiceBusNuGetTest' target 'Echoes':
D:               Echoes.dll (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Echoes.dll)
D:               Echoes.dll.mdb (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Echoes.dll.mdb)
D:               Echoes.pdb (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Echoes.pdb)
D:               Elements.dll (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Elements.dll)
D:               Elements.dll.mdb (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Elements.dll.mdb)
D:               Elements.pdb (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Elements.pdb)
D:               Microsoft.Azure.Amqp.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.azure.amqp/2.4.3/lib/net45/Microsoft.Azure.Amqp.dll)
D:               Microsoft.Azure.Services.AppAuthentication.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.azure.services.appauthentication/1.3.1/lib/net461/Microsoft.Azure.Services.AppAuthentication.dll)
D:               Microsoft.IdentityModel.Clients.ActiveDirectory.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.identitymodel.clients.activedirectory/5.2.4/lib/net45/Microsoft.IdentityModel.Clients.ActiveDirectory.dll)
D:               Microsoft.IdentityModel.JsonWebTokens.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.identitymodel.jsonwebtokens/5.6.0/lib/net461/Microsoft.IdentityModel.JsonWebTokens.dll)
D:               Microsoft.IdentityModel.Logging.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.identitymodel.logging/5.6.0/lib/net461/Microsoft.IdentityModel.Logging.dll)
D:               Microsoft.IdentityModel.Tokens.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.identitymodel.tokens/5.6.0/lib/net461/Microsoft.IdentityModel.Tokens.dll)
D:               Newtonsoft.Json.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/newtonsoft.json/12.0.3/lib/net45/Newtonsoft.Json.dll)
D:               ServiceBusNuGetTest.exe (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/ServiceBusNuGetTest-07DA3FC117F5334FA018358D2FFEF386349307E1/Release/Echoes/ServiceBusNuGetTest.exe)
D:               System.Diagnostics.DiagnosticSource.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.diagnostics.diagnosticsource/4.6.0/lib/net46/System.Diagnostics.DiagnosticSource.dll)
D:               System.IdentityModel.Tokens.Jwt.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.identitymodel.tokens.jwt/5.6.0/lib/net461/System.IdentityModel.Tokens.Jwt.dll)
D:               System.IO.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.io/4.3.0/lib/net462/System.IO.dll)
D:               System.Net.Http.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.http/4.3.4/lib/net46/System.Net.Http.dll)
D:               System.Net.WebSockets.Client.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.websockets.client/4.3.2/lib/net46/System.Net.WebSockets.Client.dll)
D:               System.Net.WebSockets.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.net.websockets/4.3.0/lib/net46/System.Net.WebSockets.dll)
D:               System.Numerics.Vectors.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.numerics.vectors/4.5.0/lib/net46/System.Numerics.Vectors.dll)
D:               System.Runtime.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime/4.3.1/lib/net462/System.Runtime.dll)
D:               System.Runtime.Serialization.Primitives.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime.serialization.primitives/4.3.0/lib/net46/System.Runtime.Serialization.Primitives.dll)
D:               System.Security.Cryptography.Algorithms.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.algorithms/4.3.1/lib/net463/System.Security.Cryptography.Algorithms.dll)
D:               System.Security.Cryptography.Algorithms.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.algorithms/4.3.1/runtimes/osx/lib/netstandard1.6/System.Security.Cryptography.Algorithms.dll)
D:               System.Security.Cryptography.Encoding.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.encoding/4.3.0/lib/net46/System.Security.Cryptography.Encoding.dll)
D:               System.Security.Cryptography.Primitives.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.primitives/4.3.0/lib/net46/System.Security.Cryptography.Primitives.dll)
D:               System.Security.Cryptography.X509Certificates.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.security.cryptography.x509certificates/4.3.2/lib/net461/System.Security.Cryptography.X509Certificates.dll)

Thanks. I’ll try with my solutions later on.

1 Like

20191202-181007-elements-develop, once done in ~1h, will have the change. extensive testing/feedback against any NuGet-using projects would be appreciated.

1 Like

Up now.

Unfortunately it breaks a lot of things.

This is an example with 4 .net standard projects. It looks like its not resolving

https://github.com/mosh/Moshine.MessagePipeline nuget references

If you create a new .net console app and add Newtonsoft.Json as a reference, its not seeing any of the namespaces in the referenced assembly.ConsoleApplication3.zip (33.8 KB)
Like this

Yeah, I was afraid this was to easy and clean. Will investigate further…

Yep. Netwonsoft.Json has only a lib folder no ref. Jesus, is there any rhyme or reason to how these are structured? :frowning:

Fixed, I believe, can you retest with the next build?

The solution I posted a link too looks good.

DataFlowConsoleApplication.zip (36.3 KB)

I get Package ‘System.Threading.Tasks.Dataflow:4.9.0’ has no deliverable for platform ‘net 4.7’. with the attached project.

It worked before.

I also get

Package ‘NLog:4.6.3’ has no deliverable for platform ‘netcoreapp 3.0’.

Im not sure it its related.

Probably. I’ll check what those two do, in a bit (out of office for the first few hours, this morning).

I can’t win here :frowning:

that package as only a lib folder, and only for

netstandard1.0
netstandard1.1
netstandard2.0

I dont fall back to netstandard2.0 for lib, when building net4x anymore. if I change that, the original issue is broklen again, because System.Buffer has a lib folder for netstandard2.0, and we’ll be deploying that version of the System.Buffer.dll again.

Not sure what to do here! :(.

The current behavior comes as close to “as designed” as I can think of.

Does this package bundle in VC#? does it reference and copy the .dll version from netstandard2.0? If so, then why doesn’t System.Buffers also do that?