locked
CreatePkgDef crashes with 0x80040153 (REGDB_E_INVALIDVALUE) RRS feed

  • Question

  • Howdy!

    I'm trying to build a Visual Studio extensibility project that's building for coworkers.  However, when I try to build it, it crashes in the CreatePkgDef step.  Visual Studio doesn't share any details about the crash at the default logging level.  I just get the

    CreatePkgDedf.exe has stopped working... check online for a solution.. close the program... debug the program popup.

    By increasing the log level, I got it to show this:

    Unhandled Exception: System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE))
     at System.Runtime.InteropServices.RuntimeEnvironment.GetDeveloperPath()
     at System.AppDomain.SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
     at System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile, String[] propertyNames, String[] propertyValues)
    

    With a bit more sleuthing, I discovered that if I set the DEVPATH environment variable like this in my system environment:

    DEVPATH=C:\
    

    The crash is resolved.

    GetPkgDef.exe also crashes in the same way if I just invoke it from a command prompt.  

    SET DEVPATH=
    "C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Tools\bin\CreatePkgDef.exe"
    Unhandled Exception: System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE))
     at System.Runtime.InteropServices.RuntimeEnvironment.GetDeveloperPath()
     at System.AppDomain.SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo)
     at System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile, String[] propertyNames, String[] propertyValues)</strong>
    

    but if I do this:

    SET DEVPATH=.
    "C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Tools\bin\CreatePkgDef.exe"
    Visual Studio (R) PkgDef Creation Utility.
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    Syntax: CreatePkgDef /out=FileName [/i=AssembliesToInclude[;...]] [/codebase] [/assembly] AssemblyPath
    
    out=FileName Output file.
    /i=AssembliesToInclude Additional assemblies to consider for binding.
    /codebase  Force registration with CodeBase.
    /assembly  Force registration with Assembly.</strong>
    

    This sure looks like a bug in CreatePkgDef. 

    I do not have <developmentMode> set in my machine,config or any app.config that I could find, so it's not clear to me why CreatePkgDef is even looking at the DEVPATH.

    Any comments would be welcome.  Am I overlooking something?

     

     


    Uwe


    • Edited by InvaderZim Thursday, June 16, 2011 8:57 PM Why is making this readable so hard?
    Thursday, June 16, 2011 8:42 PM

Answers

  • Hello,

     

    I double check the CreatePkgDef.exe.config on my side, it doesn’t contain the developmentMode tag. If I add it manually, I can repro the problem as you described.

     

    However, I can confirm the original file of CreatePkgDef.exe.config doesn’t contain the developmentMode tag, which looks like

     

    <configuration>

      <startup>

        <supportedRuntime version="v4.0"/>

      </startup>

      <runtime>

        <loadFromRemoteSources enabled="true" />

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

          <dependentAssembly>

            <assemblyIdentity name="EnvDTE" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

            <bindingRedirect oldVersion="7.0.3300.0" newVersion="8.0.0.0" />

          </dependentAssembly>

        </assemblyBinding>

      </runtime>

    </configuration>

     

    If the developmentMode is required for your business, you can add it manually to the CreatePkgDef.exe.config. The developmentMode is used to  searches for assemblies in directories specified by the DEVPATH environment variable, if we set the DEVPATH = NULL, OS indicate it is invalid value for a path, therefore the exception raised. I believe this should be an expected result.

     

    As the workaround, if you want to  use developmentMode, you have to set up a valid path for DEVPATH. Please note: “.” is a valid path which means the current folder. Otherwise, please set developmentMode to false.

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by InvaderZim Monday, June 20, 2011 11:55 AM
    Monday, June 20, 2011 3:52 AM

All replies

  • Hi Invader,

    I can’t repro your problem followed by your instruction on Windows 7 64 bit, Visual Studio 2010 SP1 with VS 2010 SDK SP1.

     

    CreatePkgDef.exe doesn’t raise the exception no matter the DEVPATH I set.

     

     If we change another machine, can we always repro this problem?

     

    Regards,

    Yi

     

        


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, June 17, 2011 9:41 AM
  • Hi Yi:
    Sorry for the delay.  I'm disappointed that you can't reproduce the problem.  Thank you for trying.
    I just logged into another machine that also has Visual Studio installed, and the Visual Studio SDK installed.  However, this is Visual Studio 2010 without SP1.  The original report was on a machine with SP1.
    The result is identical: 

    C:\Users\UWEB>set DevPath= C:\Users\UWEB>"C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Tools\bin\CreatePkgDef.exe" Unhandled Exception: System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE)) at System.Runtime.InteropServices.RuntimeEnvironment.GetDeveloperPath() at System.AppDomain.SetupFusionStore(AppDomainSetup info, AppDomainSetup oldInfo) at System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile, String[] propertyNames, String[] propertyValues) C:\Users\UWEB>set DevPath=. C:\Users\UWEB>"C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK\VisualStudioIntegration\Tools\bin\CreatePkgDef.exe"Visual Studio (R) PkgDef Creation Utility. Copyright (c) Microsoft Corporation. All rights reserved. Syntax: CreatePkgDef /out=FileName [/i=AssembliesToInclude[;...]] [/codebase] [/assembly] AssemblyPath /out=FileName Output file. /i=AssembliesToInclude Additional assemblies to consider for binding. /codebase Force registration with CodeBase. /assembly Force registration with Assembly.
    Apologies if the above is hard to read. 
     
    Did you "SET DEVPATH=" (in other words, set the DEVPATH environment variable to nothing) before you tried the command?
     
    I just noticed something: the SDK directory contains a file named "CreatePkgDef.exe.config", and that file looks like this:

    <
    configuration> <startup> <supportedRuntime version="v4.0"/> </startup> <runtime> <loadFromRemoteSources enabled="true" /> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EnvDTE" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="7.0.3300.0" newVersion="8.0.0.0" /> </dependentAssembly> </assemblyBinding> <developmentMode developerInstallation="true"/> </runtime> </configuration>
    Note that it sets developmentMode to "true".  Does your "CreatePkgDef.exe.config" also do this? In that case, please try clearing the DEVPATH and see if it crashes as I described.  If your .config file does not contain the <developmentMode> string, please try adding it temporarily and see if that causes the crash with an empty DEVPATH.
    On Monday, I will have some of my coworkers try this on their machines. 

    --- Uwe

    • Edited by InvaderZim Sunday, June 19, 2011 3:54 AM Fixed formatting again! (There is no preview.)
    Sunday, June 19, 2011 3:52 AM
  • BTW, if this problem is reproducible, the answer is to set DEVPATH=. in the system environment.  But it's still a bug -- I don't think that CreatePkgDef should crash if DEVPATH is not set.

    At this point, I'd mostly like to confirm that this is a bug.  Setting DEVPATH is just a work-around.

    Also, note the error:

    Unhandled Exception: System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE))
     at System.Runtime.InteropServices.RuntimeEnvironment.GetDeveloperPath()
    

    I did a bit of "binging" and this appears to be reporting the same API call crash:

    http://www.mail-archive.com/nant-developers%40lists.sourceforge.net/msg07390.html

    http://www.eggheadcafe.com/software/aspnet/31181293/application-fault-and-registry-setting.aspx

    And an "aha" moment:

    http://www.devnewsgroups.net/dotnetframework/t42934-empty-devpath-environment-setting-causes-exceptions.aspx

    So it appears that DEVPATH must be set if an app calls GetDeveloperPath() or bad things will happen.  This bug has apparently been around since Visual Studio 2005.

     

     

     

     


    --- Uwe
    Sunday, June 19, 2011 4:04 AM
  • Hello,

     

    I double check the CreatePkgDef.exe.config on my side, it doesn’t contain the developmentMode tag. If I add it manually, I can repro the problem as you described.

     

    However, I can confirm the original file of CreatePkgDef.exe.config doesn’t contain the developmentMode tag, which looks like

     

    <configuration>

      <startup>

        <supportedRuntime version="v4.0"/>

      </startup>

      <runtime>

        <loadFromRemoteSources enabled="true" />

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

          <dependentAssembly>

            <assemblyIdentity name="EnvDTE" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

            <bindingRedirect oldVersion="7.0.3300.0" newVersion="8.0.0.0" />

          </dependentAssembly>

        </assemblyBinding>

      </runtime>

    </configuration>

     

    If the developmentMode is required for your business, you can add it manually to the CreatePkgDef.exe.config. The developmentMode is used to  searches for assemblies in directories specified by the DEVPATH environment variable, if we set the DEVPATH = NULL, OS indicate it is invalid value for a path, therefore the exception raised. I believe this should be an expected result.

     

    As the workaround, if you want to  use developmentMode, you have to set up a valid path for DEVPATH. Please note: “.” is a valid path which means the current folder. Otherwise, please set developmentMode to false.

     

    Regards,

    Yi


    Yi Feng Li [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by InvaderZim Monday, June 20, 2011 11:55 AM
    Monday, June 20, 2011 3:52 AM
  • Hi Yi:

    Thank for verifying that your CreatePkgDef.exe.config file does not contain <developmentMode>.  My copy of this file does contain this string, and it is set on every machine that I checked that has Visual Studio installed.  I can categorically say that I did not insert this tag, so something else I install must be modifying this file.

    I still believe that the fact that GetDeveloperAPI() throws an exception if DEVPATH is not set (and complains that there is a problem with the registry) is an error in this API function.  It seems to me that it should either return a more specific error code or (better) proceed as if DEVPATH was set to an empty string.  The fact that this error has been reported a few times in different programs (not just CreatePkgDef) since 2005 indicates that it does cause confusion.  

    Hopefully this discussion will save someone else a bit of time in the future.  I will mark your previous response as an answer, but if this can be turned into a real bug report, that would be helpful.

    Thanks again for your help.

     

     


    --- Uwe
    Monday, June 20, 2011 11:55 AM