Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuGet Package StackExchange.Redis v2.2.4 raises System.IO.FileNotFoundException on ConnectionMultiplexer.Connect(_ConnectionString).GetDatabase() #1637

Closed
ChrWeinert opened this issue Dec 8, 2020 · 27 comments

Comments

@ChrWeinert
Copy link

ChrWeinert commented Dec 8, 2020

I want to use an Azure Redis Cache within my Azure Functions.
After creating a new Redis Cache Resource within my Azure Subscription I added the StackExchange.Redis package (version 2.2.4) to my .net Core 3.1 project.

When I connect to the Redis Cache my Application crashes at the follwoing line of code saying that the assembly System.IO.Pipelines was not found.
IDatabase _Cache = ConnectionMultiplexer.Connect(_ConnectionString).GetDatabase();

Exception Details:
_System.IO.FileNotFoundException: 'Could not load file or assembly 'System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Source=StackExchange.Redis
StackTrace:
at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in //src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1032
at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in /
/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1015_

I added the Nuget Package for System.IO.Pipelines with Version 5.0 to the project, but got the same error.
After this I removed StackExchange.Redis from the project and added it with an older version (2.1.58), but still get the error.

Does anyone got stucked in the same error and found a solution for this?

Best Regards
Christian Weinert

@nouira
Copy link

nouira commented Dec 9, 2020

I have the same error with 2.2.4 when targeting netcoreapp3.1.
Downgrading to 2.1.58 solved my problem though.

Here the detail of the error

System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.IO.Pipelines, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log)

@ChrWeinert
Copy link
Author

I already tried the versions 2.2.3 and 2.1.58, but the same exception occurs no matter which version i use.
Maybe this is a problem because of using Redis within a Azure Function "application" v3?

@mgravell
Copy link
Collaborator

mgravell commented Dec 9, 2020 via email

@ChrWeinert
Copy link
Author

Hello Marc,
thank You for Your reply.
I haven´t deployed the Azure Functions to the Azure Portal yet.
I get the error when I execute the functions locally.

I also included the nuget package "System.IO.Pipelines" into my project. Same error.

The error occures just when I added the Redis package. The error occurs when I want to open a connection (ConnectionMultiplexer.Connect(_ConnectionString)).

@mgravell
Copy link
Collaborator

mgravell commented Dec 9, 2020 via email

@ChrWeinert
Copy link
Author

ChrWeinert commented Dec 9, 2020

Hello Marc,
I created a new solution for You. It is just one Azure Function within I tried to open a connection to Redis.

FunctionApp1.zip

@ChrWeinert
Copy link
Author

I also setup a simple console application based on netcore3.1 using the same nuget packages.
This application works fine.

@mgravell
Copy link
Collaborator

mgravell commented Dec 9, 2020

Can you please try:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> <!-- *** this line is new ** -->
  </PropertyGroup>

(inspired by Azure/Azure-Functions#1518)

@ngufra
Copy link

ngufra commented Dec 10, 2020

Adding
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the csproj file fixed it for me.
The pipelines assembly gets deployed and stays there.

@mgravell
Copy link
Collaborator

Great to hear! Does it also work for you, @ChrWeinert ?

@ChrWeinert
Copy link
Author

Adding <_FunctionsSkipCleanOutput> to the project file works.

Thank You for the assistence!!!

@siraykut
Copy link

siraykut commented Feb 2, 2021

Thank You for the assistence!!! @mgravell

@dhornacek-spindance
Copy link

@mgravell You just saved me as well, thanks the for the help!

@ganesh-gawande
Copy link

Adding
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the csproj file fixed it for me.

But is this fix correct ? is this fix would work on Azure DevOps pipeline and after azure function deployment on azure?

@mgravell
Copy link
Collaborator

mgravell commented Mar 11, 2021 via email

@rahul230691
Copy link

Adding <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to my function project file didn't work for me.

<PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> <AzureFunctionsVersion>v3</AzureFunctionsVersion> <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup>

and exception which I am getting on console - "Anonymously Hosted DynamicMethods Assembly: Object reference not set to an instance of an object." when I am trying to inject IDistributedCache in contructor.

@mgravell
Copy link
Collaborator

Fundamentally, the maintainers aren't azure functions consumers, so it is very hard for us to opine. I've provided some initial hunches and ideas based on searching, and sometimes they have worked, sometimes they haven't. I guess what I'm saying is: it is very hard for us to provide the solution here - or even reproduce the problem.

What would be great is somebody who uses azure functions trying to debug it, and providing feedback (or a PR) along the lines of (for example):

the problem is the FooBlap package, which is loading at an incorrect version; the consumer can change the package reference to {some other version} and it works; you can also detect the problem by {some mechanism} at runtime, if you wish to improve the exception and offer direct guidance to say this

or

{some package} fundamentally can't work on {some TFM}; however, you could add {alternative TFM} or change the consumed package / version to {alternative} and it does work

or similar

@nirmallyakoley
Copy link

 <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

Thanks !!!

@AFDevMike
Copy link

Updating Microsoft.NET.Sdk.Functions to 3.0.13 resolved my issue without the need for <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>

@sshrishi
Copy link

Adding
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the csproj file fixed it for me.
The pipelines assembly gets deployed and stays there.

Thank you so much!

@joedyndale
Copy link

Hope this comment doesn't open the issue again. If it does, sorry!

Just wanted to leave this here in case more people like me stumble onto this page by googling before or instead of finding the proper solution, which is: Output Settings

@mgravell
Copy link
Collaborator

mgravell commented Nov 13, 2021

That's really helpful, thanks @joedyndale - hopefully people will use this approach in the future!

Ultimately, we're library maintainers. If the question is "how do we configure framework X to work with the library?", That needs knowledge of X - for every X you can imagine. And we're not X experts - we just know the library :) so: I appreciate the input

(Edit: although ironically, @NickCraver might not be able to use this excuse much longer)

@pmozbert
Copy link

pmozbert commented Jan 9, 2022

@joedyndale 's solution worked for me - specifically by adding this to the function app project csproj file.
<ItemGroup> <FunctionsPreservedDependencies Include="System.IO.Pipelines.dll" /> </ItemGroup>

@dlebee
Copy link

dlebee commented Jan 24, 2022

@joedyndale 's solution worked for me - specifically by adding this to the function app project csproj file. <ItemGroup> <FunctionsPreservedDependencies Include="System.IO.Pipelines.dll" /> </ItemGroup>

Worked for me too thanks @joedyndale

@ness001
Copy link

ness001 commented Jan 28, 2022

Please reopen the issue as it still exists. Is there any reason for removing the System.IO.Pipelines in the later versions?

@mgravell
Copy link
Collaborator

@ness001 We haven't removed anything. We depend on Pipelines as a transitive dependency. The problem is that some build/runtime environments aren't propagating that transitive dependency correctly. However, we don't own those build/runtime environments, and frankly: other than declaring the transitive dependency (which we already do), there is as far as I know: nothing more we can do. Except perhaps (as a few above), discuss various ways of working around that failure on different individual environments. Please feel free to suggest some additional action we could take here; that's the beauty of open source: now that you're aware of a problem, you can propose a concrete fix by playing with the code.

@jafeucht
Copy link

I ran into this issue because in Visual Studio, I had replaced all occurrences of "${DOCKER_REGISTRY-}" with the name of my docker repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests