I don't get Ocelot to work, I do create a new project, update all references and install Ocelot to the project, then I create the configuration.json file with one route to one of my service, but when I run the project (gateway), it keep loading. What am I doing wrong?
Sorry if this doesn't go here, but I didn't find where to post my question.
Regards!
Hi @piyey can you post your configuration.json here? Hide anything that might be sensitive! Also are you using the latest nuget package or Ocelot from source?
Hi @TomPallister ,thanks for your answer.
This is my configuration.json file:
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/Clientes/BuscarPorId/{id}",
"DownstreamScheme": "http",
"DownstreamHost": "localhost",
"DownstreamPort": 59293,
"UpstreamPathTemplate": "/BuscarClientePorId/{id}",
"UpstreamHttpMethod": "Get"
}
]
}
I got this error in debug:
Excepci贸n producida: 'System.EntryPointNotFoundException' en System.Private.CoreLib.ni.dll
Excepci贸n producida: 'System.DllNotFoundException' en System.Private.CoreLib.ni.dll
System.DllNotFoundException: Unable to load DLL 'combase.dll': No se puede encontrar el m贸dulo especificado. (Exception from HRESULT: 0x8007007E)
at Microsoft.Win32.UnsafeNativeMethods.RoGetActivationFactory(String activatableClassId, Guid& iid, Object& factory)
at System.Threading.Tasks.AsyncCausalityTracer..cctor()
I have no idea what that exception is! What OS are you using?
Windows 7 x64
@piyey, I had a similar issue when I try o run the Ocelot.ManualTest project. Where the gateway is struck in host.Run(); and all the internal request threads are exited.
So I just created a new project with new startup file
`public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddJsonFile("configuration.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
Action<ConfigurationBuilderCachePart> settings = (x) =>
{
x.WithMicrosoftLogging(log =>
{
log.AddConsole(LogLevel.Debug);
})
.WithDictionaryHandle();
};
services.AddOcelot(Configuration, settings);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseOcelot().Wait();
}
}`
I think something in the public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) method is causing the issue. Still did not get time to see why.
But the new startup template works.
NOTE : I did not got any exception by the way. For me it was just kept loading
I wonder if its something to do with the app.UseOcelot().Wait(). I possibly need to stick ConfigureAwait(false) on all the calls down the stack from this point. I wasn't sure how .NET core was going to work with calling .Wait() on a task during Startup in terms of deadlocking and I have had no problems with deadlocking myself.
Further research shows
http://stackoverflow.com/questions/41128131/task-start-net-core-unable-to-load-dll-combase-dll-error-windows-7
and
seems to be a win7 / .net core issue not specific to Ocelot :(
Thanks @somusun3 , I have tried your solution, but I still get errors:
Excepci贸n producida: 'System.EntryPointNotFoundException' en System.Private.CoreLib.ni.dll
Excepci贸n producida: 'System.BadImageFormatException' en System.Private.CoreLib.ni.dll
System.BadImageFormatException: Se ha intentado cargar un programa con un formato incorrecto. (Exception from HRESULT: 0x8007000B)
at Microsoft.Win32.UnsafeNativeMethods.RoGetActivationFactory(String activatableClassId, Guid& iid, Object& factory)
at System.Threading.Tasks.AsyncCausalityTracer..cctor()Excepci贸n producida: 'System.EntryPointNotFoundException' en System.Private.CoreLib.ni.dll
Excepci贸n producida: 'System.BadImageFormatException' en System.Private.CoreLib.ni.dll
System.BadImageFormatException: Se ha intentado cargar un programa con un formato incorrecto. (Exception from HRESULT: 0x8007000B)
at Microsoft.Win32.UnsafeNativeMethods.RoGetActivationFactory(String activatableClassId, Guid& iid, Object& factory)
at System.Threading.Tasks.AsyncCausalityTracer..cctor()
@TomPallister , Thanks for your answer, I have read that posts and I see is a problem with combase.dll, I have avoided to use await, but now I get error cited before.
Regards!
@piyey I麓ve seen that you are from Nicaragua. I麓m from Spain. If you want you can write me by private in Spanish to explain me better what is your problem in order to try to help you. I have done some mini projects with ocelot to test it and I didn麓t have any problems. You should be able to create a simple web api project with only ocelot dll without problems too. What kind of project are you creating? What Visual Studio are you using? Do you have installed the .Net Core SDK 1.1?
Hello @juancash , thanks for your interest in help.
I fiinally find where was my problem, looks like it was me.
I just copy all configuration from the guide in Getting Started site in Startup section on wich it remove .UseIISIntegration() from Program Class. Looks like it is required in my enviroment to run the application. I created a new project and included this configuration and now it works perfectly.
Sorry if I spent your time, but maybe it help someone else having the same problem than me.
Thanks to all, specially Tom for create this spectacullar library!!!
Regards!
Gracias @juancash , para la pr贸xima ya se con qui茅n abocarme si necesito ayuda en espa帽ol :)
@piyey Don't worry about time :) It's good to have people interested in the project.