Le réseau pour les développeurs > Forums - Accueil > Windows Presentation Foundation (WPF) > xmlns where the assembly varialble refers to a dll that localized with an file URL - possible?
Poser une questionPoser une question
 

Traitéexmlns where the assembly varialble refers to a dll that localized with an file URL - possible?

  • mercredi 28 octobre 2009 11:03Schwartzenberg Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Like to do:

    xmlns:Modul="clr-namespace:CustomControlLibrary1;assembly=CustomControlLibrary1"

    but where  assembly  refers to something like   "C:\MyLiib\CustomControlLibrary1.dll"

    I'd hope this be possible ... but i must have got the syntax wrong.

    What to do?

    It´s because i am using Kaxaml to visualize my xaml.

    Thanks,
    Paul

Réponses

  • jeudi 29 octobre 2009 12:35Olaf Rabbachin Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    Hi Paul,

    I don't know whether it'd be possible to, at runtime, reference a DLL in a path (I doubt it).
    However, if you have your DLL in a sub-directory of your solution, then you can add a reference to it. In your solution, right-click References and select Add Reference . In the dialog, click the Browse tab and locate your DLL, then click OK.

    I usually have a separate AppReferences folder in my solutions and copy additional DLLs into that folder, i.e. DLLs like WPFToolkit.dll or RibbonControlsLibrary.dll. In your XAML-files, you can then add your NS as desired; IntelliSense will also be able to locate your assemblies after you have added the DLL-reference to help you create your NS-reference.

    Cheers,
    Olaf
  • lundi 9 novembre 2009 08:56Jim Zhou - MSFTModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée

    Hi Schwartzenberg,

    I got the feecback from product team, they said that there are no changes in "clr-namespace:" uri support in WPF4 or SL4, however, in .NET4.0, you may be able to build support for this yourself, you could subclass XamlSchemaContext (which handles finding types given an xmlns and a type name).

    Hope this makes sense for you.
    Thanks.


    Jim Zhou -MSFT

Toutes les réponses

  • jeudi 29 octobre 2009 12:35Olaf Rabbachin Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    Hi Paul,

    I don't know whether it'd be possible to, at runtime, reference a DLL in a path (I doubt it).
    However, if you have your DLL in a sub-directory of your solution, then you can add a reference to it. In your solution, right-click References and select Add Reference . In the dialog, click the Browse tab and locate your DLL, then click OK.

    I usually have a separate AppReferences folder in my solutions and copy additional DLLs into that folder, i.e. DLLs like WPFToolkit.dll or RibbonControlsLibrary.dll. In your XAML-files, you can then add your NS as desired; IntelliSense will also be able to locate your assemblies after you have added the DLL-reference to help you create your NS-reference.

    Cheers,
    Olaf
  • jeudi 29 octobre 2009 12:53Schwartzenberg Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    i'm using something else to view xaml rather than VS.

    i'm using (in my case :-)) Kaxaml. 

    it might be an idea to find a tool to see the folder from where kaxaml is executed (instead of doing a long disk search) and then put my dll in this folder.

    but using a absolute file url would solve a lot, pending the above.

    what does add references actually do, that allows the designer to "see" the dll .. ?  Well i assume it is for linking after doing the compiling.  Allows the executable to be linked to the executable.  But why require this with xaml namespaces?

    ... Pending the writing plugins for other xaml viewers that add the ..."Add Reference ..." feature to them...  the absolute file url to the dll would do .. it is after-all all based on reflection (i think)...  Well i dont know actually which is why i like this thread :-)
    Thanks, Paul
  • jeudi 29 octobre 2009 12:58DanielRose Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     

    As Olaf stated, you have to add a reference to the library and then you can use it to refer to the assembly in your XAML. However, Kaxaml is unable to deal with this, so you'll have to use a different editor.

  • jeudi 29 octobre 2009 13:27Olaf Rabbachin Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hi Paul,

    if you want to visualize your XAML outside of VS (like KaXaml or XamlPad), you'll have to use an editor that can actually resolve those namespaces, no way around that, I'm afraid.

    Cheers,
    Olaf
  • lundi 2 novembre 2009 09:05Jim Zhou - MSFTModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hi Schwartzenberg,

    Since Kaxaml tool does not provide functionality to import .dll file by adding the absolute path in XAML markup, you can switch to use Visual Studio to add references to the necessary .dll files, then you can use the types in the assembly.

    Thanks.
    Sincerely.





    Jim Zhou -MSFT
  • mercredi 4 novembre 2009 08:27Jim Zhou - MSFTModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hi Schwartzenberg,

    Do you have some special reason that you do not want to use Visual Studio? Have you considered the ideas other community members shared above?

    Thanks.
    Sincerely.
    Jim Zhou -MSFT
  • mercredi 4 novembre 2009 10:32Schwartzenberg Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     

    Your right ... i could simply create a new solution with one simple WPF project ... and then add references to the dll's i need, and then use the syntax available for baseing xaml namespaces on the included assembly content.

    The dll's are produced in the more complicated VS solution, and complexities (like long build times) would be abstracted away.

    Where BTW could i make the suggestion for future versions of the VS XAML editor to allow assembly="c:\my_voll_url_path" syntax?
    When also being able to add references to a project, it would (possibly) be a nice redundancy. 
    At the proper place where i could make this suggestion, i believe i'd hear something coherent on the (possibly many) minuses concerning it.

    Thanks,
    Paul

    BTW ...these links help get a larger WPF soluton to build faster (use more memory - info here helped; allowing more handles on the machine - info here helped).  Thus constantly making external sand-box solutions for testing ideas ... a bit less necessary.


    Thanks, Paul
  • mercredi 4 novembre 2009 13:33DanielRose Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    The problem will be that this information will be used to locate the assembly at runtime. So if the assembly isn't at that location, the application will crash (ex. on you user's machine where the file is in C:\Programme\... or C:\Program Files (x86)\... instead of C:\Program Files\...).
  • vendredi 6 novembre 2009 09:38Jim Zhou - MSFTModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hi Schwartzenberg,
    -->Where BTW could i make the suggestion for future versions of the VS XAML editor to allow assembly="c:\my_voll_url_path" syntax?

    As far as I know, in the latest WPF release, the absolute assembly path in XAML markup is not supported, I will try to contact producd team to consult weather they have plan to add this functionality in the next release.

    Thanks.
    Sincerely.
    Jim Zhou -MSFT
  • lundi 9 novembre 2009 08:56Jim Zhou - MSFTModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée

    Hi Schwartzenberg,

    I got the feecback from product team, they said that there are no changes in "clr-namespace:" uri support in WPF4 or SL4, however, in .NET4.0, you may be able to build support for this yourself, you could subclass XamlSchemaContext (which handles finding types given an xmlns and a type name).

    Hope this makes sense for you.
    Thanks.


    Jim Zhou -MSFT