简体   繁体   中英

Error displaying a window of a DLL with references to other DLLs

I'm trying to load a window that is in a DLL, but that window contains references to custom WPF controls that are in another DLL (WPF Toolkit), the problem is that while rendering an instance of the window, System.Windows.Markup.XamlParseException with the following message:

"You can not load file or assembly 'Xceed.Wpf.Toolkit, PublicKeyToken = 3e4669d2f30244f4' or one of Its dependencies. The system can not find the file specified."

If I make a reference to WPF Toolkit from the main project, the problem is solved, but I need this to work without referencing WPF Toolkit.

I need this to work without referencing WPF Toolkit.

Why? Please elaborate on that requirement.


It's true that as long as your program does not itself reference members of the WPF Toolkit assembly directly, it is legal to compile without a reference to the WPF Toolkit assembly. But you are using a DLL that itself requires the WPF Toolkit assembly at run-time. So whether your program's assembly references the WPF Toolkit assembly or not, you have to do something to ensure that the WPF Toolkit assembly is available at run-time to be loaded by the DLL you're using.

One of the easiest ways to do this would be to add the WPF Toolkit assembly as a reference. You say you don't want to do this, but don't explain why. Another way to do it would be to add the WPF Toolkit DLL as a project item (eg "Add Existing Item...", "Add as link") and set the item type to "Content", with "Copy if newer" or "Copy always". A more complicated way would be to add it to the GAC.

For that matter, you could copy the DLL to the project's output directory by hand if you want; the important thing is that the WPF Toolkit's DLL is present so that it can be loaded by .NET when the DLL you're referencing needs it.

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