System.Exception: 'A plugin with 'DiscountRequirement.MustBeAssignedToCustomerRole' system name is already defined

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
nopCommerce v4.20

Decided to start my own thread for this problem I've been working on for a week.

I am constantly getting these errors (sometimes).  Meaning, I can build and debug several times and then randomly this error pops up.   When it does, the only way to fix it is the delete the presentation/plugins folder contents.

Things I know:

* It's intermittent.  

* The plugin named in the error changes.  It's not always "DiscountRequirement..."

* I am not doing any work on any of these reported plugins.  I am developing my  own plugin and only making changes to that project.  

* I understand that the system name in the plugin.json file must be unique for every plugin.  I have verified my plugin has a unique system name that is not anything close to the other plugin names.

* I have not touched the build location for anything except my own plugin - and I have verified it is correct.

* I don't know if this happens in a release version as I am only debugging at this point.

* I have tried deleting the entire nopCommerce folder and restoring from the original source zip and that doesn't help.

So....why is it doing this?   If it's something I'm doing wrong, why is it never *MY* plugin that is reported as a duplicate - it's always some other plugin I'm not even touching?   And why is it always a *DIFFERENT* other plugin being reported?

Is there something in the database I can look at to gain deeper understanding of the cause?  Or are plugins dealt with at startup based solely on the folder contents?

Finally, if nobody knows - is there a why I can just modify the build to just blast the presentation/plugins folder EVERY TIME I rebuild?   In theory, that should solve the problem (well, not solve the problem but solve the symptom which is all I really care about)
4 years ago
lots of suggestions here (same symptoms):
https://www.nopcommerce.com/boards/topic/72937/help-systemexception-a-plugin-with-sevenspikesnoppluginscategoriesheadermenu-system-name-is-already-

linked from that thread:
https://github.com/nopSolutions/nopCommerce/commit/7b9f8f0fb6178c40b92167ebdaa049a21a47b1ee
4 years ago
solved it!    

fyi: the fix was this....
https://github.com/nopSolutions/nopCommerce/commit/7b9f8f0fb6178c40b92167ebdaa049a21a47b1ee

not only solved my "plugin already defined" problem, but also the random "could not copy file" compiler errors that used to mysteriously come and go.

thanks for steering me there
4 years ago
I run into a similar problem last time when I was developing a plugin.
1) On looking at the problem I found out that the problematic plugin's dll was included inside the build version of other plugins too(DiscountRequirement.MustBeAssignedToCustomerRole in your case) .|
2) It can happen because  "ClearPluginAssemblies.dll" inside the build directory is missing or it is not functioning it should have during the project build.
3) In my case, it was there but it was not functioning as required because I had .net core 3.1 installed and NopCommerce even though used 2.2, visual studio automatically targeted the latest version which was 3.1. So I created a global.json file in the root directory and specifically instructed the vs to target the 2.2's version which was installed on my device. The problem was solved once I added the global.json file.

{
  "sdk": {
    "version": "2.2.300"
  }
}
4 years ago
Figmo wrote:
solved it!


nice work!  this problem comes up a lot so hopefully this will help others too
3 years ago
Thank @af1racing

the github post helps me right away.
2 years ago
motoTed wrote:

Thanks for GitHub link which solve my problem easily.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.