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

PMC Tools: Exception calling "Substring" #8163

Closed
mdarefull opened this issue Apr 13, 2017 · 5 comments
Closed

PMC Tools: Exception calling "Substring" #8163

mdarefull opened this issue Apr 13, 2017 · 5 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@mdarefull
Copy link

I'm working on an ASP NET MVC Core project (VS 2017, .NET Core 1.1).
I had the need of logging to the console the running environment of the application at startup and hence I configured the loggerFactory on the Startup's constructor and, immediately after, I log the required information:

public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
    //...
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();

    var logger = loggerFactory.CreateLogger<Startup>();
    logger.LogInformation($"Runing in environment: {env.EnvironmentName}");
}

Then, if I tried to use a command related to migrations (Add-Migration or Update-Database) I receive the following error:
image

Furthermore, I noticed that if I don't include the ':' on the message, the command will run successfully:
image

Anyway, the output message is not the expected.

PS: I've superfitially checked by writing directly to the console (Console.WriteLine(...)) and it worked.

Steps to reproduce

This can be reproduced with the default project templates that come with VS 2017.

  1. Create a new solution/project by selecting the template Visual C#/Web/ASP.NET Core Web Application (.NET Core) and choosing the Individual User Accounts authentication.
  2. Modify the Startup constructor signature to be:
public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
  1. At the end of the Startup constructor add the following code:
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();

var logger = loggerFactory.CreateLogger<Startup>();
logger.LogInformation($"Runing in environment {env.EnvironmentName}");
  1. Remove the loggerFactory configuration statements from the Configure method (2 firsts)
@bricelam
Copy link
Contributor

bricelam commented Apr 13, 2017

This looks familiar. What version(s) of the EF packages are you using? It may already be fixed.

@mdarefull
Copy link
Author

I have the latest stable updates of every nuget package, so they should be:
1.1.1 and 1.1.0 for Microsoft.EntityFrameworkCore.Tools

@bricelam bricelam self-assigned this Apr 16, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0, 2.0.0-preview1 Apr 17, 2017
@bricelam bricelam removed the tools label Apr 26, 2017
@bricelam bricelam changed the title Migrations break when logging information on the startup constructor. PMC Tools: Logging information on the startup constructor throws May 2, 2017
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label May 12, 2017
@bricelam bricelam changed the title PMC Tools: Logging information on the startup constructor throws PMC Tools: Exception calling "Substring" May 12, 2017
@bricelam bricelam modified the milestones: 2.0.0, 2.0.0-preview2 May 16, 2017
@MikeInSwitzerland
Copy link

It's now February 2018, and this issue is live and kicking with VS2017 v15.5.6 and EntityFramework Core v2.0.1.

@smitpatel
Copy link
Member

@MikeInSwitzerland - This issue was fixed in EF Core 2.0 release. You may be seeing similar error message but it could be due to different bug. Please file a new issue with repro steps so that we can investigate.

@MikeInSwitzerland
Copy link

@smitpatel Thank you so much for taking the time to reply to my comment... but as I said, I had actually installed Core 2.0 today. What fixed my problem was to use VS2017's function to clear the GitHub cache. But these error messages are so useless, and give you no clue about what to do, or how to solve them... you don't know if it's going to take you an hour or a month to get around such problems... As a developer, used to the cosy, reliable world of regular ASP.Net, it scares me....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants