How to use ⎕Using

Using Microsoft Windows Presentation Foundation and Syncfusion WPF Libraries

How to use ⎕Using

Postby PGilbert on Tue Mar 31, 2015 1:00 am

If you define a variable named test_xaml with the following XAML:
Code: Select all
<Window
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:sf="clr-namespace:Syncfusion.Windows.PropertyGrid;assembly=Syncfusion.PropertyGrid.Wpf"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   <sf:PropertyGrid x:Name="PGrid"/>
</Window>


Now if you try the function test1 it is working:
Code: Select all
 test1;⎕USING

 ⎕USING←'Syncfusion.Windows.PropertyGrid,Syncfusion/4.5/Syncfusion.PropertyGrid.Wpf.dll'
 ⎕USING,←⊂'System.Windows.Markup,WPF/PresentationFramework.dll'
 ⎕←XamlReader.Parse(⊂test_xaml)


if you define the functions test2 and FixMe, test2 is not working (the Xaml cannot be fixed because PropertyGrid is not found)
Code: Select all
 obj←FixMe xaml;⎕USING
 ⎕USING←'System.Windows.Markup,WPF/PresentationFramework.dll'
 obj←XamlReader.Parse(⊂xaml)

Code: Select all
 test2;⎕USING
 ⎕USING←'Syncfusion.Windows.PropertyGrid,Syncfusion/4.5/Syncfusion.PropertyGrid.Wpf.dll'
 FixMe test_xaml


Now for the function test3 define as:
Code: Select all
 test3;⎕USING
 ⎕USING←'Syncfusion.Windows.PropertyGrid,Syncfusion/4.5/Syncfusion.PropertyGrid.Wpf.dll'
 :Trap 0
     Anything Here
 :EndTrap

 FixMe test_xaml


it is working ! Looks to me that after defining the ⎕USING and before fixing the XAML the interpreter needs to be 'forced' to search in ⎕USING to load it into memory. In the function test1 it is done when the interpreter is reading the line XamlReader.Parse(⊂test_xaml). In test2 when reading the line 'FixMe' the interpreter knows already that it is a function and will not search with ⎕USING making the function to fail. In test3 it will search in ⎕USING to try to find 'Anything Here' and that will load the dll into memory before running the function 'FixMe'.

Question: Is there a better way to write test3 or what is it that I don't understand ?

Thanks in advance,

Pierre Gilbert

P.S.: This has to be tried on a computer that has not the Syncfusion dlls loaded in the GAC (Global Assembly Cache) directory. Only into the Syncfusion/4.5/ directory (like for a RunTime user).
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby JohnD|Dyalog on Tue Mar 31, 2015 10:06 am

Hello Pierre.

I think the problem here is that the assembly reference to "Syncfusion.Windows.PropertyGrid;assembly=Syncfusion.PropertyGrid.Wpf" in the XAML is not resolved via ⎕USING but via the framework's internal mechanism. If I understand it correctly it'll look at the assemblies already loaded into the appdomain, then the GAC, and then any additional directories set up in dyalog.exe.config.

The interpreter optimizes multiple assignments to ⎕USING so that assemblies are loaded all at once when a reference might need them - thus the behaviour you are seeing - the assemblies are not loaded into the appdomain until you force a reference.

Best Regards,
John Daintree.
User avatar
JohnD|Dyalog
 
Posts: 74
Joined: Wed Oct 01, 2008 9:35 am

Re: How to use ⎕Using

Postby PGilbert on Tue Mar 31, 2015 12:14 pm

Hello John and thanks for the answer. Is there a snippet of code that you can think off that is better than (:Trap 0 ⋄ Something ⋄ :EndTrap) to use to 'force' the interpreter to load the dlls of ⎕Using into APL memory ?
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby PGilbert on Thu Apr 02, 2015 2:51 pm

Hello everyone, I have put my understanding of ⎕USING and XAML on the APL Wiki at this page: http://aplwiki.com/wpfXamlDemo. If anything said can be improved, please let me know.
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby PGilbert on Mon Apr 13, 2015 2:58 pm

JohnD|Dyalog wrote:If I understand it correctly it'll look at the assemblies already loaded into the appdomain, then the GAC, and then any additional directories set up in dyalog.exe.config.


Hello John, could you give us an example of how to setup a search directory in dyalog.exe.config for the 'Syncfusion/4.5/' directory included with the Dyalog interpreter. That way we will not need to setup ⎕USING for the Syncfusion assemblies when using only XAML (sweet). I have tried myself but can't make it work.

Thanks in advance,

Pierre Gilbert
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby MikeHughes on Tue Apr 14, 2015 6:11 am

Hi Pierre,

Your Dyalog.Exe.Config file should contain the following lines (in red).
In this case it allows assemblies stored in [Dyalog]/MJHSoftware and [Dyalog]/Syncfusion/4.5. With those entries you can use in XAML without any problems - as if the assemblies were in [Dyalog]

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"></supportedRuntime>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="MJHSoftware;Syncfusion/4.5"></probing>
</assemblyBinding>
<!-- <NetFx40_LegacySecurityPolicy enabled="true"/> -->
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
User avatar
MikeHughes
 
Posts: 86
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK

Re: How to use ⎕Using

Postby PGilbert on Tue Apr 14, 2015 10:04 am

Thanks Michael its working !

What I have done is go in Menu Option -> Configure, than Click on the .Net Framework Tab and uncheck 'Specify .Net Version' and I close the interpreter. After that I went into the dyalog.exe directory and modify the dyalog.exe.config file with Notepad so it looks like you said in the previous post:

Code: Select all
<configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0">
      </supportedRuntime>
   </startup>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <probing privatePath="MJHSoftware;Syncfusion/4.5">
         </probing>
      </assemblyBinding>
      <!-- <NetFx40_LegacySecurityPolicy enabled="true"/> -->
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>


Is it correct to say that because we want to use a 'custom' dyalog.exe.config file we have to let uncheck 'Specify .Net Version' all the time from now on and maintain that file manually ?
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby MikeHughes on Wed Apr 15, 2015 7:45 am

Pierre,
As long as you don't go into the option again and "re-save" the config file its ok.

However the best option is to persuade Dyalog to make the change permanent :-)

I certainly think the Syncfusion directory needs to be there and I hope by the time 14.1 comes out MJHSoftware should be there too. :-)

I basically now keep a copy of my config file and copy it in whenever I upgrade.
User avatar
MikeHughes
 
Posts: 86
Joined: Thu Nov 26, 2009 9:03 am
Location: Market Harborough, Leicestershire, UK

Re: How to use ⎕Using

Postby PGilbert on Wed Apr 15, 2015 1:04 pm

Thanks Michael, this is answering my question. I will keep unchecked 'Specify .Net Version' and also keep a backup of the dyalog.exe.config file in case I check it by error and the file is erased.

I am glad that you help me with that question and I wish I had knew that long time ago, that would have save me a lot of time and frustration.

My vote would go also for Dyalog to add to their standard dyalog.exe.config file the Syncfusion and MJHSoftware directories as permanent in that file. That way we can write examples on the forum, Wiki and tutorials that will work for everybody the same way and makes things simpler (have ⎕USING behave the same way for everyone).

Thanks for your time.

Pierre Gilbert
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to use ⎕Using

Postby Vince|Dyalog on Thu Apr 16, 2015 9:16 am

Hi Pierre and Mike,

Mike is right when he says that you should avoid using the Options->Configure->.Net Framework tab if you have a custom dyalog.exe.config.

If you tick the box and hit OK, we create a basic file. If you untick it and press OK, we erase the file.

If the file exists, we do ask if it's OK to overwrite it, but it's best to avoid it entirely if you have a custom .config.

I have logged an RFE with your comments about what could be in the .config file.

Regards,

Vince
Vince|Dyalog
 
Posts: 432
Joined: Wed Oct 01, 2008 9:39 am

Next

Return to WPF & Syncfusion

Who is online

Users browsing this forum: No registered users and 1 guest