Can't reference an assembly in Xaml

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 5233 Views - Last Post: 09 April 2012 - 11:08 AM Rate Topic: -----

#1 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Can't reference an assembly in Xaml

Posted 07 April 2012 - 11:18 AM

So, i created a WPF custom control library and built using both F6 and shift+F6. I then created a test project to test the control and when i add the reference to the assembly in xaml i get this error

Error 1 Assembly 'CalendarControl' was not found. Verify that you are not missing an assembly reference. Also, verify that your project and all referenced assemblies have been built.C:\WpfApplication1\Mainwindow.xaml 4 26 WpfApplication1

I built both projects multiple times and I am able to reference it in the code behind of my test project so, it got to be some syntax error or something stupid. Below is how am referencing it in xaml
xmlns:myControl="clr-namespace:CalendarControl;assembly=CalendarControl" 



where CalendarControl is my namespace and also my assembly name. And btw the my calendar class is called ExtendedCalendar just to provide extra info.

Is This A Good Question/Topic? 0
  • +

Replies To: Can't reference an assembly in Xaml

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 05:22 AM

Can you post the XAML that you use on the form when you are trying to put it on the form?
Was This Post Helpful? 0
  • +
  • -

#3 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 07:33 AM

View Posteclipsed4utoo, on 09 April 2012 - 07:22 AM, said:

Can you post the XAML that you use on the form when you are trying to put it on the form?



Am not sure what you asking but below is the code am using for the client, the error are on lines 4 and 7
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:myControl="clr-namespace:CalendarControl;assembly=CalendarControl" 
        Title="MainWindow" Height="350" Width="525">
    <Grid Name="myGrid">
        <myControl:ExtendedCalendar name="calendar"></myControl:ExtendedCalendar>
    </Grid>
</Window>



CalendarControl is a WPF custom control library project and the class i need is called ExtendedCalendar. I can attach that class if you like me to. Thanks for your help.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 07:48 AM

When you were typing in the xmlns:myControl, did you use IntelliSense to complete the namespace/assembly part? or did you manually type the entire value?
Was This Post Helpful? 0
  • +
  • -

#5 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:07 AM

View Posteclipsed4utoo, on 09 April 2012 - 09:48 AM, said:

When you were typing in the xmlns:myControl, did you use IntelliSense to complete the namespace/assembly part? or did you manually type the entire value?


No, i didn't get any intellisense and i was wondering why. The weird thing i can reference it in the code behind just fine.
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:16 AM

That's not weird at all that you can reference the class in code. That simply means that the project is referencing the DLL correctly. Referencing a class from code and from XAML is different(as you can see).

So you don't get IntelliSense like this?

Attached Image
Was This Post Helpful? 0
  • +
  • -

#7 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:27 AM

View Posteclipsed4utoo, on 09 April 2012 - 10:16 AM, said:

That's not weird at all that you can reference the class in code. That simply means that the project is referencing the DLL correctly. Referencing a class from code and from XAML is different(as you can see).

So you don't get IntelliSense like this?

Attachment 4-9-2012 11-15-39 AM.png


Trying it again i do get that intellisense as shown in your attachment but am still getting this error

Error 2 The tag 'ExtendedCalendar' does not exist in XML namespace 'clr-namespace:CalendarControl'. Line 7 Position 10. C:\c#\Web\ExtendedCalender\WpfApplication1\Mainwindow.xaml 7 10 WpfApplication1

when i try to instantiate my ExtendedCalendar class.

thanks again for your help
Was This Post Helpful? 0
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:32 AM

When the IntelliSense shows up, is your CalendarControl assembly in the list? If so, choose it directly instead of trying to type the information in. Then do a rebuild of the project.
Was This Post Helpful? 0
  • +
  • -

#9 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:44 AM

View Posteclipsed4utoo, on 09 April 2012 - 10:32 AM, said:

When the IntelliSense shows up, is your CalendarControl assembly in the list? If so, choose it directly instead of trying to type the information in. Then do a rebuild of the project.



I did that and that gets rid of one error (the one in the xmlns) but i still can't instantiate a my ExtendedCalendar class. This is what it looks like now.

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:myControl="clr-namespace:CalendarControl"
        Title="MainWindow" Height="350" Width="525">
    <Grid Name="myGrid">
        <myControl:ExtendedCalendar name="calendar"></myControl:ExtendedCalendar>
    </Grid>
</Window>



The error is on line 7, it's acting like my class is not in that namespace. Below is my class


using System;
using System.Windows.Shapes;
using System.ComponentModel;

namespace CalendarControl
{
    /// <summary>
    ///
    /// </summary>
    public class ExtendedCalendar : Calendar
    {
        
    }
}



Also i thought you always had to specify the assembly name in xaml?
Was This Post Helpful? 0
  • +
  • -

#10 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:50 AM

Quote

Also i thought you always had to specify the assembly name in xaml?


I guess if the assembly and namespace are the same, you only have to give the namespace. Maybe something the VS does for you.

Let me set this up and see if it happens for me also.
Was This Post Helpful? 0
  • +
  • -

#11 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 08:54 AM

View Posteclipsed4utoo, on 09 April 2012 - 10:50 AM, said:

Quote

Also i thought you always had to specify the assembly name in xaml?


I guess if the assembly and namespace are the same, you only have to give the namespace. Maybe something the VS does for you.

Let me set this up and see if it happens for me also.



Thanks, let me know if you need anything else especially in the custom control project.
Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 09:00 AM

Hmm....I had no problems adding a Custom Control project(called CalendarControl) to a solution, adding a Custom Control to the project, inheriting from Calendar, building, adding a reference from the UI project to the DLL of the custom control project, adding the XMLNS, and adding the control to the form.

Now when I added the XMLNS, it gave me this when choosing it from IntelliSense...

xmlns:myControls="clr-namespace:CalendarControl;assembly=CalendarControl"


Was This Post Helpful? 1
  • +
  • -

#13 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 10:16 AM

View Posteclipsed4utoo, on 09 April 2012 - 11:00 AM, said:

Hmm....I had no problems adding a Custom Control project(called CalendarControl) to a solution, adding a Custom Control to the project, inheriting from Calendar, building, adding a reference from the UI project to the DLL of the custom control project, adding the XMLNS, and adding the control to the form.

Now when I added the XMLNS, it gave me this when choosing it from IntelliSense...

xmlns:myControls="clr-namespace:CalendarControl;assembly=CalendarControl"




So, i picked the actual dll generated in the debug folder of my custom control instead of the one presented in the projects tab when adding a reference and that fixed my issue. Pretty dumb... but what is that dll in the projects folder for then? Thanks very much for you help
Was This Post Helpful? 0
  • +
  • -

#14 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 10:30 AM

I was able to do it with both the DLL reference and project reference, and both worked fine for me. Not sure why your's didn't work. What version of WPF are you using?
Was This Post Helpful? 0
  • +
  • -

#15 tsackey  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 48
  • Joined: 11-March 10

Re: Can't reference an assembly in Xaml

Posted 09 April 2012 - 10:31 AM

Am using 4.0
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2