<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Missing System.ComponentModel.Annotations v4.2.0.0 in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8232869#M47931</link>
    <description>&lt;P&gt;Setup:&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;In my app.config file I have the following binding redirect for System.ComponentModel.Annotations: "&amp;lt;bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" /&amp;gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.IO.FileNotFoundException&lt;BR /&gt;&amp;nbsp; HResult=0x80070002&lt;BR /&gt;&amp;nbsp; 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.&lt;BR /&gt;&amp;nbsp; Source=Microsoft.EntityFrameworkCore&lt;BR /&gt;&amp;nbsp; StackTrace:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.CoreConventionSetBuilder.CreateConventionSet()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateConventionSet(IConventionSetBuilder conventionSetBuilder)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at System.Lazy`1.CreateValue()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at System.Lazy`1.LazyInitValue()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&amp;lt;&amp;gt;c__DisplayClass1_0.&amp;lt;RealizeService&amp;gt;b__0(ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetRelationalService[TService](IInfrastructure`1 databaseFacade)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Data.Repo.FacilityRepo.RunMigrations() in C:\Views\Plugins\LifeSciences\BT.Data.Repo\FacilityRepo.cs:line 66&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Controller.RunMigration() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 118&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Controller..ctor() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 83&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Interfaces.SController.get_Controller() in C:\Views\Plugins\LifeSciences\BT.Controller\Interfaces\SController.cs:line 30&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.LifeSciencesPlugin.Views.LifeSciencesView..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\Views\LifeSciencesView.xaml.cs:line 66&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.LifeSciencesPlugin.LifeSciencesPlugin..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\LifeSciencesPlugin.cs:line 77&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 14:53:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-08-29T14:53:26Z</dc:date>
    <item>
      <title>Missing System.ComponentModel.Annotations v4.2.0.0</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8232869#M47931</link>
      <description>&lt;P&gt;Setup:&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;In my app.config file I have the following binding redirect for System.ComponentModel.Annotations: "&amp;lt;bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" /&amp;gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.IO.FileNotFoundException&lt;BR /&gt;&amp;nbsp; HResult=0x80070002&lt;BR /&gt;&amp;nbsp; 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.&lt;BR /&gt;&amp;nbsp; Source=Microsoft.EntityFrameworkCore&lt;BR /&gt;&amp;nbsp; StackTrace:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.CoreConventionSetBuilder.CreateConventionSet()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateConventionSet(IConventionSetBuilder conventionSetBuilder)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at System.Lazy`1.CreateValue()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at System.Lazy`1.LazyInitValue()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.&amp;lt;&amp;gt;c__DisplayClass1_0.&amp;lt;RealizeService&amp;gt;b__0(ServiceProviderEngineScope scope)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.GetRelationalService[TService](IInfrastructure`1 databaseFacade)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Data.Repo.FacilityRepo.RunMigrations() in C:\Views\Plugins\LifeSciences\BT.Data.Repo\FacilityRepo.cs:line 66&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Controller.RunMigration() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 118&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Controller..ctor() in C:\Views\Plugins\LifeSciences\BT.Controller\Controller.cs:line 83&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.Controller.Interfaces.SController.get_Controller() in C:\Views\Plugins\LifeSciences\BT.Controller\Interfaces\SController.cs:line 30&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.LifeSciencesPlugin.Views.LifeSciencesView..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\Views\LifeSciencesView.xaml.cs:line 66&lt;BR /&gt;&amp;nbsp;&amp;nbsp; at BT.LifeSciencesPlugin.LifeSciencesPlugin..ctor() in C:\Views\Plugins\LifeSciences\BT.LifeSciencesPlugin\LifeSciencesPlugin.cs:line 77&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 14:53:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8232869#M47931</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-29T14:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Missing System.ComponentModel.Annotations v4.2.0.0</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8234439#M47932</link>
      <description>&lt;P&gt;Is this the same issue as in your other thread?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/fails-to-load-dependencies/td-p/8227232" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/fails-to-load-dependencies/td-p/8227232&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, can we assume that it is now resolved&amp;nbsp;as well?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 05:39:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8234439#M47932</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-08-30T05:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Missing System.ComponentModel.Annotations v4.2.0.0</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8235458#M47933</link>
      <description>&lt;P&gt;Although this is similar to my previous post, the solution that I used for that one did not solve the problem for this one.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 14:04:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8235458#M47933</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-30T14:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Missing System.ComponentModel.Annotations v4.2.0.0</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8252919#M47934</link>
      <description>&lt;P&gt;I still haven't&amp;nbsp; been able to get this working.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:12:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8252919#M47934</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-07T14:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Missing System.ComponentModel.Annotations v4.2.0.0</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8255546#M47935</link>
      <description>&lt;P&gt;You may try to force to load the assembly if it cannot be loaded successfully, please refer to code snippet below,this should be safe solution, per my experience; hope it can be helpful:&lt;/P&gt;
&lt;PRE&gt;        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            // Try to load assembly if Revit command fails to load it.
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CommandLoad_AssemblyResolve);
			//
			// your other code...
		}
		
		private Assembly CommandLoad_AssemblyResolve(object sender, ResolveEventArgs args)
        {
		   if(args.Name.Contains("ComponentModel.Annotations"))
		   {
		      string assemblyFile = Path.Combine(addinDir, "ComponentModel.Annotations.dll");
			  if(File.Exists(assemblyFile))
			     return return Assembly.LoadFrom(assemblyFile);		   
		   }
		}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Sep 2018 14:42:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/missing-system-componentmodel-annotations-v4-2-0-0/m-p/8255546#M47935</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2018-09-09T14:42:08Z</dc:date>
    </item>
  </channel>
</rss>

