M
MicheleG
Hi to all!
I created a VB.Net COM DLL which I can use in VBScript.
I followed the steps in the following article:
http://msdn2.microsoft.com/en-us/library/x66s8zcd(VS.71).aspx
(I used the method "with COM class template")
My DLL got created fine - no errors in build process.
The "Make Assembly COM-Visible" checkbox is checked.
the ComClass1 class is below (dll / assembly name is ClassLibrary1):
--------------begin of code
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId,
ComClass1.EventsId)> _
Public Class ComClass1
Public Sub Importa(ByRef o As VISUMLIB.Visum)
MsgBox(Marshal.IsComObject(o))
o.Net.Marking.Clear()
End Sub
#Region "GUID COM"
' Questi GUID forniscono l'identità COM per la classe
' e le sue interfacce COM. Se vengono modificati, i client
' esistenti non saranno più in grado di accedere alla classe.
Public Const ClassId As String = "381f7f94-e48b-431d-
bdaa-2068442c90e6"
Public Const InterfaceId As String = "2dded33c-22ac-4816-a2f2-
ec8d228686b3"
Public Const EventsId As String = "2d8d4753-4d5e-4b58-
b75c-6e3fab5dad8a"
#End Region
' È possibile creare classi COM solo se dispongono di una Public
Sub New()
' senza parametri. In caso contrario, infatti, la classe non può
essere
' registrata nel registro COM e non può essere creata
' con CreateObject.
Public Sub New()
MyBase.New()
End Sub
End Class
-----------------end of code
As you can see I created a public method called Importa that accept as
input a COM object from a library referenced in .NET ("VISUMLIB")
Then I wrote a vbscript which creates an instance of the object:
Set dllobject = CreateObject("ClassLinrary1.ComClass1")
It works correctly!
Then I put in the vbs script then statement:
dllobject.Importa comobjectname
The output is a msgbox with "True" (result of
MsgBox(Marshal.IsComObject(o)).
So the object I'm sending to the dll method is a true COM object.
The problem is in the statement inside the sub:
"o.Net.Marking.Clear()"
I'm trying to execute the method Clear() of the container
"o.Net.Marking".
In my development machine everything works corretly.
But I tried to install the dll (I created a setup) and when It comes
to execute the statement
"o.Net.Marking.Clear()"
The vbscript breaks with the following error:
----------
"Unable to cast COM object of type "VISUMLIB.VisumClass" to interface
type
'VISUMLIB.IVisum'. This operation failed
because the QueryInterface call on the COM component for the interface
with
IID '{33B2B132-69BE-4ADE-A90E-939972B93FD5}' failed due to the
following
error: No such interface supported (Exception from HRESULT:
0x80004002
(E_NOINTERFACE)).
Source:Interop.VISUMLIB
----------
Can you help me sith any suggestions?
Thank you very much
M.G.
I created a VB.Net COM DLL which I can use in VBScript.
I followed the steps in the following article:
http://msdn2.microsoft.com/en-us/library/x66s8zcd(VS.71).aspx
(I used the method "with COM class template")
My DLL got created fine - no errors in build process.
The "Make Assembly COM-Visible" checkbox is checked.
the ComClass1 class is below (dll / assembly name is ClassLibrary1):
--------------begin of code
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId,
ComClass1.EventsId)> _
Public Class ComClass1
Public Sub Importa(ByRef o As VISUMLIB.Visum)
MsgBox(Marshal.IsComObject(o))
o.Net.Marking.Clear()
End Sub
#Region "GUID COM"
' Questi GUID forniscono l'identità COM per la classe
' e le sue interfacce COM. Se vengono modificati, i client
' esistenti non saranno più in grado di accedere alla classe.
Public Const ClassId As String = "381f7f94-e48b-431d-
bdaa-2068442c90e6"
Public Const InterfaceId As String = "2dded33c-22ac-4816-a2f2-
ec8d228686b3"
Public Const EventsId As String = "2d8d4753-4d5e-4b58-
b75c-6e3fab5dad8a"
#End Region
' È possibile creare classi COM solo se dispongono di una Public
Sub New()
' senza parametri. In caso contrario, infatti, la classe non può
essere
' registrata nel registro COM e non può essere creata
' con CreateObject.
Public Sub New()
MyBase.New()
End Sub
End Class
-----------------end of code
As you can see I created a public method called Importa that accept as
input a COM object from a library referenced in .NET ("VISUMLIB")
Then I wrote a vbscript which creates an instance of the object:
Set dllobject = CreateObject("ClassLinrary1.ComClass1")
It works correctly!
Then I put in the vbs script then statement:
dllobject.Importa comobjectname
The output is a msgbox with "True" (result of
MsgBox(Marshal.IsComObject(o)).
So the object I'm sending to the dll method is a true COM object.
The problem is in the statement inside the sub:
"o.Net.Marking.Clear()"
I'm trying to execute the method Clear() of the container
"o.Net.Marking".
In my development machine everything works corretly.
But I tried to install the dll (I created a setup) and when It comes
to execute the statement
"o.Net.Marking.Clear()"
The vbscript breaks with the following error:
----------
"Unable to cast COM object of type "VISUMLIB.VisumClass" to interface
type
'VISUMLIB.IVisum'. This operation failed
because the QueryInterface call on the COM component for the interface
with
IID '{33B2B132-69BE-4ADE-A90E-939972B93FD5}' failed due to the
following
error: No such interface supported (Exception from HRESULT:
0x80004002
(E_NOINTERFACE)).
Source:Interop.VISUMLIB
----------
Can you help me sith any suggestions?
Thank you very much
M.G.