locked
VSIX package - FileNotFoundException for a referenced WPF Toolkit DLL RRS feed

  • Question

  • Microsoft Visual Studio 2010 on Windows7 - VSIX Package
    Version 10.0.30319.1 RTMRel
    Microsoft .NET Framework
    Version 4.0.30319 RTMRel
    Installed Version: Ultimate

    I've created a package and needed a pie-chart for visualization. So I downloaded the Feb release of WPF  Toolkit. Added references to System.Windows.Controls.DataVisualization.Toolkit and WPFTookit. I've data bound the PieChart to a ViewModel / presenter class.

    However when this property is changed, (i.e. items to show in the pie-chart), I get a FileNotFoundException

    Could not load file or assembly 'WPFToolkit, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    Snipped Stacktrace

       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
       at System.Windows.Baml2006.Baml2006SchemaContext.ResolveAssembly(BamlAssembly bamlAssembly)
       at System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlTypeToType(BamlType bamlType)

    --snipped--

    The FusionLog property shows me that it is looking for this DLL in the wrong place - in the parent folder of devenv.exe

    --snipped--

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///W:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/WPFToolkit.DLL.
    LOG: Attempting download of new URL file:///W:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/WPFToolkit/WPFToolkit.DLL.
    LOG: Attempting download of new URL file:///W:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/PublicAssemblies/WPFToolkit.DLL.
    --snipped--

    This dll is referenced by the VSIX Project and is present in the project output folder.

    Next step: I tried putting this dll into the GAC and now the assembly load succeeds

    c:\Program Files (x86)\WPF Toolkit\v3.5.40619.1>gacutil /i WPFToolkit.dll


    Question: Why does this exception occur for only one of the referenced DLL? What is the right fix ? I'm thinking this will cause a problem for deployment via the VS extension manager.. I'd need something like a post-install step, which is something I'd like to avoid (I would like the install to be as smooth as possible).
    Wednesday, August 25, 2010 6:44 PM

Answers

  • Actually i have the same problem with my VSPackage.

    >>Why does this problem occur for only the WPF Toolkit dll - It seems to be loading the class library dll just fine
    This happens when it's loaded using reflection

    I believe the problem is that by the time the my package's assembly is loaded, the app domain is already created. Nothing we can do to alter the "assembly search path".

    My workaround is to register an assembly resolver. Make sure it doesn't throw any exception though, otherwise you will messed up other extensions.

     

    Nancy, is it file a DCR in Dev11 timeframe to track this?

    • Marked as answer by Gishu Monday, November 8, 2010 5:50 PM
    Thursday, September 30, 2010 5:36 AM

All replies

  • Hi Gishu,

    I have tested in my side, it works fine. The following is my detailed steps:

    1. Download WPF Toolkit in Codeplex Site: http://wpf.codeplex.com/releases/view/40535

    2. Install WPFToolKit.msi

    3. Add System.Windows.Controls.DataVisualization.dll and WPFToolkit.dll as Reference to my VSIX project

    You don't need to register WPFToolkit.dll to GAC, when you install WPFToolKit.msi, WPFToolkit.dll has been registered in GAC.

    So I guess the problem is that you might not install WPFToolKit.msi successfully, or you have installed older version WPFToolkit.dll.

    If I misunderstood you, or you have any comments, please feel free to let me know.

     

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, August 26, 2010 3:44 AM
  • I'm not sure if we have zeroed in on the error here..

    The WPFToolkit.msi doesn't install the dlls into the GAC for me. I downloaded the WPF Toolkit February 2010 (Version 3.5.50211.1) version again (from the link in your post) and reinstalled (on my XP machine - VS2010 Ultimate - Admin user).

    Dropping to the 2010 command prompt post-install

     

    C:\Program Files\WPF Toolkit\v3.5.50211.1>gacutil /l WPFToolkit
    Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    The Global Assembly Cache contains the following assemblies:
    
    Number of items = 0

     

    I see the same issue on two machines (running Win7 and WinXP). I do not get any install time errors.

    In both cases, installing the WPFToolkit dll into the GAC, solved it.

    The error comes when you data-bind a Chart with a collection. When the slices of a pie-chart are created, the app seems to try to load some style resources on demand and fails when it is unable to find the DLL in the GAC or the local folder.

    If you can give me a way to get a sample project across to you, I can do that too..

     

     

    Thursday, August 26, 2010 5:58 AM
  • Hi Gishu,

    Sorry for my mistake, these dlls are not registered to GAC when install WPFToolkit.msi. It only register Assembly Folder in:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

    So they can show in .NET Tab in Add Reference Dialog.

    About your issue, have you checked the path of WPFToolkit when you add it in your project? To see it, you can right click WPFToolkit node in Reference, and choose Properties. The path should be C:\Program Files (x86)\WPF Toolkit\v3.5.50211.1. And they will be copied to bin\Debug when you add them to your project by Add Reference.

    If all is OK, could you share your project file here? or your app.config file?

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, September 16, 2010 9:17 AM
    • Unmarked as answer by Gishu Friday, September 17, 2010 7:36 PM
    Friday, August 27, 2010 7:42 AM
  • Hi,

    I am writing to follow up this issue. Please let me know what I can help. Thanks.

     

    Regards,
    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, September 1, 2010 3:25 AM
  • I was hospitalized for a couple of weeks, hence the delay. Have shared a sample, which exhibits the same issue.. but for System.Windows.Controls.DataVisualization.Toolkit.dll

    http://dl.dropbox.com/u/11733224/ExtnRefToolkit.zip

     

    As is, it shouldn't run. The inner exception of the exception, that you should be seeing should have a similar fusion log property value.

    c:\Program Files (x86)\WPF Toolkit\v3.5.50211.1>gacutil /i System.Windows.Controls.DataVisualization.Toolkit.dll

    Registering this dll in the GAC should cause the pie chart to show up without any exceptions

    c:\Program Files (x86)\WPF Toolkit\v3.5.50211.1>gacutil /u System.Windows.Controls.DataVisualization.Toolkit

    should cause the problem to reappear.

     

    Looking forward to hearing about what you find...

    Friday, September 17, 2010 8:16 PM
  • Hi,

    Sorry to hear that, I wish you a speedy recovery. 

    I have tested your application, it throws following error message when I click AToolWindow button:

    Could not load file or assembly 'System.Windows.Controls.DataVisualization.Toolkit, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

    If you mean this error message, as far as I know, because this is extension for Visual Studio, and you will start a new VS instance to debug it, so it will search for related references in the path in devenv.exe.config and GAC, for example, it will search following relative path for devenv.exe:

    privatePath="PublicAssemblies;PrivateAssemblies;CommonExtensions\Microsoft\TemplateProviders;
                     PrivateAssemblies\DataCollectors;PrivateAssemblies\DataCollectors\x86;
                     CommonExtensions\Microsoft\Editor;CommonExtensions\Platform\Debugger"

    As a workaround, you can register these dlls to GAC or copy to above relative path. Hope this helps.

    Please let me know if you have any comments.

    Regards,
    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, September 21, 2010 2:18 AM
  • Right. As the initial fusion logs in the exception showed, it is searching for the dll in the GAC and the private paths of devenv.exe

    My extension consists of a Package DLL which references one class library DLL that I wrote & the WPF Toolkit dll (in addition to other framework DLLs).

    • Why does this problem occur for only the WPF Toolkit dll - It seems to be loading the class library dll just fine.
    • if this can't be avoided, how do I get the dll installed into GAC when the extension is installed ? Would I need an MSI installation just for this ? What do you suggest ?

    I'd like it to be a one-click VSIX install  as far as possible.

    Wednesday, September 29, 2010 7:36 PM
  • Actually i have the same problem with my VSPackage.

    >>Why does this problem occur for only the WPF Toolkit dll - It seems to be loading the class library dll just fine
    This happens when it's loaded using reflection

    I believe the problem is that by the time the my package's assembly is loaded, the app domain is already created. Nothing we can do to alter the "assembly search path".

    My workaround is to register an assembly resolver. Make sure it doesn't throw any exception though, otherwise you will messed up other extensions.

     

    Nancy, is it file a DCR in Dev11 timeframe to track this?

    • Marked as answer by Gishu Monday, November 8, 2010 5:50 PM
    Thursday, September 30, 2010 5:36 AM
  • Thanks  nTony!  This works much better than having to register the DLLs in the GAC.

    I also had to add some dummy files so that the package DLL has an explicit reference to these DLLs (that are only loaded otherwise via XAML load) such that they are copied to the extension folder.

    In the assembly resolve event handler, I just look up the corresponding DLL from my extension folder and voila! It works.

    Monday, November 8, 2010 5:53 PM
  • Friday, June 3, 2011 3:00 PM