Note that there are some explanatory texts on larger screens.

plurals
  1. POmySQL error with plugin loaded into appDomain
    text
    copied!<p>I am struggling to get dynamic loading working with my plugin. I'm loading the plugin into an appdomain but I get the following exception when my plugin tries to execute any mySQL code:</p> <blockquote> <p>MySql.Data.MySqlClient.MySqlException was unhandled<br> Message=Access denied for user ''@'localhost' (using password: NO)</p> </blockquote> <p>Here is the code on Plugins.cs:</p> <pre><code>public class Plugins { private static List&lt;PluginContainer&gt; PluginList; public static bool PluginsAreLoaded { get { if(PluginList==null) { return false; } else { return true; } } } public static void LoadAllPlugins(Form host) { //add assemblies in OD folder to appDomain Assembly[] list = AppDomain.CurrentDomain.GetAssemblies(); AppDomain appDomainAnesthesia AppDomain.CreateDomain("appDomainAnesthesia"); for(int i=0;i&lt;ProgramC.Listt.Count;i++) { string dllPathWithVersion = String.Empty; if(!ProgramC.Listt[i].Enabled) { continue; } if(ProgramC.Listt[i].PluginDllName=="") { continue; } string dllPath=ODFileUtils.CombinePaths(Application.StartupPath,ProgramC.Listt[i].PluginDllName); if(dllPath.Contains("[VersionMajMin]")) { Version vers=new Version(Application.ProductVersion); dllPathWithVersion=dllPath.Replace("[VersionMajMin]",vers.Major.ToString()+"."+vers.Minor.ToString()); dllPath=dllPath.Replace("[VersionMajMin]","");//now stripped clean if(File.Exists(dllPathWithVersion)){ File.Copy(dllPathWithVersion,dllPath,true); } } if(!File.Exists(dllPath)) { continue; } //add our plugin to the appDomain try { string typeName = Path.GetFileNameWithoutExtension(dllPath) + ".Plugin"; PluginBase plugin = (PluginBase)appDomainAnesthesia.CreateInstanceAndUnwrap(Path.GetFileNameWithoutExtension(dllPathWithVersion), typeName); appDomainAnesthesia.Load(Path.GetFileNameWithoutExtension(dllPathWithVersion)); plugin.Host=host; } catch(Exception ex) { MessageBox.Show(ex.Message); continue;//don't add it to plugin list. } PluginContainer container=new PluginContainer(); container.Plugin=plugin; container.ProgramNum=ProgramC.Listt[i].ProgramNum; PluginList.Add(container); } } </code></pre> <p>Here is PluginBase:</p> <pre><code>public abstract class PluginBase : MarshalByRefObject { private Form host; ///&lt;summary&gt;This will be a refrence to the main FormOpenDental so that it can be used by the plugin if needed. It is set once on startup, so it's a good place to put startup code.&lt;/summary&gt; public virtual Form Host { get { return host; } set { host=value; } } ///&lt;summary&gt;These types of hooks are designed to completely replace the existing functionality of specific methods. They always belong at the top of a method.&lt;/summary&gt; public virtual bool HookMethod(object sender,string methodName,params object[] parameters) { return false;//by default, no hooks are implemented. } ///&lt;summary&gt;These types of hooks allow adding extra code in at some point without disturbing the existing code.&lt;/summary&gt; public virtual bool HookAddCode(object sender,string hookName,params object[] parameters) { return false; } public virtual void LaunchToolbarButton(long patNum) { } </code></pre> <p>}</p> <p>PluginContainer:</p> <pre><code>class PluginContainer { public PluginBase Plugin; public long ProgramNum; </code></pre> <p>and finally, Plugin:</p> <pre><code>public class Plugin : PluginBase { private Form host; public AnestheticData AnesthDataCur; public AnestheticRecord AnestheticRecordCur; public Patient PatCur; public string SourceDirectory; public string DestDirectory; public System.ComponentModel.IContainer components; public long patNum; public static Procedure procCur; public static List&lt;Procedure&gt; ProcList; public static ODtextBox textNotes; public override Form Host { get { return host; } set { host=value; ConvertAnesthDatabase.Begin();//if this crashes, it will bubble up and result in the plugin not loading. } } </code></pre> <p>It bombs at the </p> <pre><code>plugin.Host=host; </code></pre> <p>line on <code>Plugins.cs</code> which comes from the ConverAnesthDatabase.Begin() method as there are multiple mySQL statements there.</p> <p>I have access to the mySQL database, so that is not the issue.</p> <p>How do I resolve this error? </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