Description
Loads a .NET (5 or later) assembly.
Applies to
Syntax
Integer LoadWithDotNet (readonly string assemblypath)
Argument |
Description |
---|---|
assemblypath |
The name and location of the .NET assembly (*.dll).
The location can be an absolute path or a relative path. When a relative path is executed in the development environment, it is relative to the location of the PBT file; when a relative path is executed in the production environment, it is relative to the installation location of the application's executable file.
|
Return value
Integer.
Returns values as follows. If any argument's value is null, the method returns null.
1 -- Success.
-1 -- Unknown error.
-2 -- Could not find the assembly.
-3 -- It's not a valid assembly.
-4 -- The assembly requires a dependent assembly.
Usage
If an application uses LoadWithDotNetCore and LoadWithDotNet at the same time, the .NET Runtime cannot be the same version, otherwise the subsequent execution will fail to load. You need to specify different versions of the .NET Runtime. For the LoadWithDotNet function, the version can be specified by modifying the pbdotnetinvoker.runtimeconfig.json file. For more details, refer to https://docs.microsoft.com/en-us/dotnet/core/run-time-config/.
Examples
The following example loads a DLL with .NET (5 or later):
Long ll_return String ls_dll DotNetAssembly lcs_ass //Specifies a DLL in the relative path Ls_dll = "Appeon.Simple.dll" //Instantiates the DotNetAssembly object Lcs_ass = create DotNetAssembly //Loads the DLL Ll_return = lcs_ass.LoadWithDotNet(ls_dll) //Checks the result If ll_return < 0 then Messagebox("Load "+ls_dll+" Failed", lcs_ass.ErrorText) Return ll_return End if
See also