Hello,

we (as a large company) are evaluating the Rebex SFtp components in our project (in the mean time all needed Rebex licences are being purchased). We have created one simple dll in C++/CLI with CLR Support. This dll exports one simple function, which will be called from vb6 and from excel vba. Everything works so that we are able to use any .NET functionality in that way without having any errors. If we try to use any SFTP functionality and reference Rebex assemblies in the C++/Cli dll our excel vba crashes as well as our vb6 project. If we call the exported function from a compled vb6 exe or from .net everything also works fine. So, the main problem is our vba macro in excel.

What could be the reason of the error? Any trial checks in the rebex dlls?

I have also prepared a small application to demonstrate the error. I could upload it if it helps.

Thanks in advance.

Best regards, Igor

asked 27 Sep '11, 13:02

IgorJ's gravatar image

IgorJ
152
accept rate: 0%

edited 27 Sep '11, 13:06

Hello, is there any error message? It might be the trial check - indirectly calling Rebex assemblies from Excel an VBA isn't a tested or common scenario. A sample application demonstrating the error should make it possible to tell what is going on. Also, consider using Sftp object's LogWriter to create a log (http://www.rebex.net/kb/logging.aspx) - if it is a trial check error, the log would clearly state it.

(27 Sep '11, 16:17) Lukas Pokorny ♦♦

Hi, there is no error message. It crashes if I only create the Sftp object. How can I upload the sample application?

(27 Sep '11, 16:34) IgorJ

If I try to debug this crash with an external debugger I get: FileNotFoundException. The file or Assembly "Rebex.Net.Sftp, Version=2.0.4086.0, Culture=neutral, PublicKeyToken=1c4638788972655d or any dependency can not be loaded. All 4 Rebex dlls are present in the directory.

(27 Sep '11, 17:58) IgorJ

ok, it seems that is a general microsoft problem.. any statically linked .net assembly failes to be loaded in C++CLI in that case...

(27 Sep '11, 18:19) IgorJ

Have you tried placing Rebex DLLs into Global Assembly Cache? That might do the trick.

(29 Sep '11, 11:53) Lukas Pokorny ♦♦

Thanks, it helps! :) But unfortunately this is not the way out of this problem :( We can not put 4 Rebex assemblies into the gac on 5000 client computers. The existing assemblies must be loaded from the current directory. Is there any way out? I know that this is a microsoft problem, but may be you know the solution?

(29 Sep '11, 18:12) IgorJ
showing 5 of 6 show 1 more comments

I've found the solution by myself. :) The problem is that the rebex assembly can not be found (?) by the .NET Loader, even if it exists in the same directory with the excel sheet (!!). It is possible to sign the rebex assembly and place it into the GAC to solve the problem (Thanks Lukas Pokorny). But the better solution would be to use the AppDomain::CurrentDomain->AssemblyResolve event to help to the .NET Loader to find the missing assembly.

link

answered 30 Sep '11, 12:16

IgorJ's gravatar image

IgorJ
152
accept rate: 0%

Thanks for letting us know about this solution, we have not been aware of this event! I was about to suggest loading the assembly explicitly by calling Assembly.LoadFrom, but your solution is much better.

(30 Sep '11, 13:39) Lukas Pokorny ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×141

Asked: 27 Sep '11, 13:02

Seen: 289 times

Last updated: 30 Sep '11, 13:39