Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:creating_com_library [2012/05/14 15:59] smayr |
swdev:dotnet:creating_com_library [2012/05/16 12:40] (current) smayr [Creating COM Library] |
||
---|---|---|---|
Line 1: | Line 1: | ||
= Creating COM Library = | = Creating COM Library = | ||
- | Source: [[http:// | + | |
- | + | ||
- | * Start VS2010 as administrator. | + | |
- | | + | |
* Interface: | * Interface: | ||
- | * Add a new interface | + | * Add to the file:< |
- | * Add a using '' | + | * Add a new interface |
- | * Add the attributes '' | + | { |
- | * You can generate | + | void launch(); |
+ | }</ | ||
+ | * Add the attributes '' | ||
+ | [InterfaceType(ComInterfaceType.InterfaceIsDual)] | ||
+ | [Guid(" | ||
* Class: | * Class: | ||
- | * Add a class that implement the interface. | + | * Add a class that implement the interface.<code csharp> |
- | * Add the attributes '' | + | public class MyLauncher: IMyLauncher |
+ | { | ||
+ | public void launch() | ||
+ | { | ||
+ | } | ||
+ | }</ | ||
+ | * Add the attributes '' | ||
+ | [ClassInterface(ClassInterfaceType.None)] | ||
+ | [Guid(" | ||
+ | [ProgId(" | ||
* '' | * '' | ||
* Activate COM and register it: | * Activate COM and register it: | ||
- | * In Project Properties (Alt-Tab) > Application > Assembly Information, | + | * In Project Properties (Alt-Enter) > Application > Assembly Information, |
- | * In Project Properties (Alt-Tab) > Build > Output, and check " | + | * In Project Properties (Alt-Enter) > Build > Output, and check " |
* Build the project. This will register the COM object. | * Build the project. This will register the COM object. | ||
* Alternatively, | * Alternatively, | ||
Now the COM object is available to be called by its '' | Now the COM object is available to be called by its '' | ||
+ | == Example == | ||
Example class for COM: | Example class for COM: | ||
<code csharp> | <code csharp> | ||
Line 64: | Line 74: | ||
Hello, World, from a COM object | Hello, World, from a COM object | ||
</ | </ | ||
+ | |||
+ | == References == | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// |