none
Serialization throws DirectoryNotFoundException in IE7 Protected Mode RRS feed

  • Question

  • Hi,

    I've already asked this question in the IE Extension forums, but was advived to seek further help from here, so here's the story:

    I've developped a BHO plugin for Internet Explorer 7.0. It works fine in IE6, XP's IE7 and IE7 in Vista, if run in admin privileges ot Protected Mode turned off.

    The BHO is created using .NET and is done with Visual Studio 2003 (FW1.1).

    The problem is that, when I launch Internet Explorer with user privileges and it goes to Protected Mode the browser popups a dialog, which says that it wants to open dw20.exe, which to my knowledge is error reporting tool. I figured out that the BHO had an unhandled exception occuring and this is why it crashed and wants to open the error reporting tool. I don't have the actual full error description which occured at hand but briefly the exception was "Directory not found".

    I searched deeper, and found out that the IE is trying to write to location:
    C:\Users\UserAccount\AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\C\Users\UserAccount\AppData\Local\Temp\Low

    And the last two folders aren't there. If I manually create them, the problem disappears. But it's seems to be a bad solution when thinking about later disribution of my application to customers. Shouldn't these folders be created and managed by the OS (or browser) itself, so is there a bug or if not, how can I pass this problem?

    The BHO I've programmed doens't write anything to temp, and when I created those folders and looked what files would appear there, these was only on file with cryptic name with a suffix ".tmp" and had binary content that made no sense to me.

    I've searched the whole internet, and found out couple of people that had the same problem but the only solution for them was to create those folders. That's not good enough for me.


    Here's the Exception and the code section:

    System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Account\AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\C\Users\Account\AppData\Local\Temp\Low\uygftk7v.tmp'. 
        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) 
        at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) 
        at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated() 
        at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile) 
        at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension) 
        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.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence) 
        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 Domppari.ExternalApplicationUtil.ExternalApplicationUtilMessage.GetBytes() 
        at Domppari.ExternalApplicationUtil.ExternalAppUtilConnection.SendData(Int32 utilId, Int32 fromUtilId, Int32 messageId, Byte[] data, Object aClassroom, Object aSession) 
        at Domppari.ExternalApplicationUtil.AppSideExtAppUtilConnection.ConnectionStatusChanged(ConnectionState conState) 
        at Domppari.ExternalApplicationUtil.ClientSocketHandler.OnConnect(IAsyncResult result) 



    So, it's the XMLSerializer that does the harm, but why? It's probably creating some runtime types, because the BHO also requires access to the CSC.exe. Could it be that it generates these runtime assemblies and needs a place to save them to? If so, the only question still is, why these folders do not exist automatically.

    I'm aware that with FW2.0 comes a tool called sgen.exe, that can be used to generate these assemblies beforehand and ship then alongside with the BHO, so no calls to the csc.exe would required and so no runtime assemblies would need a place to be saved. But I'm still in FW1.1 and cannot use sgen.exe.

    Here's some code from the GetBytes section:

            public byte[] GetBytes() 
            { 
                byte[] message = null
                try 
                { 
                    MemoryStream stream = new MemoryStream(); 
                    XmlSerializer serializer = new XmlSerializer(typeof(ExternalApplicationUtilMessage)); 
                    serializer.Serialize(stream, this); 
                    message = stream.GetBuffer(); 
     
     



    How can I get this problem resolved?

    Thanks in advance!



    --
    Best Regards,
    Toni Riikonen.

    Friday, August 15, 2008 10:27 AM

Answers

  • OK, had this one "kinda" solved now.

    The sgen generated XmlSerialization.dll need to be copied to Internet Explorer folder. I've have my BHO components at the install path of my application and one them (the plugin one) is registered using regasm /codebase. Furthermore the XmlSerialization.dll won't be enough for IE. It will require also any referenced components to be at IE directory OR at GAC.

    So, if I don't copy the XmlSerialization.dll to IE directory IE tries to generate these types on-the-fly using csc.exe from Framework 2.0. This causes problems with Protected Mode.

    If I copy the XmlSerialization.dll to IE directory, the IE will automatically require all the reference components and their dependency references copied to it's folder.

    It's not the best solution but it's enough for me, considering that after careful googling through the Internet, there just isn't a better solution available at this time.

    Seems to me like Microsoft wants to drive developpers away from IE development and maybe to Silverlight...

    --
    Best Regards,
    Toni Riikonen
    • Marked as answer by Domppari Thursday, October 9, 2008 11:15 AM
    Thursday, October 9, 2008 11:15 AM

All replies

  • Sounds to me like the rate of MSFT product development is outpacing your willingness to upgrade the tools you need to use them.
    Hans Passant.
    Friday, August 15, 2008 11:12 AM
    Moderator
  • Hi,

    I've now upgraded to Visual Studio 2008 and am building against Framework 2.0, the problem still occurs, the IE wants to open dw20.exe due to DirectoryNotFound exception.

    Even the Sgening the XmlSerializers to go with the BHO components didn't fix the problem.

    I'm all open for ideas about this.

    --
    Best Regards,
    Toni Riikonen
    Tuesday, October 7, 2008 7:43 AM
  • OK, had this one "kinda" solved now.

    The sgen generated XmlSerialization.dll need to be copied to Internet Explorer folder. I've have my BHO components at the install path of my application and one them (the plugin one) is registered using regasm /codebase. Furthermore the XmlSerialization.dll won't be enough for IE. It will require also any referenced components to be at IE directory OR at GAC.

    So, if I don't copy the XmlSerialization.dll to IE directory IE tries to generate these types on-the-fly using csc.exe from Framework 2.0. This causes problems with Protected Mode.

    If I copy the XmlSerialization.dll to IE directory, the IE will automatically require all the reference components and their dependency references copied to it's folder.

    It's not the best solution but it's enough for me, considering that after careful googling through the Internet, there just isn't a better solution available at this time.

    Seems to me like Microsoft wants to drive developpers away from IE development and maybe to Silverlight...

    --
    Best Regards,
    Toni Riikonen
    • Marked as answer by Domppari Thursday, October 9, 2008 11:15 AM
    Thursday, October 9, 2008 11:15 AM