Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by xenvy04_unity · Mar 23, 2018 at 10:58 PM · plugindll.netlibrarydllimport

Getting SSH.NET to work in Unity

My steps:

Downloaded the library from https://github.com/sshnet/SSH.NET

Built the 3.5 framework one and copied the DLL at *\src\Renci.SshNet.NET35\bin\Debug\ into Unity assets

Wrote a script that should output "C" in a text field:

 using System.IO;
 using Renci.SshNet;
 using Renci.SshNet.Common;
 using Renci.SshNet.Sftp;
  
 String Host = "ftp.csidata.com";
 int Port = 22;
 String RemoteFileName = "TheDataFile.txt";
 String LocalDestinationFilename = "TheDataFile.txt";
 String Username = "yourusername";
 String Password = "yourpassword";
  void Start(){
 using (var sftp = new SftpClient(Host, Port, Username, Password))
 {
     sftp.Connect();
  
     using (var file = File.OpenWrite(LocalDestinationFilename))
     {
         sftp.DownloadFile(RemoteFileName, file);
         tex.text += "C";
     }
  
     sftp.Disconnect();
 }
 }

Build solution aimed at HoloLens:

SDK - Universal 10

Target device - Any device

UWP Build Type - D3D

Changed .dll settings to SDK: Any SDK ; ScriptingBackend: Dot Net ; Don't process: Checked

Unity version: 5.5.1f1 Visual Studio version: 2015 update 3

Expected results: Successful connection and letter "C" in text box

Actual results: No change to textbox. VS Debugger tells me:

An exception of type 'System.IO.FileLoadException' occurred in Renci.SshNet.dll but was not handled in user code

Additional information: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Thank you in advance for the help.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Mar 24, 2018 at 10:52 AM

I found something that led me to the following assumption. The dll you compiled makes use of the NET core library, while nothing else of your code is. So unity is unaware of this dependency and does not provide it. Prove me wrong but I guess it's missing from the VS project folder. I found adding this line to any script makes Unity Core aware:

 System.Collections.SortedList lst = new SortedList();

I found this here:
https://unity3d.com/de/partners/microsoft/porting-guides

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xenvy04_unity · Mar 24, 2018 at 06:44 PM 0
Share

I tried adding the line to the class as well as Start but unfortunately it doesn't change anything. Same error message. :Y

I've also tried building the UAP10 sln that's provided by SSH.NET and I get the same result.

avatar image xenvy04_unity · Mar 24, 2018 at 07:34 PM 0
Share

If I add the lines

 AssemblyName Core = new AssemblyName("System.Core, Version=3.5.0.0, Culture=neutral, Public$$anonymous$$eyToken=b77a5c561934e089, Retargetable=Yes");

 Assembly.Load(Core);

It stops throwing the Exception but it also still doesn't connect properly. Also if I put it before any other code, that code no longer runs properly...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

78 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to link to scripts in the Package Manager when building a dll. 0 Answers

The classes in the module cannot be loaded? 0 Answers

How do you use a class from a .dll file? 1 Answer

How do I use .NET 4.5 managed DLL called by a native DLL (Not easy, I swear I read doc) 0 Answers

ML.NET in unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges