Marshal
Marshal

Reputation: 6671

Correctly deploying Application with Telerik components

I have following project structure:

The class library is having several usercontrols which has telerik components in it. And I have a host application, which hosts these user controls from Class Library.

Now the problem is, despite of reference to telerik dlls in library, I still have to reference telerik dlls in my host application. Or else it throws XamlParseException during runtime. It compiles without error though.

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'Telerik.Windows.Controls.GridView, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.

Why is this happening ? Why is there need of duplicating the dlls.

I am using Telerik dll with version 2015.2.623.45


To reproduce this issue: We can just create a library with one usercontrol

<UserControl>
       <Grid>
          <telerik:RadGridView></telerik:RadGridView>  
       </Grid>
 </UserControl>

And then create another project which references this class library

<Window>
    <Grid>
        <wpfApplication1:UserControl1/>
    </Grid>
</Window>

And try to run it.

(I have omitted xmlns definitions for brevity)

Upvotes: 4

Views: 3539

Answers (2)

K512
K512

Reputation: 141

In the project file that actually uses the DLL, add this to a <PropertyGroup> section:

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Now the DLL will be copied to the output folder of this and all referencing projects.

Upvotes: 0

aydjay
aydjay

Reputation: 878

Taken from the following solution:

DLL reference not copying into project bin

A) Add a reference to your Host Application

B) Add dummy code your class library so that the compiler would detect that the reference is being used and then copy it into your Host Application Bin folder.

C) Add a build event to force copy the DLL.

The reason just having the XAML code isn't enough is the compiler doesn't evaluate it to see what DLL's your XAML is dependent on.

I went with option B for now, but i'm leaning towards option A) being best practice.

If you start manipulating your telerik control in C# at some point, everything will start working as intended.

Upvotes: 7

Related Questions