Hi,
is there any other way to integrate .NET libraries (C#) than with the .NET Explorer?
Regards
Ewald
Implement .NET Library
-
- Founder/Site Admin
- Posts: 3498
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
Re: Implement .NET Library
Yes.
If the C# .NET library has an exposed COM interface, you can use it as ActiveX/COM from TD.
You use in that case the ActiveX Explorer in TD to generate the TD library to use it.
As an example
Specifying that the interface and the methods are COM exposed by adding it just in front of the definition.
The method
To enable exposing COM in .NET project (Visual Studio) you check the option in the assembly properties
For 3rd party assemblies it depends if the product has enabled this. I know some components (like GdPicture) can be used both in native .NET and as COM.
Other ways I do not know of.
But to be honest, I would use GAILWrapper when possible over the COM option.
You have to register COM which makes deployment more difficult.
And GAILWrapper in current state (TD 7.4) is stable and supports most of the interface features.
The advantage of COM is that you can expose events and more complex class/parameter types.
If the C# .NET library has an exposed COM interface, you can use it as ActiveX/COM from TD.
You use in that case the ActiveX Explorer in TD to generate the TD library to use it.
As an example
Code: Select all
[ComVisible(true), Guid("43c9ad6b-5027-4626-afbb-264922bde0ad")]
public interface ZipWrapperInterface
{
String ZipFiles(String zipFileName, String directory, String[] filesToInclude);
}
The method
ZipFiles
can then be called from TD using COM and also from native .NET.To enable exposing COM in .NET project (Visual Studio) you check the option in the assembly properties
For 3rd party assemblies it depends if the product has enabled this. I know some components (like GdPicture) can be used both in native .NET and as COM.
Other ways I do not know of.
But to be honest, I would use GAILWrapper when possible over the COM option.
You have to register COM which makes deployment more difficult.
And GAILWrapper in current state (TD 7.4) is stable and supports most of the interface features.
The advantage of COM is that you can expose events and more complex class/parameter types.
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Dave Rabelink
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Re: Implement .NET Library
Only for the sake of completeness:
There is another way to use .NET assemblies. The static functions in .NET assemblies could be used like normal Win32 DLL functions as external functions in Team Developer. But there is no automatic way with Visual Studio to generate them.
The advantage here is that this have worked long before Team Developer could use .NET assemblies directly. We use this a lot and it works very stable.
The disadvantage is that the interface only knows normal data types (it is not object oriented). The functions to be exported must be static and the effort of converting the assembly is quite high, because you have to do the following steps:
1. Create .NET assembly normally with static functions as interface (e.g. with Visual Studio).
2. disassemble .NET assembly with ildasm.exe to generate MSIL code
3. modify the MSIL code to create the interface for the external functions
4. recompile the .NET assembly with ilasm.exe.
If the .NET Explorer had been around when we wanted to use the .NET assemblies in Team Developer, we certainly wouldn't have gone this way
If you are interested I can describe the way how to change the MSIL code in more detail, but I don't think this is the solution you are looking for
PS: Here is the underlying article about which we realized our solution of disassemble/modify/assemble:
http://www.blong.com/Articles/DotNetInt ... nterop.htm
PPS: Attached is a sample that use a .NET Assembly with the following .NET code as Win32 DLL in Team Developer:
There is another way to use .NET assemblies. The static functions in .NET assemblies could be used like normal Win32 DLL functions as external functions in Team Developer. But there is no automatic way with Visual Studio to generate them.
The advantage here is that this have worked long before Team Developer could use .NET assemblies directly. We use this a lot and it works very stable.
The disadvantage is that the interface only knows normal data types (it is not object oriented). The functions to be exported must be static and the effort of converting the assembly is quite high, because you have to do the following steps:
1. Create .NET assembly normally with static functions as interface (e.g. with Visual Studio).
2. disassemble .NET assembly with ildasm.exe to generate MSIL code
3. modify the MSIL code to create the interface for the external functions
4. recompile the .NET assembly with ilasm.exe.
If the .NET Explorer had been around when we wanted to use the .NET assemblies in Team Developer, we certainly wouldn't have gone this way
If you are interested I can describe the way how to change the MSIL code in more detail, but I don't think this is the solution you are looking for
PS: Here is the underlying article about which we realized our solution of disassemble/modify/assemble:
http://www.blong.com/Articles/DotNetInt ... nterop.htm
PPS: Attached is a sample that use a .NET Assembly with the following .NET code as Win32 DLL in Team Developer:
Code: Select all
namespace MathLibrary
{
public static class Sum
{
public static int AddInt(int a, int b)
{
return a + b;
}
public static string AddString(string a, string b)
{
return a + b;
}
public static int AddStringEx(string a, string b, [MarshalAs(UnmanagedType.LPStr)] string c)
{
c = a + b;
return c.Length;
}
public static int GetDate(ref int year, ref int month, ref int day)
{
year = 2021;
month = 3;
day = 24;
return 0;
}
}
}
You do not have the required permissions to view the files attached to this post.
Best regards,
Michael Ehehalt
Michael Ehehalt
-
- Founder/Site Admin
- Posts: 3498
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
Re: Implement .NET Library
Nice. I haven't seen this before. So thanks for this info !Michael Ehehalt wrote: ↑24 Nov 2021, 16:24Only for the sake of completeness:
There is another way to use .NET assemblies. The static functions in .NET assemblies could be used like normal Win32 DLL functions as external functions in Team Developer.
Regards,
Dave Rabelink
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Dave Rabelink
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel
Re: Implement .NET Library
Many thanks to Dave and Michael. I will try different the different approaches.
Re: Implement .NET Library
If you're looking for a custom .net development company that can help you with your current project or start a new one, then look no further than Dot Net Development Company. We have over 15 years of experience in the field and are passionate about helping our clients achieve their business goals.
Our team of experts is skilled in various .NET technologies, so we can ensure that your projects are delivered on time and to specification. In addition to developing software applications, we also offer website design and development services.
Our team of experts is skilled in various .NET technologies, so we can ensure that your projects are delivered on time and to specification. In addition to developing software applications, we also offer website design and development services.
Global Business Transformation Solutions | MMC Global
Who is online
Users browsing this forum: [Ccbot] and 3 guests