Re: Creating a Com Component in VB.net 2005



On Oct 3, 5:25 pm, tomek.romanow...@xxxxxxxxx wrote:
Hi Josh !

 " a Reference to 'VbCalendar' could not be added.  The Active X type
library 'c:\VbCal\VbCalendar\VbCalendar\bin\Debug\VbCalendar.tlb was
exported from a .net assembly  and cannot be added as a reference.

Add a reference to the .net assembly instead.  Can someone explain
what this means and how to do it??

It's absolutelly normal, whenever you're trying to import to .Net a
COM component which in fact is .Net assembly and you cannot do
anything about it.
If you want to try your component (and have no VB 6.0), then consider
a use of VBScript as a calling code.

And when it comes to making a COM interoperating .NET assembly:
1. the most recomended way is to define an interface, which is then
implemented by your class and also prevent the class to have
autogenerated interface (which might mess up). This can be achieved by
using an ClassInterface attribute with None value - applied on the
class.
2. if you want to ensure both kinds of bindings, then the interfaced
exposed as COM interface must have InterfaceType.InterfaceIsDual
applied
3. COM clients often use ProgID as class "identifier" when making a
new object of given class. By default, in .Net assembly it is a
namespace and class name coupled together. You can set it as you want
with ProgID attribute.
4. All COM compliant classes must have parameterless constructor.

Examples of the above you can find in my post on the list (VB code,
but attributes names are the same in C#) "How to create a Net assembly
as replacement for existing COM component ".

One more thing: you must sign your assembly (give a strong name, as it
is called in .Net). Project properties/Signing tab - if I'm not wrong.

Thanks Tomek! Your answer cleared many things up for me!
.



Relevant Pages

  • Re: CreateObject from CLSID
    ... work via VB, but since it only has a CLSID and not a ProgID, it wasn't as ... a simple interface which works perfectly well with VB. ... > What do you mean "Trying to add a reference ... ...
    (microsoft.public.vb.com)
  • Re: "R6025 - Pure virtual function called". when consuming COM obj
    ... Calling code is what I have already provided.And regarding the COM ... so that when the client calls again, you return the interface to the same instantiated object. ... > the error happens on any of the COM call.And seems like AttributeDefs object ... > everytime function returns this "attrs" which is an RCW will go out of scope ...
    (microsoft.public.win32.programmer.ole)
  • Re: Creating a Com Component in VB.net 2005
    ... Add a reference to the .net assembly instead. ... a use of VBScript as a calling code. ... autogenerated interface. ... with ProgID attribute. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Dynamically Loading Assembly and Accessing its Types (namespaces are different)
    ... << If those types implement an interface known by the calling code you are ... but if you do not know of any interface those types ... have to be discovered or called using Reflection. ... to have this discovery capability. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What design pattern(s) to use here?
    ... way to "fool" the calling code because it thinks that it is using one ... interface, but you need it to use another. ... fairly complicated and it's used by a number other sub-systems. ... I think this is the definition of a Facade. ...
    (comp.software.patterns)

Loading