私はactiveXコントロールを作成しましたが、Internet Explorerに展開する際に問題が発生しています。ブラウザ(IE 11)はActiveXコントロールをダウンロードできません。何が間違っているのか、どのコードがうまく機能していないのかわかりません。私は.net 2010、フレームワーク4.0を使用していますc#.net windowsフォームでのActiveXコントロールの作成方法と展開方法
これは私が試みたコードです。
[ProgId("Newcomp.UserControl1")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("5FE8E181-7D6D-4CE2-AB83-BAEB9906EF48")]
[ComVisible(true)]
public partial class UserControl1: UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.BackColor = Color.YellowGreen;
}
///
/// Register the class as a control and set it's CodeBase entry
///
/// The registry key of the control
[ComRegisterFunction()]
public static void RegisterClass(string key)
{
// Strip off HKEY_CLASSES_ROOT\ from the passed key as I don't need it
StringBuilder sb = new StringBuilder;
sb.Replace(@"HKEY_CLASSES_ROOT\", "");
// Open the CLSID\{guid} key for write access
RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(), true);
// And create the 'Control' key - this allows it to show up in
// the ActiveX control container
RegistryKey ctrl = k.CreateSubKey("Control");
ctrl.Close();
// Next create the CodeBase entry - needed if not string named and GACced.
RegistryKey inprocServer32 = k.OpenSubKey("InprocServer32", true);
inprocServer32.SetValue("CodeBase", Assembly.GetExecutingAssembly().CodeBase);
inprocServer32.Close();
// Finally close the main key
k.Close();
}
///
/// Called to unregister the control
///
/// Tke registry key
[ComUnregisterFunction()]
public static void UnregisterClass(string key)
{
StringBuilder sb = new StringBuilder;
sb.Replace(@"HKEY_CLASSES_ROOT\", "");
// Open HKCR\CLSID\{guid} for write access
RegistryKey k = Registry.ClassesRoot.OpenSubKey(sb.ToString(), true);
// Delete the 'Control' key, but don't throw an exception if it does not exist
k.DeleteSubKey("Control", false);
// Next open up InprocServer32
RegistryKey inprocServer32 = k.OpenSubKey("InprocServer32", true);
// And delete the CodeBase key, again not throwing if missing
k.DeleteSubKey("CodeBase", false);
// Finally close the main key
k.Close();
}
}
は、私はあなたが経験している問題は、デフォルトでは、IE10(以降は)その中には、Active Xコントロールを実行します/あなたがダウンロードさせません、という事実によって引き起こされるthis
これはあなたの質問に答えるのに役立つと思います。 http://stackoverflow.com/questions/26151999/ie11-prevents-activex-from-running – DaniDev
また、残念ながら、あなたが従った例は2011年となっており、IE11の制限は予期していません。 – DaniDev
@DaniDev - IE11で動作させるためにinorderで参照できる他のドキュメントはありますか? –