using CLI dll inside C# library that loaded dynamically

  .net-4.6.1, c++, legacy, reflection

i’m in middle of creating an app that use plugin architecture, the application written in c# (.Net framework 4.6.1) the app loading modules dynamically using reflection, as part of the plugins i have some legacy managed CPP module that i need to use in the plugins (compiled with vs2010 and can’t be upgraded), any time in trying to load it in the plugins and use it it throws Access violation exception, when im trying to load and use it out of the plugins (the exe that loading the plugins) it works perfectly.

the first and more important question is Why it works like that?

the second question is how to overcome this issue, the simplest workaround i found is to wrap it with singleton under the main executable project and use it and then it works, there is better why to approach this issue?

Thanks in advance!

Source: Windows Questions C++

LEAVE A COMMENT