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

ASP.NET web site (not regular project) fails to find gRPC native binaries #12570

Open
jskeet opened this Issue Sep 14, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@jskeet
Contributor

jskeet commented Sep 14, 2017

Platform: Windows
gRPC: 1.6.0
.NET: 4.6.1
Prerequisites: VS2017 with web development installed (not just regular ASP.NET)

Repro:

  • Start VS2017

  • From the File / New menu, pick Web Site (not Project), and target .NET 4.6.1 (although I doubt that the version matters much)

  • Use "Manage NuGet packages" to add Grpc.Core

  • Add a new web form (default.aspx)

  • In the codebehind (default.aspx.cs) in the Page_Load method, add a single line:

       var channel = new Channel("localhost:8001", ChannelCredentials.Insecure);
    
  • Run the app

It will fail when it can't load the native library, which won't have been copied to the bin directory.

I know very little about "web site" projects, unfortunately - there's no project file, just a packages.config.

@jskeet

This comment has been minimized.

Show comment
Hide comment
@jskeet

jskeet Sep 14, 2017

Contributor

I've just tried this with System.Data.Sqlite and seen the same effect. Their advice is "you need the native library on the path". I don't think we probe the path at the moment, which may be one option - another would be to allow an environment variable to specify where to find the DLL. Or just not support this scenario, potentially. (Ultimately, the support for native libraries in NuGet packages leaves something to be desired, but we need to work around that as best we can.)

Contributor

jskeet commented Sep 14, 2017

I've just tried this with System.Data.Sqlite and seen the same effect. Their advice is "you need the native library on the path". I don't think we probe the path at the moment, which may be one option - another would be to allow an environment variable to specify where to find the DLL. Or just not support this scenario, potentially. (Ultimately, the support for native libraries in NuGet packages leaves something to be desired, but we need to work around that as best we can.)

@pereiren

This comment has been minimized.

Show comment
Hide comment
@pereiren

pereiren Nov 19, 2017

Hi Jon,

I am facing this issue as well. I am working in a Proof of Concept to communicate code from a Website project to .NET Core 2 microservices (yeah I know, messy way but you know how Product Teams work with R&D teams and this is our only possibility to refactor our old code in microservices)

I tried as well to add directly the dlls in Bin folder and I got this:
website

en Grpc.Core.Internal.UnmanagedLibrary.GetNativeMethodDelegate[T](String methodName) en Grpc.Core.Internal.NativeMethods.GetMethodDelegate[T](UnmanagedLibrary library) en Grpc.Core.Internal.NativeMethods..ctor(UnmanagedLibrary library) en Grpc.Core.Internal.NativeExtension..ctor() en Grpc.Core.Internal.NativeExtension.Get() en Grpc.Core.GrpcEnvironment.GrpcNativeInit() en Grpc.Core.GrpcEnvironment..ctor() en Grpc.Core.GrpcEnvironment.AddRef() en Grpc.Core.Server..ctor(IEnumerable1 options)
en Grpc.Core.Server..ctor()
en WebSiteServerPoC.Startup.Configuration(IAppBuilder app) en C:\Users\Pereira\Documents\Visual Studio 2017\Projects\WebSiteServerPoC\App_Code\Startup.cs:línea 23
`
Hope it can hlep, I will try to find a solution anyway.

pereiren commented Nov 19, 2017

Hi Jon,

I am facing this issue as well. I am working in a Proof of Concept to communicate code from a Website project to .NET Core 2 microservices (yeah I know, messy way but you know how Product Teams work with R&D teams and this is our only possibility to refactor our old code in microservices)

I tried as well to add directly the dlls in Bin folder and I got this:
website

en Grpc.Core.Internal.UnmanagedLibrary.GetNativeMethodDelegate[T](String methodName) en Grpc.Core.Internal.NativeMethods.GetMethodDelegate[T](UnmanagedLibrary library) en Grpc.Core.Internal.NativeMethods..ctor(UnmanagedLibrary library) en Grpc.Core.Internal.NativeExtension..ctor() en Grpc.Core.Internal.NativeExtension.Get() en Grpc.Core.GrpcEnvironment.GrpcNativeInit() en Grpc.Core.GrpcEnvironment..ctor() en Grpc.Core.GrpcEnvironment.AddRef() en Grpc.Core.Server..ctor(IEnumerable1 options)
en Grpc.Core.Server..ctor()
en WebSiteServerPoC.Startup.Configuration(IAppBuilder app) en C:\Users\Pereira\Documents\Visual Studio 2017\Projects\WebSiteServerPoC\App_Code\Startup.cs:línea 23
`
Hope it can hlep, I will try to find a solution anyway.

@jskeet

This comment has been minimized.

Show comment
Hide comment
@jskeet

jskeet Nov 19, 2017

Contributor

The workaround I'm aware of (assuming it's actually the same error - it's not immediately clear that it is) is to write code to copy the plugin into the bin directory before you make any gRPC calls.

But it sounds like there's probably nothing we can do about the nuget installation for the package not doing this itself - I suspect that Website projects just don't perform the right steps here :(

Contributor

jskeet commented Nov 19, 2017

The workaround I'm aware of (assuming it's actually the same error - it's not immediately clear that it is) is to write code to copy the plugin into the bin directory before you make any gRPC calls.

But it sounds like there's probably nothing we can do about the nuget installation for the package not doing this itself - I suspect that Website projects just don't perform the right steps here :(

@pereiren

This comment has been minimized.

Show comment
Hide comment
@pereiren

pereiren Nov 28, 2017

I tried older versions because I saw this issue was noted on last version and it fails on the same way.

Did you test it specifying an environment variable as you sugggested? If not, I can give it a try during next days.

Thank you Jon, always a pleasure

pereiren commented Nov 28, 2017

I tried older versions because I saw this issue was noted on last version and it fails on the same way.

Did you test it specifying an environment variable as you sugggested? If not, I can give it a try during next days.

Thank you Jon, always a pleasure

@jskeet

This comment has been minimized.

Show comment
Hide comment
@jskeet

jskeet Nov 28, 2017

Contributor

No, I haven't tried modifying the path.

Contributor

jskeet commented Nov 28, 2017

No, I haven't tried modifying the path.

@pereiren

This comment has been minimized.

Show comment
Hide comment
@pereiren

pereiren Dec 1, 2017

It fails also trying to load the native DLLs on path, it is the same that trying to copy them to Bin folder.

I will give RabbitMQ a try to communicate our website project with .NET Core 2 microservices. I wanted to use gRPC but it can't be possible with this kind of website projects.

Anyway thank you Jon for the help and for finding out this issue.

pereiren commented Dec 1, 2017

It fails also trying to load the native DLLs on path, it is the same that trying to copy them to Bin folder.

I will give RabbitMQ a try to communicate our website project with .NET Core 2 microservices. I wanted to use gRPC but it can't be possible with this kind of website projects.

Anyway thank you Jon for the help and for finding out this issue.

@pereiren

This comment has been minimized.

Show comment
Hide comment
@pereiren

pereiren Jan 19, 2018

Finally I solved this issue. Instead of using the Nuget package, you need to add the DLL as a reference. It works now.

pereiren commented Jan 19, 2018

Finally I solved this issue. Instead of using the Nuget package, you need to add the DLL as a reference. It works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment