سؤال

I am currently working on an Internet Explorer BHO which has been written in VB.NET using the Add-In Express (www.add-in-express.com) .NET library and targets .NET Framework 2.0. The browser add-on is installed to the user's AppData/Local directory via an InnoSetup 5 installer which also handles the registration of the add-on.

Upon installation, the InnoSetup installer is UAC elevated which is required by the executable (provided by Add-In Express) that registers the BHO with the browser.

I must point out that my .NET experience is minimal at best - I know enough to code the app, but don't really have any knowledge of how the operating system deals with applications - I'll try to describe the issue as best as I can.

One feature my add-on makes use of is Visual Studio's User Settings (via the Properties->Settings section in VS). When debugging the add-on in IE on the original development machine everything works as expected.

When installing the add-on to a new machine, I receive an exception whenever my app tries to call My.Settings.Save(). I've been struggling to find any other identical scenarios on the web for this same problem. Please find the stack trace below:

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

Upon searching the User/AppData directory, I can see that there has been no folder created for the organisation name. I've also read that the user.config file could be created by Internet Explorer itself under the Microsoft_Corporation folder, although this too is empty. It seems to me that this is a permissions issue, but I'm at a loss due to my lack of experience in coding applications for Windows.

Has anyone every come across this issue before, and if so, how did you resolve it?

Thanks in advance!

EDIT:

I should also point out that the exception can be closed and the app can continue running, however no settings data is ever saved making my add-on a little redundant in nature.

EDIT 2:

Unfortunately running Internet Explorer in administrator mode isn't an option, as the add-in is an update to an older version that currently has a 20,000+ userbase. Our users cover a range of skill levels and the add-in should work "as is" across multiple operating systems and user settings.

هل كانت مفيدة؟

المحلول

Make sure you have included the add-on's config file in your installation package.

Also, if the Internet Explorer Protected Mode is enabled, your code cannot save anything to the config file located in the same folder where the add-on is installed. You can implement a custom config file and copy it to the "Temporary Internet Files\Low" folder in the user’s profile. Another solution is to disable Protected Mode.

نصائح أخرى

Have you tried to run the application as Administrator?

You could view that when you right-click on an application and see on the available options which would state as 'Run As Administrator'.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top