Cannot find file when loading addon with IE in protected mode as non-administrator

Add-in Express™ Support Service
That's what is more important than anything else

Cannot find file when loading addon with IE in protected mode as non-administrator
FileNotFoundException when loading addon 
Justin Ricci




Posts: 14
Joined: 2010-08-12
Hi, I've been working on my first addon using your toolkit and I found that it works great when I launch IE from visual studio [read: As Administrator]. When I launch IE as a normal user I get this error window when My app loads. It seems to be related to the creation of an XmlSerializer, and NOT a permissions issue on the file I'm trying to write...

The code at line 75 in my piece of the call stack is this:

XmlSerializer serializer = new XmlSerializer(typeof(MyNamespace.ImageMetaFile))

Here's the details from the error window:

************** Exception Text **************
System.IO.FileNotFoundException: Could not find file 'C:\Users\jricci\AppData\Local\Temp\Low\wcutvype.dll'.
File name: 'C:\Users\jricci\AppData\Local\Temp\Low\wcutvype.dll'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at WAMBarIEAddon.Artifact.ImageMetaFile.Save(ImageMetaFile metaFile) in D:\Projects\comp\WAMBar\WAMBarIEAddon\Artifact\ImageMetaFile.cs:line 75
at WAMBarIEAddon.Artifact.ImageMetaFile.Load(String filePath, String fileDir) in D:\Projects\comp\WAMBar\WAMBarIEAddon\Artifact\ImageMetaFile.cs:line 46
at WAMBarIEAddon.Artifact.ImageManager.get_ImageMeta() in D:\Projects\comp\WAMBar\WAMBarIEAddon\Artifact\ImageManager.cs:line 36
at WAMBarIEAddon.WAMBar.FillTreeView() in D:\Projects\comp\WAMBar\WAMBarIEAddon\WAMBar.cs:line 192
at WAMBarIEAddon.WAMBar.OnLoad(EventArgs e) in D:\Projects\comp\WAMBar\WAMBarIEAddon\WAMBar.cs:line 185
at System.Windows.Forms.UserControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at AddinExpress.IE.ADXIEBar.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

AddinExpress.IE
Assembly Version: 6.2.373.0
Posted 13 Aug, 2010 11:35:08 Top
Digvijay Chauhan




Posts: 8
Joined: 2010-08-09
Justin,

I have has similar issues. The XmlSerializer tries to create and compile code - and requires user to have administrative privileges. The solution is to build the classes that XmlSerializer would otherwise generate at runtime and use them.

Also, use file locations such as in user/AppData folders where UAC does not care much about FileIO operations.

Hope that helps,

Digvijay
Posted 13 Aug, 2010 12:32:52 Top
Justin Ricci




Posts: 14
Joined: 2010-08-12
Thanks Digvijay, I changed my code to serialize to regular text in the environment temp folder directory and all seems to be working great now. I'm sure the XmlSerializer was a bit overkill, although nice to have... I can survive without it!
Posted 13 Aug, 2010 17:08:01 Top
Digvijay Chauhan




Posts: 8
Joined: 2010-08-09
Hi Justin,

Good to know that you found a way around. You can still have the xml serializer however it must be pre-compiled. I do not recall but there is a compiler switch for the same.

regards,

Digvijay
Posted 14 Aug, 2010 10:03:22 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Justin,

Thank for the good news! BTW Did you enabled Protected Mode in IE?
.NET, Extended MAPI, Windows Phone & RT
Posted 16 Aug, 2010 03:21:04 Top
Justin Ricci




Posts: 14
Joined: 2010-08-12
eugene:

Yes Running in protected mode is just fine, as long as I use the system Temp folder for any file storage I'm doing, which is ok for us!

example: Path.GetTempPath()
Posted 18 Aug, 2010 13:55:25 Top