简体   繁体   中英

DotVVM. System.IO.FileNotFoundException Microsoft.Cloud.Monitoring.UsageCounters.dll

I'm trying to connect DotVVM to migrate the application to net core. When I try to open a simple web page, I get an error.

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". This is the only link. Library "Microsoft.ApplicationServer.Caching.Server.dll " included in the application "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.

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.

just in case, I attach the contents of the test pages.

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

@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

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

    public override string Title => "TestPage"; 
} 
     

SiteViewModel.cs

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

Startup.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

<?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

<?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.

Solution

config.ExperimentalFeatures.ExplicitAssemblyLoading.Enabled = true;

Source of information 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);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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