Alachisoft / NCache

NCache: Highly Scalable Distributed Cache for .NET
http://www.alachisoft.com
Apache License 2.0
647 stars 123 forks source link

Configuration Error #28

Open ShirishPatel opened 6 years ago

ShirishPatel commented 6 years ago

Just installed Install-Package Alachisoft.NCache.SDK -Version 4.9.1

And followed all the steps mentioned here http://www.alachisoft.com/resources/docs/ncache/prog-guide/content-optimization-ncache.html

Could not load file or assembly 'Alachisoft.NCache.Adapters, Version=4.9.1.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096' or one of its dependencies. The system cannot find the file specified.

Please help, currently I am using ViewStateOptimizer 1.0.2 but the disadvantage is it is storing on disk and I want to limit I/O and make use of Memory as the server I am using has 288GB RAM out of which I am just using 20GB.

ShirishPatel commented 6 years ago

Could not load file or assembly 'Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096' or one of its dependencies. The system cannot find the file specified.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096' could not be loaded.

=== Pre-bind state information === LOG: DisplayName = Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096 (Fully-specified) LOG: Appbase = file:///C:/Users/ShirishPatel/Downloads/NCache-master/NCache-master/Samples/dotnet/ViewState/Src/ LOG: Initial PrivatePath = C:\Users\ShirishPatel\Downloads\NCache-master\NCache-master\Samples\dotnet\ViewState\Src\bin Calling assembly : Alachisoft.NCache.Adapters, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\ShirishPatel\Downloads\NCache-master\NCache-master\Samples\dotnet\ViewState\Src\web.config LOG: Using host configuration file: C:\Users\ShirishPatel\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096 LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/AppData/Local/Temp/Temporary ASP.NET Files/vs/9498099a/b876aef9/Alachisoft.NCache.Common.DLL. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/AppData/Local/Temp/Temporary ASP.NET Files/vs/9498099a/b876aef9/Alachisoft.NCache.Common/Alachisoft.NCache.Common.DLL. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/Downloads/NCache-master/NCache-master/Samples/dotnet/ViewState/Src/bin/Alachisoft.NCache.Common.DLL. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/Downloads/NCache-master/NCache-master/Samples/dotnet/ViewState/Src/bin/Alachisoft.NCache.Common/Alachisoft.NCache.Common.DLL. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/AppData/Local/Temp/Temporary ASP.NET Files/vs/9498099a/b876aef9/Alachisoft.NCache.Common.EXE. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/AppData/Local/Temp/Temporary ASP.NET Files/vs/9498099a/b876aef9/Alachisoft.NCache.Common/Alachisoft.NCache.Common.EXE. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/Downloads/NCache-master/NCache-master/Samples/dotnet/ViewState/Src/bin/Alachisoft.NCache.Common.EXE. LOG: Attempting download of new URL file:///C:/Users/ShirishPatel/Downloads/NCache-master/NCache-master/Samples/dotnet/ViewState/Src/bin/Alachisoft.NCache.Common/Alachisoft.NCache.Common.EXE.

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096' or one of its dependencies. The system cannot find the file specified.] System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr typeInstArgs, Int32 typeInstCount, IntPtr methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +145 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +130 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +91 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +418 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType) +106 System.Reflection.RuntimePropertyInfo.GetCustomAttributes(Type attributeType, Boolean inherit) +64 System.Attribute.InternalGetCustomAttributes(PropertyInfo element, Type type, Boolean inherit) +35 System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit) +134 System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit) +14 System.Configuration.ConfigurationElement.CreateConfigurationPropertyFromAttributes(PropertyInfo propertyInformation) +35 System.Configuration.ConfigurationElement.CreatePropertyBagFromType(Type type) +191 System.Configuration.ConfigurationElement.PropertiesFromType(Type type, ConfigurationPropertyCollection& result) +218 System.Configuration.ConfigurationElement.CreateConfigurationPropertyFromAttributes(PropertyInfo propertyInformation) +108 System.Configuration.ConfigurationElement.CreatePropertyBagFromType(Type type) +191 System.Configuration.ConfigurationElement.PropertiesFromType(Type type, ConfigurationPropertyCollection& result) +218 System.Configuration.ConfigurationElement.get_Properties() +33 System.Configuration.ConfigurationElement.Reset(ConfigurationElement parentElement) +47 System.Configuration.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, SectionInput sectionInput, Object parentConfig, ConfigXmlReader reader) +145 System.Configuration.RuntimeConfigurationFactory.CreateSectionWithFullTrust(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, SectionInput sectionInput, Object parentConfig, ConfigXmlReader reader) +51 System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, SectionInput sectionInput, Object parentConfig, ConfigXmlReader reader) +73 System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, SectionInput sectionInput, Object parentConfig, ConfigXmlReader reader) +92

[ConfigurationErrorsException: An error occurred creating the configuration section handler for ncContentOptimization/settings: Could not load file or assembly 'Alachisoft.NCache.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=1448e8d1123e9096' or one of its dependencies. The system cannot find the file specified.] System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, SectionInput sectionInput, Object parentConfig, ConfigXmlReader reader) +289 System.Configuration.BaseConfigurationRecord.CreateSectionDefault(String configKey, Boolean getRuntimeObject, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object& result, Object& resultRuntimeObject) +50 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1503 System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +41 System.Web.HttpContext.GetSection(String sectionName) +52 System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName) +56 System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) +11 System.Configuration.ConfigurationManager.GetSection(String sectionName) +79 Alachisoft.NCache.ContentOptimization.Configurations.ConfigurationProvider..cctor() +33

[TypeInitializationException: The type initializer for 'Alachisoft.NCache.ContentOptimization.Configurations.ConfigurationProvider' threw an exception.] Alachisoft.NCache.ContentOptimization.Configurations.ConfigurationProvider.get_Settings() +0 Alachisoft.NCache.Adapters.PageAdapter..cctor() +106

[TypeInitializationException: The type initializer for 'Alachisoft.NCache.Adapters.PageAdapter' threw an exception.] Alachisoft.NCache.Adapters.PageAdapter..ctor() +0 T_a065bf2b_ff71_47c3_8e7d_57483033d6c2.CreateInstance() +49 System.Web.Configuration.HttpCapabilitiesBase.GetAdapter(Control control) +9874903 System.Web.UI.Control.ResolveAdapter() +101 System.Web.UI.Page.get_PageAdapter() +22 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +108

ShirishPatel commented 6 years ago

Sample is also giving error NCache-master\NCache-master\Samples\dotnet\ViewState

Ollie-NCache commented 5 years ago

Hello Shirish,

I have looked at your issue and have found out the root cause. The problem is that the Alachisoft.NCache.SDK nuget package does not have some assemblies needed for the view state caching feature to run. There are some dependent assemblies that need to be copied in your project bin folder in order to avoid this issue. There are various ways to obtain those assemblies:

1- Install NCache v4.9 SP1 Enterprise edition and select the "Developer" mode when prompted by the installation wizard. This mode does not require a license and completely free. After you have installed it, you will find the required assemblies at %NCHOME%/NCache/Integrations/ContentOptimization, copy them to your application bin folder. Note that %NCHOME% is the path where NCache is installed.

2- Another option could be that you follow the link

https://github.com/Alachisoft/NCache/tree/master/Integration/ViewStateCaching

and download the solution, compile it and find the required assemblies in the bin/Debug folder.

3- You can also find the assemblies attached in the github reply to your query which I have copied from NCache Enterprise installation.

Once those assemblies have been referenced in your project, double check that your web.config file is set with the following directives properly placed as instructed in the Alachisoft documentation (Link: http://www.alachisoft.com/resources/docs/ncache/prog-guide/content-optimization-ncache.html):

<add assembly="Alachisoft.NCache.Adapters, Version=4.9.0.0, Culture=neutral, PublicKeyToken=CFF5926ED6A53769" />
 <add assembly="Alachisoft.Common, Version=4.9.0.0, Culture=neutral, PublicKeyToken=CFF5926ED6A53769" />
 <add assembly="Alachisoft.ContentOptimization, Version=4.9.0.0, Culture=neutral, PublicKeyToken=CFF5926ED6A53769" />

A working sample is also attached in this thread.

Please let me know if you have any further questions.

Assemblies.zip WorkingSample.zip