IE with Protected Mode enabled does not load addin

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

IE with Protected Mode enabled does not load addin
 
Andrey Yemelyanov




Posts: 70
Joined: 2009-04-21
Hi guys:

I have created an IE addin using Addin Express 2009.
It is a very simple sample addin that does NOT write any data
to local disk.
It works great in most cases. However, it crashes under Vista 32x
with the Protected Mode enabled in IE v.8. In fact, the addin
does not seem to load at all when IE runs with Protected Mode.
But if I run IE as Administrator, then the addin gets loaded and
works as expected.

Do you have any guidelines that I can follow to make sure the addin
works properly under Protected Mode? Maybe, you have some
suggestions on how to prompt user for elevated privileges when addin
is loaded?

I have seen some forum threads where you suggest using protected mode
api. But I do not think this applies in my case as no data is saved by the addin.

Here is the error log I am getting:

Detailed technical information follows:
---
(Inner Exception)
Date and Time: 2010-02-18 17:22:54
Machine Name: ANDREY-PC
IP Address: fe80::edc0:890:ca05:dfb6%10
Current User: Andrey-PC\Andrey

Application Domain: C:\Webstamp\Webstamp portal client\Webstamp.Addin.IEWO\Webstamp.Addin.IEWO\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/5.2.261.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name: AddinExpress.IE, Version=5.2.261.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 5.2.261.0
Assembly Build Date: 2009-11-18 15:49:06

Exception Source: System
Exception Type: System.Runtime.InteropServices.ExternalException
Exception Message: Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\Users\Andrey\AppData\Local\Temp\Low\axqyyokn.cmdline".
Exception Target Site: ExecWaitWithCaptureUnimpersonated

---- Stack Trace ----
System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(userToken As SafeUserTokenHandle, cmd As String, currentDir As String, tempFiles As TempFileCollection, outputName As String&, errorName As String&, trueCmdLine As String)
AddinExpress.IE.dll: N 1039 (0x40F) IL
System.CodeDom.Compiler.Executor.ExecWaitWithCapture(userToken As SafeUserTokenHandle, cmd As String, currentDir As String, tempFiles As TempFileCollection, outputName As String&, errorName As String&, trueCmdLine As String)
AddinExpress.IE.dll: N 0035 (0x23) IL
Microsoft.CSharp.CSharpCodeGenerator.Compile(options As CompilerParameters, compilerDirectory As String, compilerExe As String, arguments As String, outputFile As String&, nativeReturnValue As Int32&, trueArgs As String)
AddinExpress.IE.dll: N 0043 (0x2B) IL
Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(options As CompilerParameters, fileNames As String[])
AddinExpress.IE.dll: N 0316 (0x13C) IL
Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(options As CompilerParameters, sources As String[])
AddinExpress.IE.dll: N 0192 (0xC0) IL
Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(options As CompilerParameters, sources As String[])
AddinExpress.IE.dll: N 0014 (0xE) IL
System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(options As CompilerParameters, sources As String[])
AddinExpress.IE.dll: N 0000 (0x0) IL
System.Xml.Serialization.Compiler.Compile(parent As Assembly, ns As String, xmlParameters As XmlSerializerCompilerParameters, evidence As Evidence)
AddinExpress.IE.dll: N 0294 (0x126) IL
System.Xml.Serialization.TempAssembly.GenerateAssembly(xmlMappings As XmlMapping[], types As Type[], defaultNamespace As String, evidence As Evidence, parameters As XmlSerializerCompilerParameters, assembly As Assembly, assemblies As Hashtable)
AddinExpress.IE.dll: N 1214 (0x4BE) IL
System.Xml.Serialization.TempAssembly..ctor(xmlMappings As XmlMapping[], types As Type[], defaultNamespace As String, location As String, evidence As Evidence)
AddinExpress.IE.dll: N 0006 (0x6) IL
System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(mappings As XmlMapping[], type As Type)
AddinExpress.IE.dll: N 0252 (0xFC) IL
System.Xml.Serialization.XmlSerializer.FromMappings(mappings As XmlMapping[], type As Type)
AddinExpress.IE.dll: N 0163 (0xA3) IL
System.Web.Services.Protocols.SoapClientType..ctor(type As Type)
AddinExpress.IE.dll: N 0236 (0xEC) IL
System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
AddinExpress.IE.dll: N 0075 (0x4B) IL
Webstamp.ClientCore.WebstampClientService.WebstampClientServiceService..ctor()
Reference.cs: line 0054, col 09, IL 0000 (0x0)
Webstamp.ClientCore.WebstampToolbarControl..ctor()
WebstampToolbarControl.cs: line 0039, col 09, IL 0014 (0xE)
Webstamp.Addin.IEWO.IEModule.IEModule_OnDisconnect(sender As Object, e As EventArgs)
IEModule.cs: line 0194, col 17, IL 0020 (0x14)
AddinExpress.IE.ADXIEModule.AddinExpress.IE.IObjectWithSite.SetSite(site As Object)
AddinExpress.IE.dll: N 0033 (0x21) IL



(Outer Exception)
Date and Time: 2010-02-18 17:22:54
Machine Name: ANDREY-PC
IP Address: fe80::edc0:890:ca05:dfb6%10
Current User: Andrey-PC\Andrey

Application Domain: C:\Webstamp\Webstamp portal client\Webstamp.Addin.IEWO\Webstamp.Addin.IEWO\bin\Debug\
Assembly Codebase: file:///C:/Windows/assembly/GAC_MSIL/AddinExpress.IE/5.2.261.0__4416dd98f0861965/AddinExpress.IE.dll
Assembly Full Name: AddinExpress.IE, Version=5.2.261.0, Culture=neutral, PublicKeyToken=4416dd98f0861965
Assembly Version: 5.2.261.0
Assembly Build Date: 2009-11-18 15:49:06

Exception Source:
Exception Type: AddinExpress.IE.ADXIEExternalException
Exception Message: An error has occured in the code of the extension.
Exception Target Site: Object reference not set to an instance of an object.

---- Stack Trace ----

/Andrey
Posted 18 Feb, 2010 09:43:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Andrey.

Do you call a web service from the add-on?
Posted 18 Feb, 2010 11:28:26 Top
Andrey Yemelyanov




Posts: 70
Joined: 2009-04-21
Hi Sergey:

Yes, as a matter of fact, I have a web service proxy in my add-in. However, I never make web service
calls when IE loads my add-in. This is what baffles me: the add-in fails long before
I make a remote method call. I suspect it fails in the proxy constructor. Is it some dynamic compilation problem?

BTW: Forgot to mention... When I launch IE with protected mode enabled I get the following warning prompt:

"This program will open outside of Protected Mode. ...
Name: csc.exe
Details: Microsoft.NET/Framework/v.2.0... ./csc.exe"

I figure it has something to do with the compiler, but I cannot put my finger on it.

What is your take on this?

/Andrey
Posted 19 Feb, 2010 01:41:48 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Andrey.

You get this warning because the compiler is not registered in the ElevationPolicy registry key.
You can read about it here: http://www.codeproject.com/KB/vista-security/PMSurvivalGuide.aspx
I would advise you to communicate with the web service from a separate .exe application which starts as a medium intergrity process by default.
Posted 19 Feb, 2010 10:59:31 Top
Andrey Yemelyanov




Posts: 70
Joined: 2009-04-21
Hi Sergey:

I have added the ElevationPolicy setting for the compiler to registry as you recommended and
as a result the warning prompt no longer appears. But my addin still fails to load due to
error instantiating the web service proxy instance in the constructor.

I assumed that the executable file adxloader.exe generated by adxregext.exe during installation
was already supposed to load my addin with medium privileges and therefore creating
web service proxy instances should have worked (when I lauch adxloader.exe I get a message
from console "Medium").

Could you please explain the role of adxloader.exe and how it can or maybe cannot help me
work with web services in the addin?

/Andrey
Posted 22 Feb, 2010 03:19:46 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Andrey.

The adxloader.exe program injects the adxloader.dll into the main process of IE8. It is needed to support custom shortcuts in the main process of IE8.

Probably this post will help you to solve the issue with the web service:
http://social.msdn.microsoft.com/Forums/en-US/ieextensiondevelopment/thread/2a656095-4b85-46f9-97aa-c6d72148a1eb
Posted 23 Feb, 2010 05:37:29 Top
Andrey Yemelyanov




Posts: 70
Joined: 2009-04-21
Hi Sergey:

Thank you for the latest reply. It was a breaker! I solved a problem with accessing web services
by pre-generating serialization assembly for the dll which uses web services. Now at least I can
see the addin loading into IE. But I struck yet another snag :( I get Access Denied error when trying to
read fr om or write to user folder. I figure this is wh ere your protected mode api comes into play:
just get a writable dir and save files there? Is this a correct assumption?

Andrey
Posted 24 Feb, 2010 02:36:19 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hi Andrey,

Andrey Yemelyanov writes:
Is this a correct assumption?


Yes, it is. Please find a suggested way of saving a file when in Protected Mode at http://msdn.microsoft.com/en-us/library/ms537319(VS.85).aspx.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Feb, 2010 04:57:52 Top
Andrey Yemelyanov




Posts: 70
Joined: 2009-04-21
Great! Now everything works as expected. Using Protected Mode API I was able to get a writable dir
and write to it.

Thanks a lot for your help, guys!

Andrey
Posted 24 Feb, 2010 05:17:05 Top