User Assemblies

User Assemblies

In the CTP file we specified the full path to user assemblies. For example:

USER:C:\source\CrossTalk\source\CrossTalkRightTest\bin\Debug\CrossTalkRightTest.dll

The full path is fine and needed during the generation phase. However the generator also emits this path into the .pas files. In CTCrossTalkRightTest.pas this is generated:

initialization
LoadAssembly(‘C:\source\CrossTalk\source\CrossTalkRightTest\bin\Debug\CrossTalkRightTest.dll’);
end.

This will work while debugging, however you are unlikely to deploy your assembly in this location on your users machines. You could change this path, however it a .pas file that is autogenerated and not intended for changes. Because of this, at runtime CrossTalk will actually try to load the assembly first from the User Path.

User Path

The UserPath is the path where the application that calls CrossTalk exists. Normally this is your exe, but if you put your CrossTalk units in a DLL or a package, then the User Path will be the path where that DLL or package exists. This may or may not be the same as the exe.

So in our example the Delphi code creates an exe and it is deployed to C:\Program Files\My App\app.exe, then CrossTalk would first look for C:\Program Files\My App\CrossTalkRightTest.dll. If CrossTalk does not find it there, then it will look in the actual path specified.

This allows for easy deployment, and debugging scenarios.

Gotcha

The one thing you need to watch out for is during debugging. If you happen to copy the assembly to the application directory for testing, remember that CrossTalk will always give it priority over your debug version even if you rebuild the debug version. We considered looking for both and loading the newer one, but has more serious side effects.