question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Referenced nuget pkgs are not loaded by custom assemblies in root sharedbin folder

See original GitHub issue

Original discussion thread from StackOverflow with @fabiocav: (http://stackoverflow.com/questions/42281084/getting-null-terms-when-accesing-termcollection-from-sharepoint-online-via-csom).

When a custom assembly, which references a nuget package, is published into the wwwroot/sharedbin folder, the runtime cannot acccess the referenced nuget packages which are declared as dependencies of a child function in its project.json file.

Repro steps

  1. Create an HTTP triggered C# function with a project.json referencing the SharePoint CSOM nuget package as a dependency (see gist link below).

  2. Add 3 app settings to the function’s app service settings (SPOSiteUrl, SPOUserName, SPOPassword), with valid credentials and URL to connect to an existing SharePoint Online tenant site.

  3. Build a custom assembly, from a class library project which references the same SharePoint CSOM nuget package as the Azure function. Place the custom DLL into wwwroot/sharedbin using Kudu. (see gist link below for complete example files)

  4. Run the Azure function

Expected behavior

Function should invoke the code from the custom assembly within sharedbin folder, which logs into a SharePoint Online tenant with credentials, then connects to the default Taxonomy store, and retrieves all terms for a specified TermSet Guid, and returns the term data as a POCO view model. The function should return the view model data to the HTTP response as JSON.

Actual behavior

The Azure Functions runtime host throws an exception when invoking the custom assembly code, as it tries to find the Microsoft.SharePoint.Client.dll. It is not loaded into process, and it cannot find the assembly to load it.

Known workarounds

Instead of referencing the nuget package from the function’s project.json file, we need to download the nuget package locally, then extract the package’s DLLs and include them in the wwwroot\sharedbin folder along with the custom assembly, in order for all assemblies to be loaded by the process.

Related information

Gist containing all related files for repro: Gist

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fabiocavcommented, Mar 20, 2017

@tafs7 apologies for the delay on this. Missed some notifications and this fell off the radar.

Yes, for the runtime to be able to restore the packages, the package source/repository does need to be at least accessible. They could be authenticated and managed using the standard nuget.config mechanism.

A wwwroot project.json would not be used in the shared assemblies scenario. As mentioned above, that model does expect dependencies to be deployed with the assemblies (similar to how you’d deploy a standard app.)

1reaction
tafs7commented, Feb 28, 2017

@fabiocav Thanks for looking into this further and clarifying. As of now, I’ve got it working with the output of my project (custom dll and nuget DLLs) deployed to the shared bin folder.

When you mention that I should create a nuget package, do you mean that I should create the nuspec, etc., and then deploy it publicly, so that it can be pulled from the functions runtime? If so, I’m not sure I’d want to do that, since we’re building internal solutions for our corporate portal. If not, please help me understand your suggestion. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

This project references NuGet package(s) that are missing ...
This error usually occurs when you change the project directory name or path. edit the .proj file and replace the new directory name...
Read more >
Create a package using the nuget.exe CLI
A detailed guide on designing and creating a NuGet package, including files and versioning.
Read more >
How to resolve “Could not load file or assembly … or one of its ...
Thus, another solution is to update NuGet package in all root project and then in subsequent referred project (if required) where same package...
Read more >
Unable to resolve dependencies of NuGet packages
All NuGet package, Visual Studio throws the following error: ... Delete all packages from the packages folder, located in your project's folder.
Read more >
Loading .NET Assemblies out of Seperate Folders - Rick Strahl
Assemblies are loaded out of the application folder or a special private bin folder (like ASP.NET applications) and it all works as you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found