0

I have just set up my linux machine with the new .NET support.

  1. Using this tutorial: http://docs.asp.net/en/latest/getting-started/installing-on-linux.html
  2. Having this dockerfile:

     FROM microsoft/aspnet:1.0.0-beta5
    
     # Copy the project into folder and then restore packages
     COPY . app
     WORKDIR app
     RUN ["dnu","restore"]
    
     # Open this port in the container
     EXPOSE 5000
     # Start application
     ENTRYPOINT ["dnx",".", "web"]
    
  3. Running docker build . is successful

  4. When running # docker run -p 8080:5000 dockerfile I get this exception:

    System.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IApplicationEnvironment' has been registered.    
        at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService (IServiceProvider provider, System.Type serviceType) [0x00000] in <filename unknown>:0
        at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[IApplicationEnvironment] (IServiceProvider provider) [0x00000] in <filename unknown>:0
        at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0    
        at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)    
        at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
     --- End of stack trace from previous location where exception was thrown ---   
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0  
     at Microsoft.Dnx.ApplicationHost.Program+<>c__DisplayClass3_0.<ExecuteMain>b__0() [0x00000] in <filename unknown>:0    
     at System.Threading.Tasks.Task`1[System.Threading.Tasks.Task`1[System.Int32]].InnerInvoke() [0x00000] in <filename unknown>:0    
     at System.Threading.Tasks.Task.Execute () [0x00000] in <filename unknown>:0
    

Here is my full build log

http://pastebin.com/e3zpcrFZ

What am I doing wrong here? Running the same project with dnx . web in a windows starts up my webapi successfully.

Fabian N.
  • 3,807
  • 2
  • 23
  • 46
Marco Klein
  • 683
  • 5
  • 19

1 Answers1

0

Solved it myself. Found out that during the installation alongside with the tutorial, it was installing an old mono version. You need Mono 4.x, according to this post http://blog.bananacoding.com/blog/first-impressions-of-aspnet-and-visual-studio-code-on-osx

So what I did was the following:

  1. Uninstall mono using .net
  2. Purging it
  3. Using the installation instructions on the mono website, installing mono 4-x
  4. Using apt-get -o Dpkg::Options::="--force-overwrite" -f install I forced to overwrite everything since I got errors about some libs
  5. dnvm install latest
  6. Fitting my project to the latest versions (see several update posts on the net)
  7. dnu restore
  8. dnx kestrel

DONE!

Marco Klein
  • 683
  • 5
  • 19