Using Aspose.Tasks for .NET via COM Interoperation
This article applies to scenarios where Aspose.Tasks for .NET needs to be used from unmanaged environments like:
- Visual Basic 6.0
- Classic ASP with VBScript
- Other COM-aware languages
Understanding COM Interop
Aspose.Tasks is a managed .NET library, but with the help of COM Interop, it can be used from unmanaged code — i.e., from environments that do not run on the .NET runtime. In such scenarios, .NET classes are exposed as COM objects, allowing legacy or non-.NET applications to instantiate and interact with Aspose.Tasks objects.
COM Interop acts as a bridge between .NET and COM clients.
Key Concepts
Before using Aspose.Tasks via COM Interop, it’s important to be familiar with:
- How to create COM objects in your programming language (VB6, ASP Classic, etc.)
- How COM objects behave when exposed from .NET assemblies
- How to register and reference type libraries (
*.tlb
) in your environment
For deeper reference:
Registering Aspose.Tasks for COM Interop
To use Aspose.Tasks from a COM client, you must:
1. Register the .NET Assembly
1regasm "C:\Program Files\Aspose\Aspose.Tasks\bin\net20\Aspose.Tasks.DLL" /codebase
This registers the assembly with the COM system and adds it to the Windows registry.
2. Generate the COM Type Library
1regasm "C:\Program Files\Aspose\Aspose.Tasks\bin\net20\Aspose.Tasks.DLL" /tlb:Aspose.Tasks.tlb
The resulting Aspose.Tasks.tlb
can now be referenced in any COM-aware environment.
⚙️ You’ll need the
regasm.exe
tool, which is part of the .NET Framework SDK. It’s located in a folder like:C:\Windows\Microsoft.NET\Framework\v4.0.30319\
Accessing Aspose.Tasks from Your Language
Once registered, the library behaves like any other COM object in VB6 or ASP Classic:
1Dim prj As New Aspose_Tasks.Project
2prj.IsScheduleFromStart = True
If your language has an Object Browser, referencing Aspose.Tasks.tlb
will make the full API available to you — including classes, methods, properties, and enumerations.
Method Overloads in COM
COM does not natively support method overloading. Therefore, overloaded methods in .NET are exposed with numeric suffixes in COM:
.NET Method Overload | COM Equivalent |
---|---|
Project.CalcCalendarUids() | Project.CalcCalendarUids |
Project.CalcCalendarUids(...) | Project.CalcCalendarUids_2 |
📝 The first method retains its name; subsequent overloads are suffixed.
Summary
Using Aspose.Tasks for .NET via COM Interop allows developers to bring Microsoft Project file manipulation to legacy environments without needing to migrate codebases to .NET. Whether you’re working with VB6, ASP Classic, or other COM-compatible tools, this approach gives you access to the full power of Aspose.Tasks.
For a practical example, see: