Access error Nop.Plugin.DiscountRules.BillingCountry.dll

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 năm cách đây
I have one thought. Can you please try the following steps?

1. Open web.config file
2. Find and remove the following line of code:
<probing privatePath="Plugins/bin/" />


Please let me know if the site works fine now
12 năm cách đây
a.m. wrote:
I have one thought. Can you please try to following?

1. Open web.config file
2. Find and remove the following line of code:
<probing privatePath="Plugins/bin/" />


Please let me know if the site works fine now


I tried changing that and I got the following error:

Could not load file or assembly 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.
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 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.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 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
   System.Reflection.Assembly.Load(AssemblyName assemblyRef) +30
   Nop.Core.Plugins.PluginManager.PerformFileDeploy(FileInfo plug) in PluginManager.cs:301
   Nop.Core.Plugins.PluginManager.Initialize() in PluginManager.cs:114

[Exception: Could not load file or assembly 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.
]
   Nop.Core.Plugins.PluginManager.Initialize() in PluginManager.cs:163

[InvalidOperationException: The pre-application start initialization method Initialize on type Nop.Core.Plugins.PluginManager threw an exception with the following error message: Could not load file or assembly 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.
.]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591

[HttpException (0x80004005): The pre-application start initialization method Initialize on type Nop.Core.Plugins.PluginManager threw an exception with the following error message: Could not load file or assembly 'Nop.Plugin.DiscountRules.BillingCountry, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The network name cannot be found.
.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9013676
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
12 năm cách đây
I gave up on GoDaddy and ended up moving to Arvixe.  I haven't (knock on wood) had any issues since.
Fast and no access denied (plugins) issues


I will be downloading and installing 2.20 this weekend so we will see.


Tom
12 năm cách đây
Is there any news on this issue because I can't move my hosting to another company and its definitaly caused by an issue with hosting companies that use data cloud servers.
12 năm cách đây
I have not scanned the whole thread, but the topic matched my problem.

What I did was to manually create a bin folder since it was missing (Plugins/bin) and then I copied the Nop.Plugin.DiscountRules.BillingCountry and Nop.Plugin.DiscountRules.BillingCountry from the Nop.Web/Plugins/DiscountRules.BillingCountry to the Plugins/bin folder and added write permissions to the bin folder and now I get to the Installation page.
12 năm cách đây
Is there code that is copying or compiling the DLLs?  If so which file?  Or is IIS removing these DLLs?
12 năm cách đây
The problem is in the Nop.Core.Plugins.PluginManager.

The application clears the Plugins/bin folder every time the ASP.NET app starts.  Godaddy probably has IIS set to restart the application when the app pool is recycled.  They mention on the IIS management screen that they automatically recycle the app pool frequently.

When the application is restarted, the Nop.Core.Plugins.PluginManager::Initialize function is called because of the [assembly: PreApplicationStartMethod(typeof(PluginManager), "Initialize")] attribute.  This needs to happen because the PluginManager loads the DLL assemblies.  Unfortunately with hosting companies, you don't have control over the configuration of the hardware.

The Problem
The Nop.Core.Plugins.PluginManager::Initialize function deletes all of the DLLs in the Plugins/bin folder because it figures the application is being started and won't be restarted frequently.  This is what is causing the access denied errors and the could not be found errors.

Solution
Delete or comment out the following code in Nop.Core.Plugins.PluginManager::Initialize
   //clear out shadow copied plugins
   foreach (var f in binFiles)
   {
       Debug.WriteLine("Deleting " + f.Name);
       try
      {
           File.Delete(f.FullName);
      }
      catch (Exception exc)
      {
          Debug.WriteLine("Error deleting file " + f.Name + ". Exception: " + exc);
      }
    }

And modify the code in Nop.Core.Plugins.PluginManager::InitializeMediumTrust function.
1. Change if (shadowCopiedPlug.CreationTimeUtc.Ticks == plug.CreationTimeUtc.Ticks)
    to if (shadowCopiedPlug.CreationTimeUtc.Ticks >= plug.CreationTimeUtc.Ticks)
    == to >= since we only want the newest DLL.
2. Add else
          {
               Debug.WriteLine("New Plugin found; Deleteing old fild from Plugins/bin: '{0}'", shadowCopiedPlug.Name);
               File.Delete(shadowCopiedPlug.FullName);
          }


to look like this.
   if (shadowCopiedPlug.Exists)
   {
        if (shadowCopiedPlug.CreationTimeUtc.Ticks >= plug.CreationTimeUtc.Ticks)
        {
               Debug.WriteLine("Not copying; files appear identical: '{0}'", shadowCopiedPlug.Name);
               shouldCopy = false;
        }
        else
        {
               Debug.WriteLine("New Plugin found; Deleteing old fild from Plugins/bin: '{0}'", shadowCopiedPlug.Name);
               File.Delete(shadowCopiedPlug.FullName);
        }

    }

The above will only delete the DLLs that are new so that when the DLLs are copied, there is no way for it to cause an access denied error.

NOTE: For new installations you may still get errors, but you should be able to recycle the application pool.  I haven't tried the above code on a new installation.  If you do get errors, you should be able to manually copy the DLLs into the Plugins/bin folder as a work around, but I am guessing that the errors would be minimized and not occur frequently.  This may also speed up the initialization a touch.
12 năm cách đây
NeffreyC wrote:
Solution...

Thanks a lot for investigating it! I've just merged this change in the official branch. Now it should work fine.
12 năm cách đây
How do I download the fix for this?
12 năm cách đây
cheatcountry wrote:
How do I download the fix for this?

Please get the latest version here or simply apply the changes (some developer skills are required) proposed by NeffreyC
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.