locked
Issue adding external alias - VS 2010 bug

    Question

  • I am having a tough time setting up an external alias.  I added references to these two items:
      - Telerik.Windows.Controls.Scheduler
      - Telerik.Windows.Controls.ScheduleView

    Telerik is a set of components (in this case for WPF).  When using both of these, they require one be added as an external alias as they contain duplicate definitions of some items.  I made the following changes changes:

      - Changed the Scheduler reference alias to 'sched', (left ScheduleView as 'global').
      - Added the following class to my program:

    extern alias sched;

    namespace Work_Planner
    {
       public class RadScheduler : sched::Telerik.Windows.Controls.RadScheduler
       {
       }
    }

    NOTE: I've used BOTH my application's own namespace here as well as a new one.

      - Added an xmlns to my XAML (again, I tried my MAIN app namespace, as well as a new one):

    xmlns:local="clr-namespace:Work_Planner"
    xmlns:sch="clr-namespace:SchedNamespace"

    Added the component in my XAML (again, both namespaces have been tried):

    <local:RadScheduler>
    <sch:RadScheduler>       

    And finally added the extern declarations and modified any using clauses in code behind forms:

    extern alias sched; // first line - before usings
    using ...........;
    using sched::Telerik.Windows.Controls.Scheduler;

     

    After doing this, it still did not work.  I found a forum topic on it as well as a Microsoft Bug report:

    http://stackoverflow.com/questions/2502640/the-extern-alias-xxx-was-not-specified-in-a-reference-option/

    https://connect.microsoft.com/VisualStudio/feedback/details/615953/reference-aliases-are-ignored-on-projects-containing-some-xaml-files

    I followed the steps in the workaround listed in the bug report.  Just before the end of the csproj file (just before the </Project> line) I added the following:

      <Target Name="solveAliasProblem" >
        <ItemGroup>
          <ReferencePath Remove="C:\Program Files (x86)\Telerik\RadControls for WPF Q3 2010\Binaries\WPF\Telerik.Windows.Controls.Scheduler.dll"/>
          <ReferencePath Include="C:\Program Files (x86)\Telerik\RadControls for WPF Q3 2010\Binaries\WPF\Telerik.Windows.Controls.Scheduler.dll">
            <Aliases>sched</Aliases>
          </ReferencePath>
        </ItemGroup>
      </Target>
      <PropertyGroup>
        <CoreCompileDependsOn>solveAliasProblem;$(PrepareResourcesDependsOn)</CoreCompileDependsOn>
      </PropertyGroup>

     

    It still does not work.  Now I get an error when building on my main window in the generated code file.  The error is as follows:

    Error 1 The type or namespace name 'Scheduler' does not exist in the namespace 'Telerik.Windows.Controls' (are you missing an assembly reference?) C:\Source Code\PN.Net\Work Planner\Work Planner\obj\x86\Debug\MainWindow.g.cs 41 32 Work Planner


    Looking at the g.cs file it does reference Telerik and does not contain the 'extern alias' at the top.  What can I do?  I can't modify this file.  The bug doesn't even look to be addressed in SP1.


    Any thoughts or ideas would be appreciated!
    Paul

    Wednesday, February 23, 2011 10:38 PM

All replies

  • Hi Paul,

     

    Thanks for your post.

    I'm not familiar with Telerik but I suspect you have to install something else.

    It seems Scheduler type is in other assembly but use the same namespace "Telerik.Windows.Controls".

    Also you can post another thread at:

    http://www.telerik.com/community/forums/wpf.aspx

    I need some time to do further research on this issue and hope you can get more information there.


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 25, 2011 6:32 AM
  • Thank you for the reply.  

    There's nothing missing from the installations.  I can use either reference and corresponding component separately.  Just not together.  I have already posted on Telerik's forums and the resulting response was to use an external alias on the Scheduler and leave ScheduleView as global which I have done.  The 615953 issue in Visual Studio on the MS Connect site is exactly my problem but I cannot get the workaround to work.  I'm hoping I'm doing something wrong that can be fixed.

    I did create a sample project without referencing my application's namespace in my XAML and it did work.  Removing all references in my large application will be difficult.

    Friday, February 25, 2011 2:18 PM
  • Hello,

    My apologies for posting again, but I'm wondering if the statement "I need some time to do further research" meant that this thread would be updated again.  If not, I'll need to go another route, if so I will wait to hear back before continuing development on this application.

    Paul

    Thursday, March 03, 2011 5:59 PM
  • Hi Paul,

     

    Thanks for your feedback and sorry for the delay.

    I did some research but cannot reproduce your issue,

    I think the best approach it to look for some workarounds for your project if it is urgent.

    Thanks for understanding and wish you a good weekend.


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 04, 2011 9:14 AM
  • I workaround this issue in XAML using two aliases for one assembly (with comma delimited): "global, someAliasName"

    In code where I have a class conflict I use someAlliasName::someNamespace.someClass.

    In XAML xmlns:a="clr-namespace:someNamespace;assembly=someAssembly"

    Hope this helps somebody who have a problem like this.


    Tuesday, August 23, 2011 12:37 PM