question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FileNotFoundException: System.Runtime, Version=4.2.2.0

See original GitHub issue

Describe the bug Attempting to run ‘dotnet fm migrate’ on a migration fails with the following exception, if I use a certain option in the migration:

dotnet fm migrate -c "..." -p sqlserver -a Schema.dll
-------------------------------------------------------------------------------
xxx: xxx migrating
-------------------------------------------------------------------------------
Beginning Transaction
Rolling back transaction

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at xxx.Schema.xxx.Up()
   at FluentMigrator.MigrationBase.GetUpExpressions(IMigrationContext context) in d:\a\1\s\src\FluentMigrator\MigrationBase.cs:line 83
   at FluentMigrator.Runner.MigrationRunner.ExecuteMigration(IMigration migration, Action`2 getExpressions) in d:\a\1\s\src\FluentMigrator.Runner\MigrationRunner.cs:line 831
   at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(IMigrationInfo migrationInfo, Boolean useTransaction) in d:\a\1\s\src\FluentMigrator.Runner\MigrationRunner.cs:line 607
   at FluentMigrator.Runner.MigrationRunner.MigrateUp(Int64 targetVersion, Boolean useAutomaticTransactionManagement) in d:\a\1\s\src\FluentMigrator.Runner\MigrationRunner.cs:line 427
   at FluentMigrator.Runner.Initialization.TaskExecutor.Execute() in d:\a\1\s\src\FluentMigrator.Runner\Initialization\TaskExecutor.cs:line 165
   at FluentMigrator.DotNet.Cli.Commands.BaseCommand.ExecuteMigrations(MigratorOptions options, IConsole console) in d:\a\1\s\src\FluentMigrator.DotNet.Cli\Commands\BaseCommand.cs:line 32
   at FluentMigrator.DotNet.Cli.Commands.Migrate.OnExecute(IConsole console) in d:\a\1\s\src\FluentMigrator.DotNet.Cli\Commands\Migrate.cs:line 35
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](IConsole console, String[] args)
   at FluentMigrator.DotNet.Cli.Program.Main(String[] args) in d:\a\1\s\src\FluentMigrator.DotNet.Cli\Program.cs:line 35

This is my migration:

public override void Up()
{
	Alter.Table("MyTable")
		.AddColumn("MyColumn").AsBoolean().SetExistingRowsTo(false);
}

If I remove SetExistingRowsTo it succeeds. If I try SetDefaultValueTo the error is also present.

To Reproduce

  1. Build a .NET Core 3.1 app with the above schema migration and run it

Expected behavior No error to occur, the migration should succeed.

Information (please complete the following information):

  • OS: Windows 10
  • Platform .NET Core 3.1
  • FluentMigrator version: 3.2.6 (fluentmigrator.dotnet.cli 3.2.6) and FluentMigrator 3.2.6 used by the schema project
  • FluentMigrator runner: FluentMigrator.DotNet.Cli
  • Database Management System: SQL Server
  • Database Management System Version: 2019 LocalDB

Additional context I’ve seen a similar report at https://github.com/fluentmigrator/fluentmigrator/issues/1188 but it was unclear what the resolution is. It’s also interesting the migration fails when using some optional extension methods (eg SetExistingRowsTo) but otherwise works fine.

I have tried adding System.Runtime to my project via nuget but it did not resolve the error.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
jzabroskicommented, Jun 8, 2020

Just an update on this. I released 3.2.7 this morning. There is a small chance we will have a 3.2.8 release as there is an outstanding Oracle PR, but otherwise I am focused on finishing 3.3.0 which should address this problem.

1reaction
tekguycommented, May 8, 2020

I just ran into this issue today, looking forward to the PR as well. Thank you @jzabroski

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET Core 3.1 - Could not load file or assembly System. ...
In my case Nischal Nigam's solution didn't worked out, so what I did, I updated the package Microsoft.NET.Sdk.Functions from version 1.0...
Read more >
NET Core: Could not load file or assembly 'System. ...
TestMethod1 threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, ...
Read more >
MSB3277: Found conflicts between different versions of ' ...
This error occurs during a build when more than one version of the same dependent assembly is referenced in a build of the...
Read more >
Troubleshoot .NET Framework targeting errors
To resolve the error, make sure that your application targets a .NET version that's compatible with the version that's targeted by the projects ......
Read more >
Microsoft.Identity.Client 4.55.0
This version supports adding authentication functionality to your .NET based clients - .NET, .NET Framework, .NET MAUI, Xamarin iOS, Xamarin Android and UWP ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found