ObjectForScriptingを介してWebBrowserControlと対話するWinFormがあります。WinFormの基本クラスはComVisibleではなく、変更できないか、変更しません。NonComVisibleBaseClassがあるため、インターフェイスを作成してComVisible(true)に設定し、FormAttribute [ClassInterface(ClassInterfaceType.None)]を設定しました。インターフェイスのメソッドはJavaScriptで呼び出すことができます。そしてそれは完璧に機能します:
//Make the class visible for COM so we can set the ObjectForScripting
//Specify ClassInterfaceType.None to use the ComVisible Interface
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public partial class GeekBrowser : GeekBasePage, IMapControlInteractable
...
public class GeekBasePage : System.Windows.Forms.Form
...
[ComVisible(true)]
public interface IMapControlInteractable
しかし今、私の問題。インターフェイスには複数の機能が含まれています。個別のタスクグループ化のためにインターフェイスを分離したい。そのため、ロギング関数を含むインターフェースと、DataAccess関数などのインターフェースが必要です。
したがって、次のようになります。
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public partial class GeekBrowser : GeekBasePage, IDataAccess, ILogging
...
public class GeekBasePage : System.Windows.Forms.Form
...
[ComVisible(true)]
public interface IDataAccess
...
[ComVisible(true)]
public interface ILogging
しかし、これを行うと、2番目のインターフェイス(ILogging)の機能にJavascriptからアクセスできなくなります。インターフェイスの順序を切り替えると、IDataAccess関数にアクセスできなくなります。
したがって、Javascriptでは最初のインターフェイスのメソッドにのみアクセスできる場合があります。
各インターフェイスのすべての機能にアクセスできるようにするにはどうすればよいですか?繰り返しになりますが、BaseClassをComVisibleにし、ClassInterface属性を削除することは機能しますが、オプションではありません。
前もって感謝します!!