viewpoint-particle

Author Topic: Another CLR Refresher  (Read 551 times)

stanl

  • Pundit
  • *****
  • Posts: 650
Another CLR Refresher
« on: July 23, 2017, 07:46:31 am »
Got tasked with moving data from the Sytel Dialer into ECH Microstrategy. Developed a very small, but fantastic WB script to create the files for upload - to an SFTP site. At that point I felt I could use WINSCP: First checked that it worked through Powershell:

Add-Type -Path "C:\winscp\WinSCPnet.dll"

OK.  Then WB

Code: Winbatch
assemblydir = 'C:\WinSCP'
ObjectClrOption( 'appbase', assemblydir )
ObjectClrOption ( 'use', 'WinSCP, Version=1.0.7.3446, Culture=neutral' )
 

which errors with unable to load dll.  My first thought is the version=, but then how do I determine that as the dll is not registered as an assembly.  So, stick with Powershell and call it from WB. Finally, hoping to avoid the fingerprint in the WB sample script:

Code: Winbatch
If IsDefined(Sftp)
   objSessionOptions.SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" ;REQUIRED by SFTP     ; MODIFY TO FIT YOUR NEEDS
EndIf
 

I am going to try

$sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey

and if anyone has any experience with how successful that might be I would appreciate comments.

td

  • Tech Support
  • *****
  • Posts: 2185
    • WinBatch
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 786
    • Data & Stuff Inc.
Re: Another CLR Refresher
« Reply #2 on: July 23, 2017, 05:44:02 pm »
Just right-click on the DLL, Properties and Details.  It shows the File Version there.

Jim

stanl

  • Pundit
  • *****
  • Posts: 650
Re: Another CLR Refresher
« Reply #3 on: July 24, 2017, 02:58:25 am »
Just right-click on the DLL, Properties and Details.  It shows the File Version there.

Jim

DOIT :o     Need coffee. Thanks Jim.

stanl

  • Pundit
  • *****
  • Posts: 650
Re: Another CLR Refresher
« Reply #4 on: July 24, 2017, 06:16:55 am »
Well tried both the version and file version of the .dll but just get the attached error. But no problem just sticking with running a .ps1 from WB; generic code and since the .ps1 is text can either load or create from scratch.


td

  • Tech Support
  • *****
  • Posts: 2185
    • WinBatch
Re: Another CLR Refresher
« Reply #5 on: July 24, 2017, 06:39:03 am »
The assembly file version is not necessarily the same thing as the assembly version.  If you look at any of the assemblies stored in the GAC, you will see the difference.  Also, you don't need to use the version information with non-GAC assemblies.  And with the latest version of WinBatch you don't need to use it with any assembly.

Code: Winbatch
ObjectClrOption( 'appbase', DirScript() )
ObjectClrOption('use','WinSCPnet')
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2185
    • WinBatch
Re: Another CLR Refresher
« Reply #6 on: July 24, 2017, 11:06:24 am »
And the following works with the the latest WinSCP assembly:

Code: Winbatch
ObjectClrOption('use','WinSCPnet, Version=1.3.7.7601, Culture=neutral')
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


stanl

  • Pundit
  • *****
  • Posts: 650
Re: Another CLR Refresher
« Reply #7 on: July 24, 2017, 12:08:42 pm »
The assembly file version is not necessarily the same thing as the assembly version.  If you look at any of the assemblies stored in the GAC, you will see the difference.  Also, you don't need to use the version information with non-GAC assemblies.  And with the latest version of WinBatch you don't need to use it with any assembly.

Code: Winbatch
ObjectClrOption( 'appbase', DirScript() )
ObjectClrOption('use','WinSCPnet')

Yep, ignore the version etc... and works.  Thanks.  I think in this instance I would prefer a pure WB solution over Powershell because I get more visibility over the results.

JTaylor

  • Pundit
  • *****
  • Posts: 786
    • Data & Stuff Inc.
Re: Another CLR Refresher
« Reply #8 on: July 24, 2017, 03:49:16 pm »
I used the File Version and it works fine for me.

Jim

stanl

  • Pundit
  • *****
  • Posts: 650
Re: Another CLR Refresher
« Reply #9 on: July 25, 2017, 03:06:23 am »
I used the File Version and it works fine for me.

Jim

This being a company computer where I have limited admin rights, there may be some unknowns because I tried a connection from home in WB studio with version info and it worked. Something to be said about WB's flexibility ;D

td

  • Tech Support
  • *****
  • Posts: 2185
    • WinBatch
Re: Another CLR Refresher
« Reply #10 on: July 25, 2017, 06:40:13 am »
As a general rule I don't use version information when loading assemblies unless I am using functionality that is only available in a specific version.   
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 786
    • Data & Stuff Inc.
Re: Another CLR Refresher
« Reply #11 on: July 25, 2017, 07:29:02 am »
Understood.  I was just responding to the original question and that I only mentioned using the file version in this case because I knew it worked.  Deana's post was in response to a question I had about using WinSCP, if I remember correctly.

Jim