
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Setup:
In my project directory I have a reference set up to use System.ComponentModel.Annotations v4.2.1.0 and it is being copied to local.
In my app.config file I have the following binding redirect for System.ComponentModel.Annotations: "<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />"
My project is set up as an application plugin that launches my application when a button is clicked from the ribbon panel in the addins section of revit. I know that I have that set up correctly because it has run correctly prior to my latest addition (which involves Entity Framework reading/writing to a database). I have a class that extends DBContext stored in the variable _context. When I first initialize _context I immediately run the command _context.Database.Migrate(). Upon running this command I get the error below. This issue only occurs when i run this application through revit. I have a standalone application that runs outside of Revit and makes the exact same calls that doesn't have any problem finding/loading System.ComponentModel.Annotations. I'm not sure why my application can't load this dependency when running through Revit, but can through my standalone project (both of which have identical references). Does anyone have any ideas on how to fix this?
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source=Microsoft.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.CoreConventionSetBuilder.CreateConventionSet()
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateConventionSet(IConventionSetBuilder conventionSetBuilder)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetRelationalService[TService](IInfrastructure`1 databaseFacade)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
at BT.Data.Repo.FacilityRepo.RunMigrations() in C:\Views\Plugins\LifeSciences\BT.Data.Repo\FacilityRepo.cs:line 66
at BT.Controller.Controller.RunMigration() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 118
at BT.Controller.Controller..ctor() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 83
at BT.Controller.Interfaces.SController.get_Controller() in C:\Views\Plugins\LifeSciences\BT.Controller\Interfaces\SController.cs:line 30
at BT.LifeSciencesPlugin.Views.LifeSciencesView..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\Views\LifeSciencesView.xaml.cs:line 66
at BT.LifeSciencesPlugin.LifeSciencesPlugin..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\LifeSciencesPlugin.cs:line 77
Solved! Go to Solution.