How to target .Net other than 4.0 ?

Using Microsoft Windows Presentation Foundation and Syncfusion WPF Libraries

How to target .Net other than 4.0 ?

Postby PGilbert on Tue Mar 15, 2016 2:52 am

In a )CLEAR WS if I do:

      ⎕USING←'System.Windows.Controls,WPF/PresentationFramework.dll'
ListBox
(System.Windows.Controls.ListBox)


and if I look at the version loaded of PresentationFramework.dll by doing:

      ]assemblies
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
bridge141_unicode, Version=14.1.26323.0, Culture=neutral, PublicKeyToken=eb5ebc232de94dcf
msvcm80, Version=8.0.50727.6229, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
dyalognet, Version=14.1.26323.0, Culture=neutral, PublicKeyToken=eb5ebc232de94dcf
PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


The loaded version of PresentationFramework.dll is version 4.0, I would like to use instead PresentationFramework.dll version 4.5.1 or better, how do I target a specific version of .Net to be used by the APL interpreter ?

The value of dyalog.exe.config that I am using looks like that:
Code: Select all
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="MJHSoftware;Syncfusion/4.5;Syncfusion"/>
    </assemblyBinding>
    <!-- <NetFx40_LegacySecurityPolicy enabled="true"/> -->
    <loadFromRemoteSources enabled="true"/>
  </runtime>
</configuration>


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

Re: How to target .Net other than 4.0 ?

Postby PGilbert on Tue Mar 15, 2016 2:13 pm

By using Telerik JustDecompile I was able to confirm that the PublicKeyToken given by ]assemblies is the one of .net 4.6 as requested by the dyalog.exe.config file. I was not able to find the PublicKeyToken of PresentationFramework using VisualStudio however.
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to target .Net other than 4.0 ?

Postby JohnD|Dyalog on Thu Mar 17, 2016 10:33 am

PGilbert wrote:By using Telerik JustDecompile I was able to confirm that the PublicKeyToken given by ]assemblies is the one of .net 4.6 as requested by the dyalog.exe.config file. I was not able to find the PublicKeyToken of PresentationFramework using VisualStudio however.


Hello Pierre,

I think you've answered the question yourself there. It looks like all versions of the file report 4.0 as the .NET version - althought the file version my be different. Here's what I did:

      ⎕USING←'System.Windows.Controls,WPF/PresentationFramework.dll'
l←⎕new ListBox
l.GetType.Assembly
PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
l.GetType.Assembly.CodeBase
file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll
⎕using,←⊂'System.Diagnostics,system.dll'
(FileVersionInfo.GetVersionInfo⊂8↓l.GetType.Assembly.CodeBase).FileVersion
4.6.1073.0


So it looks like the 4.6 version is being loaded anyway. I guess the framework is always redirecting to the latest version.

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

Re: How to target .Net other than 4.0 ?

Postby PGilbert on Thu Mar 17, 2016 11:39 am

Hello John, thanks for answering because I was not sure of my answer since this public token does not seems to be unique among dlls.

I have tried your reasoning with a ListBox created from XAML and got the same result:

      lb
<ListBox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ListBox>

⎕USING←'System.Windows.Markup,WPF/PresentationFramework.dll'
lb_obj←XamlReader.Parse(⊂lb)

⎕USING,←⊂'System.Diagnostics,system.dll'
(FileVersionInfo.GetVersionInfo⊂8↓lb_obj.GetType.Assembly.CodeBase).FileVersion
4.6.1073.0


This is a pretty neat way to find out the .Net version used by the interpreter.

Thanks for that.

P.S.: May be if the ]assemblies script could be modified to show the .FileVersion à la JD it would be appreciated and useful (-fileVersion switch maybe ?).
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to target .Net other than 4.0 ?

Postby PGilbert on Sun Mar 20, 2016 2:35 pm

Following the comments of John on previous post here is a function that will give the name, version and location of the loaded assemblies. Very useful to know what is loaded with their 'real' version and where it came from.

Code: Select all
 r←GetAssemblies;assemblies;assembly;inter;⎕USING
 ⍝ Show the Current .Net assemblies that are loaded.
 ⍝ Returns a 3 column matrix representing the name, version and location of the assembly loaded.
 ⍝
 ⍝ Inspired from: http://www.dyalog.com/forum/viewtopic.php?f=35&t=990

 r←0 3⍴⍬

 ⎕USING←'System' 'System.Diagnostics,system.dll'

 :Trap 0
     assemblies←AppDomain.CurrentDomain.GetAssemblies

     :For assembly :In assemblies

         :If assembly.IsDynamic
             inter←2↑(~inter=',')⊂inter←assembly.ToString
             r⍪←inter,⊂'Dynamic assembly with no location'
         :Else
             inter←1↑(~inter=',')⊂inter←assembly.ToString
             inter,←⊂(FileVersionInfo.GetVersionInfo(⊂assembly.Location)).FileVersion
             r⍪←inter,⊂assembly.Location
         :EndIf
     :EndFor

 :Else
    ⍝ If ⎕USING←0⍴⊂'', it will bug.
     r←0 3⍴⍬
 :End
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to target .Net other than 4.0 ?

Postby JohnD|Dyalog on Mon Mar 21, 2016 9:13 am

Nice. I think that Assembly.IsDynamic is in .NET 4.0 onwards only. Having said that, I think pretty much everyone is running on at least 4 anyway.
User avatar
JohnD|Dyalog
 
Posts: 74
Joined: Wed Oct 01, 2008 9:35 am

Re: How to target .Net other than 4.0 ?

Postby norbertjurkiewicz84 on Wed Apr 06, 2016 1:34 pm

I will backup JDs claim on .NET 4. Over the last two years we moved a very upgrade conservative user base to Dyalog 14.0 and .NET 4.0 full profile with only a handful of users needing any extra downloads.
(It's the little things that make the difference :-)
User avatar
norbertjurkiewicz84
 
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm


Return to WPF & Syncfusion

Who is online

Users browsing this forum: No registered users and 1 guest