I have added new property name "range" in searchBoxModel. I start my application then no bug comes but when i restart again then, following error comes. [MissingMethodException: Method not found: 'System.String Nop.Web.Models.Catalog.SearchBoxModel.get_Range()'].
SearchBoxModel code public string Name { get; set; } public int Range { get; set; }
Any answer to this problem? I'm having the same issue. I added a new property in HeaderLinksModel.cs first try viewing the page works fine but when I closed the browser and do it again without cleaning/building the entire projects the problem will show up.
Bump... Still having the same issue. Tried different solution by providing CustomProperties with new Dictionary, first debug session it went through but the second time it didn't pass through in HeaderLinks() action method! I guess I'm having the same issue.
We have the Same Issue in NOP 3.0. We have an New Property of type Dictionary and it works after first deployment. After a while (we think cache will expire) We receive also the Method not found exception.
If it works at first and then after a while it doesn't, check to make sure you don't have any Nop.Core/Data/Services DLLs in your Plugins folder. If it's an old version then the AppPool will reboot eventually and it loads those instead of the correct ones.
The reason seems to be ASP.Net and the way it loads assemblies from your application directory for the first time and after a recycle. On first start, the assemblies are loaded from your application's bin directory and after a recycle (or even an IIS restart) it loads the assemblies from the Temporary ASP.NET Files directory. And depending on the situation more or less assemblies are loaded.
Her our Workaround (Not Nice but Works) We load a new DLL in PreInitialize this will reload the Assemblies after Recygling:
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Threading; using System.Web; using System.Web.Compilation;
namespace Nop.Web { public static class Initializer { public static void BreakCache() { // start the assembly string tempFolder = System.Threading.Thread.GetDomain().BaseDirectory; var assemblyName = new AssemblyName { Name = "Cachebuster_" + DateTime.Now.ToString("yyyyMMddhhmmssfff") }; var filename = assemblyName.Name + ".dll"; var fullpath = tempFolder + @"\Plugins\" + filename;
// create our builders var asmBuilder = Thread.GetDomain() .DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave, tempFolder + @"\Plugins\"); var fakeModule = asmBuilder .DefineDynamicModule(assemblyName.Name, filename, true); var typeBuilder = fakeModule .DefineType(string.Format("WhoYaGonnaCall{0}", DateTime.Now.ToString("fff")), TypeAttributes.Public); var fakeMethod = typeBuilder .DefineMethod("Cachebusters", MethodAttributes.Public | MethodAttributes.Static);
// emit a minimum amount of IL var methodIL = fakeMethod.GetILGenerator(); methodIL.Emit(OpCodes.Ret);
// create the type and save the DLL typeBuilder.CreateType(); asmBuilder.Save(filename);
What we did in the live server not in my local IIS express is we set the recycling pool to 30 days to check if it's reverting back to the first old installation nop.web.dll, now the server is running fine but we still have to find a better solution for this one.