Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I change the lookup path for .NET libraries referenced via #using in Managed C++?
    text
    copied!<p>I developed a DLL in Managed C++ which loads some plugins (implemented in any .NET language) at runtime using <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfile.aspx" rel="nofollow noreferrer">System.Reflection.Assembly.LoadFile</a>. The interface which is implemented by all plugins is implemented in C#. It's used by the Managed C++ code like this:</p> <pre><code>#using &lt;IMyPluginInterface.dll&gt; // Make the 'IMyPluginInterface' type available ref class PluginManager { List&lt;IMyPluginInterface ^&gt; ^m_plugins; // Load all plugins in a well-known directory. void load() { for ( string dllFile in Directory.GetFiles( .., "*.dll" ) ) { // Lookup the type of the plugin object using Reflection Type pluginType = ...; // Finally, instantiate the plugin and add it to our list. m_plugins.Add( (IMyPluginInterface ^)Activator.CreateInstance( pluginType ) ); } } } </code></pre> <p>Loading the plugins works well; the problem I'm facing is that at runtime, the <code>IMyPlugnInterface.dll</code> file might not be in the same directory as the Managed C++ DLL. This means that the 'IMyPluginInterface' type is not available at runtime, and an exception is thrown.</p> <p>I previously asked whether it was maybe possible to influence the lookup path used when resolving DLLs referenced via the <code>#using</code> statement. Unfortunately, this didn't yield any result.</p> <p>Is there maybe a different approach to this? Can types which are referenced via <code>#using</code> be compiled into the Managed C++ DLL? Maybe anybody else has an entirely different solution?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload