【问题标题】:Sitecore 9.2 Helix ,How to use Assets, SitecoreExtension and Dependency Injection that exist in foundation layer of habitatSitecore 9.2 Helix ,如何使用栖息地基础层中存在的资产、SitecoreExtension 和依赖注入
【发布时间】:2021-05-18 15:28:58
【问题描述】:

我是使用 Helix 设计原则进行 sitecore 开发的初学者 我从空白项目开始,在要素层中添加了一项功能,在项目层as in this image 中添加了一种布局,效果很好。

当我尝试将资产模块用于我的项目的栖息地基础层中存在的样式目的时,它告诉我它需要依赖注入和 Sitecore 扩展

当我尝试在我的项目中加载 DependenyInjection 并使用 gulpfile as in this image 部署它时,sitecore 给了我这个错误

Server Error in '/' Application.
Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Source Error:


Line 187:            try
Line 188:            {
Line 189:                return assembly.GetExportedTypes();
Line 190:            }
Line 191:            catch (NotSupportedException)

Source File: D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs    Line: 189

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:


[FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
   System.Reflection.RuntimeAssembly.GetExportedTypes() +32
   Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:189

[InvalidOperationException: Unable to load types from assembly Sitecore.XA.JSS.Foundation.Integration, Version=5.9.0.0, Culture=neutral, PublicKeyToken=null. Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
   Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:210
   System.Linq.<SelectManyIterator>d__17`2.MoveNext() +265
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +287
   System.Linq.WhereEnumerableIterator`1.MoveNext() +255
   Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, Assembly[] assemblies) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:39
   Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, String[] assemblyFilters) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:27
   Sitecore.Foundation.DependencyInjection.Infrastructure.MvcControllerServicesConfigurator.Configure(IServiceCollection serviceCollection) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\Infrastructure\MvcControllerServicesConfigurator.cs:12
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
   Sitecore.DependencyInjection.BaseServiceProviderBuilder.ConfigureServiceCollection() +142
   Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +225
   Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +513
   Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +142
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +107
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1476
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +80
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +234
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1153
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +139
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724

【问题讨论】:

    标签: sitecore helix sitecore-habitat


    【解决方案1】:

    首先,看一下this sitecore community question,因为它与您的情况类似。

    那么,如果不固定:

    • 确保您已使用 nuget 包管理器 -> 包源在 Visual Studio 中添加了 sitecore nuget 源 (https://sitecore.myget.org/F/sc-packages/api/v3/index.json)。

    • 在您的解决方案中也将此源添加到您的 nuget.config。

    • 确保您的项目中没有安装任何以下依赖项以及其他参考

      <ItemGroup>
        <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.4" />
        <PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.4" />
        <PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.4" />
        <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="1.0.3" />
        <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
        <PackageReference Include="Microsoft.Net.Compilers" Version="1.3.2" />
        <PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
        <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
        <PackageReference Include="System.ComponentModel" Version="4.0.1" />
        <PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
        <PackageReference Include="System.Globalization" Version="4.0.11" />
        <PackageReference Include="System.Linq" Version="4.1.0" />
        <PackageReference Include="System.Linq.Expressions" Version="4.1.0" />
        <PackageReference Include="System.Reflection" Version="4.1.0" />
        <PackageReference Include="System.Resources.ResourceManager" Version="4.0.1" />
      </ItemGroup>
      

    来自栖息地项目repos

    【讨论】:

      猜你喜欢
      • 2015-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      相关资源
      最近更新 更多