简体   繁体   English

点VVM。 System.IO.FileNotFoundException Microsoft.Cloud.Monitoring.UsageCounters.dll

[英]DotVVM. System.IO.FileNotFoundException Microsoft.Cloud.Monitoring.UsageCounters.dll

I'm trying to connect DotVVM to migrate the application to net core.我正在尝试连接 DotVVM 以将应用程序迁移到网络核心。 When I try to open a simple web page, I get an error.当我尝试打开一个简单的 web 页面时,出现错误。

Error in Dotvvm Application:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Cloud.Monitoring.UsageCounters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Cloud.Monitoring.UsageCounters, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at DotVVM.Framework.Compilation.ControlTree.DefaultControlResolver.<>c.<InvokeStaticConstructorsOnAllControls>b__4_7(AssemblyName an)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at DotVVM.Framework.Utils.FunctionalExtensions.<SelectRecursively>d__8`1.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__59`1.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at DotVVM.Framework.Compilation.ControlTree.DefaultControlResolver.InvokeStaticConstructorsOnAllControls()
   at DotVVM.Framework.Compilation.ControlTree.DefaultControlResolver..ctor(DotvvmMarkupConfiguration configuration, IControlBuilderFactory controlBuilderFactory)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ScopedCallSite.Invoke(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at DotVVM.Framework.Compilation.DefaultControlBuilderFactory.CreateControlBuilder(MarkupFile file)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at DotVVM.Framework.Runtime.DefaultDotvvmViewBuilder.BuildView(IDotvvmRequestContext context)
   at DotVVM.Framework.Hosting.DotvvmPresenter.<ProcessRequestCore>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DotVVM.Framework.Hosting.DotvvmPresenter.<ProcessRequest>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DotVVM.Framework.Hosting.Middlewares.DotvvmRoutingMiddleware.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at DotVVM.Framework.Hosting.Middlewares.DotvvmRoutingMiddleware.<Handle>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at DotVVM.Framework.Hosting.DotvvmMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DotVVM.Framework.Hosting.Middlewares.DotvvmErrorPageMiddleware.<Invoke>d__5.MoveNext()

I searched through all the libraries and found that the library "Microsoft.ApplicationServer.Caching.Server.dll " refers to "Microsoft.Cloud.Monitoring.UsageCounters.dll".我搜索了所有库,发现库“Microsoft.ApplicationServer.Caching.Server.dll”指的是“Microsoft.Cloud.Monitoring.UsageCounters.dll”。 This is the only link.这是唯一的链接。 Library "Microsoft.ApplicationServer.Caching.Server.dll " included in the application "AppFabric 1.1 for Windows Server".库“Microsoft.ApplicationServer.Caching.Server.dll”包含在应用程序“AppFabric 1.1 for Windows Server”中。 I can't give up "AppFabric 1.1 for Windows Server" yet, since there is a dependency on SharePoint.我还不能放弃“Windows 服务器的 AppFabric 1.1”,因为它依赖于 SharePoint。

I ask for help to sort out the error.我请求帮助以解决错误。 Microsoft library.ApplicationServer.Caching.Server.dll I can't find it on the Internet to check whether it will work with it. Microsoft library.ApplicationServer.Caching.Server.dll 我在互联网上找不到它来检查它是否可以使用它。

just in case, I attach the contents of the test pages.以防万一,我附上了测试页的内容。

DotvvmStartup.cs DotvvmStartup.cs

public class DotvvmStartup : IDotvvmStartup, IDotvvmServiceConfigurator
{
    public void Configure(DotvvmConfiguration config, string applicationPath)
    {
        config.Debug = true;
        config.AllowBindingDebugging = true;
        ConfigureRoutes(config, applicationPath);
        ConfigureControls(config, applicationPath);
        ConfigureResources(config, applicationPath);
    }

    private void ConfigureRoutes(DotvvmConfiguration config, string applicationPath)
        {
        config.RouteTable.Add("FieldEdit2", "FieldEdit2", "FieldEdit2.dothtml");
        config.RouteTable.Add("FieldEdit", "", "FieldEdit2.dothtml");
    }

    private void ConfigureControls(DotvvmConfiguration config, string applicationPath)
    {
    }

    private void ConfigureResources(DotvvmConfiguration config, string applicationPath)
    {
    }

    public void ConfigureServices(IDotvvmServiceCollection options)
    {
        options.AddDefaultTempStorages("Temp");
    }
}

FieldEdit2.dothtml FieldEdit2.dothtml

@viewModel WSSC.V4.SYS.DBFramework.DotVVMCustom.FieldEditViewModel,WSSC.V4.SYS.DBFramework
@masterPage Site.dotmaster
 
<dot:Content ContentPlaceHolderID="MainContent">
    <h2>{{value: Title}}.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p> 
</dot:Content>
 

FieldEditViewModel.cs FieldEditViewModel.cs

public class FieldEditViewModel : SiteViewModel
{
    public FieldEditViewModel()
    {
       
    }

    public override string Title => "TestPage"; 
} 
     

SiteViewModel.cs站点视图模型.cs

public abstract class SiteViewModel : DotvvmViewModelBase
{
    public abstract string Title { get; }
}

Startup.cs启动.cs

[assembly: OwinStartup(typeof(WSSC.V4.SYS.DBFramework.DotVVMCustom.Startup))]
namespace WSSC.V4.SYS.DBFramework.DotVVMCustom
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {   
            app.UseDotVVM<DotvvmStartup>(HostingEnvironment.ApplicationPhysicalPath);
        }
    }
}

Web.config Web.config

<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on how to configure your ASP.NET application, please visit https://go.microsoft.com/fwlink/?LinkId=169433  -->
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.7.2"/>
        <httpRuntime targetFramework="4.7.2"/>
    </system.web>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f"/>
                <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
                <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    <appSettings>
        <add key="owin:appStartup" value="WSSC.V4.SYS.DBFramework.DotVVMCustom.Startup,WSSC.V4.SYS.DBFramework,Version=4.0.0.0,Culture=neutral,PublicKeyToken=9f4da00116c38ec5"/>

    </appSettings>
    <system.codedom>
        <compilers>
        </compilers>
    </system.codedom>

    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

packages.config包.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Antlr" version="3.5.0.2" targetFramework="net472"/>
    <package id="Ben.Demystifier" version="0.1.0" targetFramework="net472"/>
    <package id="bootstrap" version="3.4.1" targetFramework="net472"/>
    <package id="DotVVM" version="2.2.0.2" targetFramework="net472"/>
    <package id="DotVVM.Core" version="2.2.0.2" targetFramework="net472"/>
    <package id="DotVVM.Owin" version="2.2.0.2" targetFramework="net472"/>
    <package id="EntityFramework" version="6.0.0" targetFramework="net472"/>
    <package id="jQuery" version="3.3.1" targetFramework="net472"/>
    <package id="Microsoft.CodeAnalysis.Analyzers" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.CodeAnalysis.Common" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.CodeAnalysis.CSharp" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="3.6.0" targetFramework="net472"/>
    <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.Extensions.Options" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.Extensions.Primitives" version="1.0.0" targetFramework="net472"/>
    <package id="Microsoft.Owin" version="3.0.1" targetFramework="net472"/>
    <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net472"/>
    <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net472"/>
    <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net472"/>
    <package id="Owin" version="1.0" targetFramework="net472"/>
    <package id="System.Collections" version="4.0.11" targetFramework="net472"/>
    <package id="System.Collections.Concurrent" version="4.0.12" targetFramework="net472"/>
    <package id="System.Collections.Immutable" version="1.4.0" targetFramework="net472"/>
    <package id="System.ComponentModel" version="4.0.1" targetFramework="net472"/>
    <package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net472"/>
    <package id="System.Globalization" version="4.0.11" targetFramework="net472"/>
    <package id="System.Linq" version="4.1.0" targetFramework="net472"/>
    <package id="System.Linq.Expressions" version="4.1.0" targetFramework="net472"/>
    <package id="System.Reflection" version="4.1.0" targetFramework="net472"/>
    <package id="System.Reflection.Metadata" version="1.5.0" targetFramework="net472"/>
    <package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net472"/>
    <package id="System.Runtime" version="4.1.0" targetFramework="net472"/>
    <package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net472"/>
    <package id="System.Threading" version="4.0.11" targetFramework="net472"/>
    <package id="System.Threading.Tasks" version="4.0.11" targetFramework="net472"/>
    <package id="System.ValueTuple" version="4.4.0" targetFramework="net472"/>
</packages>

The error occurs because DotVVM tries to reflexively call static constructors of all types.发生该错误是因为 DotVVM 尝试反身调用所有类型的 static 构造函数。

Solution解决方案

config.ExperimentalFeatures.ExplicitAssemblyLoading.Enabled = true; config.ExperimentalFeatures.ExplicitAssemblyLoading.Enabled = true;

Source of information https://gitter.im/riganti/dotvvm?at=5f0b4e5b7a4e99049e07ca51信息来源https://gitter.im/riganti/dotvvm?at=5f0b4e5b7a4e99049e07ca51

Example例子

public class DotvvmStartup : IDotvvmStartup, IDotvvmServiceConfigurator
{
    public void Configure(DotvvmConfiguration config, string applicationPath)
    {
        config.ExperimentalFeatures.ExplicitAssemblyLoading.Enabled = true;
        config.Debug = true;
        config.AllowBindingDebugging = true;
        ConfigureRoutes(config, applicationPath);
        ConfigureControls(config, applicationPath);
        ConfigureResources(config, applicationPath);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM