Failure on using .NET assembly in VB2010

Advertisement

kitsune
Joined:
Posts:
2

Failure on using .NET assembly in VB2010

I have referenced the WinSCP.dll in my project.
With the import command (Imports WinSCP), the session object and the events called in the VB.net syntax are fine.

However, once I deploy by running in debug mode. VB prompts the error message as below:
"Could not load file or assembly 'WinSCP, Version=1.0.5.2937, Culture=neutral, PublicKeyToken=b5f19f5762436b89' or one of its dependencies. The module was expected to contain an assembly manifest."

Would someone advise on this?
Thanks so much!

Reply with quote

Advertisement

gjs
Joined:
Posts:
9

It's a naming conflict between winscp.dll and winscp.exe. VS tries to load the exe thinking it is the referenced dll. I found that I must just reference the dll in my project and so it is copied to the output directory but do not include winscp.exe in the project just copy it to the output directory, so the dll knows where to find it.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

gjs wrote:

It's a naming conflict between winscp.dll and winscp.exe. VS tries to load the exe thinking it is the referenced dll. I found that I must just reference the dll in my project and so it is copied to the output directory but do not include winscp.exe in the project just copy it to the output directory, so the dll knows where to find it.
Thanks, that's correct.
See https://winscp.net/eng/docs/library_install#vs

Reply with quote

kitsune
Joined:
Posts:
2

Thanks all.

However, I have read the page https://winscp.net/eng/docs/library_install#vs before and have renamed the dll file as suggested before including in the reference.
Also, I have copied the exe file to the debug folder but the problem is not yet solved.
Thus, I made this post and would like to have advice from you all experts.

Please also find the attached screen capture of my vs debug environment for reference.
Would someone advise on this?
Thanks so much!

WinSCP location.jpg

Reply with quote

Advertisement

gsclarke
Joined:
Posts:
3

Hello All,

I have just gone through the installation and am experiencing the same problem. The DLL is renamed and registered in V4.0.xxxx .NET framework (as per the install page), but when the app is run, get the same error message:

"Could not load file ... blah blah ... system could not find the file specified." I did pick up a version discrepancy between the DLL and EXE files, and I have fixed that and also copied the EXE file to the project "obj" folder, but still getting the same problem.

Any further thoughts on the problem.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

gsclarke wrote:

I have just gone through the installation and am experiencing the same problem. The DLL is renamed and registered in V4.0.xxxx .NET framework (as per the install page), but when the app is run, get the same error message:

"Could not load file ... blah blah ... system could not find the file specified." I did pick up a version discrepancy between the DLL and EXE files, and I have fixed that and also copied the EXE file to the project "obj" folder, but still getting the same problem.
Have you tried to debug this using fuslogvw?

Reply with quote

gsclarke
Joined:
Posts:
3

martin wrote:

Have you tried to debug this using fuslogvw?

Many thanks - that tool did the trick. The problem was that the Winscp.* files were not in the project's bin/debug directory where I was running the application from. I then stumbled onto the next problem with the invalid manifest error. There seems to be a bit of confusion with the install instructions...

According to the instructions, the DLL must be renamed to winscpnet.dll (anything other than winscp.dll to avoid confusion with winscp.exe) and then added to the project as a reference. However, the invalid manifest problem was solved if I renamed the file back to winscp.dll.

I just need to sort out my sshhostkey value and then I can confirm if everything is working properly.

Reply with quote

Advertisement

gsclarke
Joined:
Posts:
3

All is good in the WinSCP world!

8)

I successfully ran through my program to upload a file to SFTP sever. So, it appears the DLL name should be "winscp.dll" in the project/bin/debug|release/ folder.

PS: Running VS2012 Pro on Win7.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

gsclarke wrote:

I successfully ran through my program to upload a file to SFTP sever. So, it appears the DLL name should be "winscp.dll" in the project/bin/debug|release/ folder.
Ok, thanks for your investigation. Alternatively, you can use WinSCP 5.2.x assembly that is built as winscpnet.dll.

Reply with quote

Advertisement

You can post new topics in this forum