我目前正在开发一个 Internet Explorer BHO,它使用 Add-In Express (www.add-in-express.com) .NET 库在 VB.NET 中编写并以 .NET Framework 2.0 为目标。浏览器插件通过 InnoSetup 5 安装程序安装到用户的 AppData/Local 目录,该安装程序也处理插件的注册。
安装后,InnoSetup 安装程序是 UAC 提升的,这是向浏览器注册 BHO 的可执行文件(由 Add-In Express 提供)所必需的。
我必须指出,我的 .NET 经验充其量是最少的——我知道足以编写应用程序,但对操作系统如何处理应用程序一无所知——我会尽量将这个问题描述为我可以。
我的插件使用的一个功能是 Visual Studio 的用户设置(通过 VS 中的属性->设置部分)。在原始开发机器上的 IE 中调试插件时,一切都按预期工作。
将插件安装到新机器时,每当我的应用程序尝试调用 My.Settings.Save() 时,我都会收到异常。我一直在努力在网上为同样的问题找到任何其他相同的场景。请在下面找到堆栈跟踪:
Exception Source: mscorlib
Exception Type: System.InvalidOperationException
Exception Message: Method failed with unexpected error code 3.
Exception Target Site: CreateInternal
---- Stack Trace ----
System.Security.AccessControl.NativeObjectSecurity.CreateInternal(resourceType As ResourceType, isContainer As Boolean, name As String, handle As SafeHandle, includeSections As AccessControlSections, createByName As Boolean, exceptionFromErrorCode As ExceptionFromErrorCode, exceptionContext As Object)
mscorlib.dll: N 0306 (0x132) IL
System.Security.AccessControl.FileSystemSecurity..ctor(isContainer As Boolean, name As String, includeSections As AccessControlSections, isDirectory As Boolean)
mscorlib.dll: N 0017 (0x11) IL
System.Security.AccessControl.FileSecurity..ctor(fileName As String, includeSections As AccessControlSections)
mscorlib.dll: N 0000 (0x0) IL
System.Configuration.Internal.WriteFileContext.DuplicateTemplateAttributes(source As String, destination As String)
mscorlib.dll: N 0008 (0x8) IL
System.Configuration.Internal.WriteFileContext.DuplicateFileAttributes(source As String, destination As String)
mscorlib.dll: N 0028 (0x1C) IL
System.Configuration.Internal.WriteFileContext.Complete(filename As String, success As Boolean)
mscorlib.dll: N 0018 (0x12) IL
System.Configuration.Internal.InternalConfigHost.StaticWriteCompleted(streamName As String, success As Boolean, writeContext As Object, assertPermissions As Boolean)
mscorlib.dll: N 0070 (0x46) IL
System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.WriteCompleted(streamName As String, success As Boolean, writeContext As Object, assertPermissions As Boolean)
mscorlib.dll: N 0000 (0x0) IL
System.Configuration.Internal.DelegatingConfigHost.WriteCompleted(streamName As String, success As Boolean, writeContext As Object, assertPermissions As Boolean)
mscorlib.dll: N 0000 (0x0) IL
System.Configuration.ClientSettingsConfigurationHost.WriteCompleted(streamName As String, success As Boolean, writeContext As Object)
mscorlib.dll: N 0019 (0x13) IL
System.Configuration.UpdateConfigHost.WriteCompleted(streamName As String, success As Boolean, writeContext As Object)
mscorlib.dll: N 0036 (0x24) IL
System.Configuration.MgmtConfigurationRecord.SaveAs(filename As String, saveMode As ConfigurationSaveMode, forceUpdateAll As Boolean)
mscorlib.dll: N 0793 (0x319) IL
System.Configuration.Configuration.SaveAsImpl(filename As String, saveMode As ConfigurationSaveMode, forceSaveAll As Boolean)
mscorlib.dll: N 0036 (0x24) IL
System.Configuration.Configuration.Save()
mscorlib.dll: N 0000 (0x0) IL
System.Configuration.ClientSettingsStore.WriteSettings(sectionName As String, isRoaming As Boolean, newSettings As IDictionary)
mscorlib.dll: N 0219 (0xDB) IL
System.Configuration.LocalFileSettingsProvider.SetPropertyValues(context As SettingsContext, values As SettingsPropertyValueCollection)
mscorlib.dll: N 0219 (0xDB) IL
System.Configuration.SettingsBase.SaveCore()
mscorlib.dll: N 0154 (0x9A) IL
System.Configuration.SettingsBase.Save()
mscorlib.dll: N 0016 (0x10) IL
System.Configuration.ApplicationSettingsBase.Save()
mscorlib.dll: N 0023 (0x17) IL
FindAndRemind.User.DetectUser()
mscorlib.dll: N 0042 (0x2A) IL
FindAndRemind.IEModule.IEModule_DownloadComplete()
mscorlib.dll: N 0151 (0x97) IL
AddinExpress.IE.ADXIEModule.DoDownloadComplete()
mscorlib.dll: N 0010 (0xA) IL
在搜索 User/AppData 目录后,我可以看到没有为组织名称创建文件夹。我还读到 user.config 文件可以由 Internet Explorer 本身在 Microsoft_Corporation 文件夹下创建,尽管这也是空的。在我看来,这是一个权限问题,但由于我缺乏为 Windows 编写应用程序的经验,我不知所措。
以前有没有人遇到过这个问题,如果有,您是如何解决的?
提前致谢!
编辑:
我还应该指出,可以关闭异常并且应用程序可以继续运行,但是没有保存任何设置数据,这使得我的插件在本质上有点多余。
编辑2:
不幸的是,不能在管理员模式下运行 Internet Explorer,因为该插件是对当前拥有 20,000 多个用户群的旧版本的更新。我们的用户涵盖了一系列技能水平,并且加载项应该在多个操作系统和用户设置中“按原样”工作。