access to .net dll in an other folder

Discussion forum about all things Team Developer 5.x and 6.x
Thomas4711
Germany
Posts: 5
Joined: 26 Feb 2018, 15:51
Location: Germany, Oberkirch

access to .net dll in an other folder

Post by Thomas4711 » 26 Feb 2018, 15:56

Hello,
I build a .net dll and created a *.apl file.
Everything ist working fine, when the .net dll is in the same folder as the exe file.
But when the .net dll is in an other folder, I get an error message, that the dll is not found.

What can I do, that the dll will be found, when it is in an other folder as the exe file?

Best regards,
Thomas

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1083
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

access to .net dll in an other folder

Post by Dave Rabelink » 27 Feb 2018, 07:08

Hi Thomas,

Normally you deploy your assemblies in the application folder or install them in the global assembly cache when it should be a shared component.
You are able to use a different folder, but as far as I know it can only be a subfolder of the application folder.

Here some info on how assemblies are located:

https://docs.microsoft.com/en-us/dotnet ... assemblies



This is info how to specify a subfolder for the assemblies. Done using <codeBase> or <probing>. This is a setting in the application.exe.config file.

https://docs.microsoft.com/en-us/dotnet ... y-location


This is an example of a config file used here. We use a third party component to enable speech recognition in the application using Philips/Nuance SpeechMagic.
The speech API is .NET and we deploy it with the application into 2 separate subfolders of the main application.

To let .NET know where the assemblies are located, we specify this in application.exe.config file like this:

Code: Select all

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0.50727" />
  </startup>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_ITDDebugger" openTimeout="00:00:05">
          <reliableSession enabled="true" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:8010/TDDebugger" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITDDebugger" contract="Gupta.TD.Compiler.Debugger.ITDDebugger" name="NetTcpBinding_ITDDebugger" />
    </client>
  </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="SpeechMagic.Interactive" />
      <probing privatePath="Philips.SpeechMike" />
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
        <codeBase version="1.2.11.0" href="SpeechMagic.Interactive/log4net.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
See at the end these probing tags:

Code: Select all

      <probing privatePath="SpeechMagic.Interactive" />
      <probing privatePath="Philips.SpeechMike" />
When the application loads the needed assemblies, it looks for the root application folder AND the supplied extra subfolders .\SpeechMagic.Interactive and .\Philips.SpeechMike.

So, if your application executable is named MyApplication.exe, the config file should be placed alongside the executable having this name: MyApplication.exe.config.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Thomas4711
Germany
Posts: 5
Joined: 26 Feb 2018, 15:51
Location: Germany, Oberkirch

access to .net dll in an other folder

Post by Thomas4711 » 27 Feb 2018, 07:21

Hello Dave,

thanks for your information.
But unfortunately I need the dll not in the GAC and not in a subfolder, but in an other folder. (The TeamDeveloper exe don't find the .net dll)
I tried to registry the dll with "gacutil" and "Regasm" but nothing worked!
Nevertheless thanks for your help:-)

Best regards
Thomas

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1083
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

access to .net dll in an other folder

Post by Dave Rabelink » 27 Feb 2018, 07:28

Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Thomas4711
Germany
Posts: 5
Joined: 26 Feb 2018, 15:51
Location: Germany, Oberkirch

access to .net dll in an other folder

Post by Thomas4711 » 27 Feb 2018, 08:57

Hi Dave,

thanks for the links.
But how can I do this with TeamDeveloper? All explanations are for .net. When I have a .net exe file, then I can do it, as explained!
But my exe file from TeamDeveloper don't find the dll.
How can I say to my exe file from TeamDeveloper, where the dll is?
I fear, it is not possible! Or do you know a way to get an ResolveEventHandler event with TeamDeveloper?

Best regards
Thomas

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1083
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

access to .net dll in an other folder

Post by Dave Rabelink » 27 Feb 2018, 09:51

Ah, yes. You are using Win32 exe to use .NET assembly using gail.

I'm not sure if this could work. But you might create a .NET wrapper (assembly) which does this for you.
Then you place the wrapper in the application folder. The assembly exports a method to load the needed assembly (using the info provided in the links).

The Win32 executable first calls the wrapper function and then try to use the other assembly as needed.

But then again, I'm not familiar with this and if this could even work. But you might want to try this to see.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Thomas4711
Germany
Posts: 5
Joined: 26 Feb 2018, 15:51
Location: Germany, Oberkirch

access to .net dll in an other folder

Post by Thomas4711 » 27 Feb 2018, 09:56

Hi Dave,

thanks for this tip.
I will try this.

Best regards,
Thomas

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1083
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

access to .net dll in an other folder

Post by Dave Rabelink » 27 Feb 2018, 09:59

And of course, when you tried this, please report the results here.
I'm curious whether this works or not, and others might also ;)
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Christof
Germany
Posts: 9
Joined: 06 Mar 2017, 07:27
Location: Frankfurt, Germany

access to .net dll in an other folder

Post by Christof » 07 Mar 2018, 09:58

We actually modified one of the generated Classes: Unify_TD_GAIL_CNETBase.
There is a method "__Base_Constructor_Overload2" which does the magic of loading custom assemblies not located in GAC. Here you can implement your own logic for locating your assemblies.

Referring to TD60, the .Net Explorer always creates this class as long as a derived class System_Object. This in turn is the base class for your .Net-Classes.
Now, when you want to use more than one assembly, you are getting duplicates of System_Object and Unify_TD_GAIL_CNETBase. So you have to extract these classes into a separate include file anyway. And doing this, it is safe to modify the loading logic described above as well.

Hth
Christof

Thomas4711
Germany
Posts: 5
Joined: 26 Feb 2018, 15:51
Location: Germany, Oberkirch

access to .net dll in an other folder

Post by Thomas4711 » 07 Mar 2018, 11:14

Thanks,

that solves my problem.

Thomas

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests