简体   繁体   中英

Could not load file or assembly 'WPG, PublicKeyToken=null' or one of its dependencies

I'm using PRISM and a new control which I found in CodePlex: WPF Property Grid

http://wpg.codeplex.com/

While I was testing the DEMO, everthing going well.

I have not started using PRISM. If I put the control in a Shell, that also works well. The problem is if I put the control in a Module, it throws an error.

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

I really have no idea about that error. Does anyone have an idea how to fix it?

在此处输入图片说明

EDIT:

<UserControl x:Class="ConfigurationManagerModule.Views.ConfigurationView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:prism="http://www.codeplex.com/prism"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:wpg="clr-namespace:WPG;assembly=WPG"
    >

And this user control is part of a Module

Make sure you have your references set right. I had this problem occur when Project B used an assembly (like WPG) in XAML, but Project A actually created the instance of a Project B class. Adding the WPG reference to Project A is necessary for the XAML parser to work in this way. Referencing Project B in Project A is not sufficient.

I had the same issue while working on Visual Studio 2010, SP1 and Team Server. The simplest solution (though it took a complete day of debugging) is to:

  1. Add the reference (say ProjA.dll) in your project/solution (Say ProjB) where-ever required.
  2. If you see another error related to method not found in ProjB (related to ProjA.dll), then go to ProjA, open it in Solution Explorer, add all the items in it using "Add existing items". Clean and build ProjA.dll, again reference the correct dll in ProjB. It should work!

Sometimes, even if items are in source control, and you can see them, work upon them, and check-in/check-out; such intermittent issues are seen.

This is a fairly general error and is most often caused by the dynamic construction of elements. Whilst you have probably added the reference to the WPG assembly, it is necessary that all of its dependencies are also realised.

  • Try looking at the source code of the WPG package and see whether any references are made by it that do not appear in your output location.
  • Using a tool like ILSpy may help you examine the inner dependencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM