This is weird.....
I tried exactly what you did:
1) I could do the following in Microsoft Word 2003 Macro (after adding a
reference to testInterop.tlb):
------------------------start of functioning VBA
Code------------------------
Dim objTest As New testInterop.test
objTest.DoSomething
------------------------end of functioning VBA Code------------------------
2.1) When I try the following ASP code on Windows XP Professional SP1 with
IIS5.1
-----------------------------startof ASP Code-----------------------------
<%
Dim objTest
Set objTest = CreateObject("testInterop.test")
objTest.DoSomething
%>
------------------------------end of ASP Code------------------------------
2.2) I still get the following error
--------------------------------start of ASP
error--------------------------------
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object: 'testInterop.test'
/testInterop.asp, line 3
--------------------------------end of ASP
error--------------------------------
3) If I put the ASP code in VBScript, I get the following error:
----------------------------start of VBScript
Error---------------------------
C:\Temp\testactivex.vbs(2, 5) Microsoft VBScript runtime error: ActiveX
componen
t can't create object: 'testInterop.test'
----------------------------end of VBScript Error---------------------------
Why is this and how could this be resolved?
> I assume you have not given the assembly a strong name and installed it in the GAC. The problem is that the COM loader gets pointed to mscoree.dll (the
Have a look in the registry and find out what the InprocServer32 key looks like for your .NET object.
Also, ASP and vbscript are creating the object via its progid - is testInterop.test the fully qualified name (including full namespace) of the class you are trying to create?
Regards
Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.framework/<On0O3lgpEHA.868@TK2MSFTNGP10.phx.gbl>
This is weird.....
I tried exactly what you did:
1) I could do the following in Microsoft Word 2003 Macro (after adding a
reference to testInterop.tlb):
------------------------start of functioning VBA
Code------------------------
Dim objTest As New testInterop.test
objTest.DoSomething
------------------------end of functioning VBA Code------------------------
2.1) When I try the following ASP code on Windows XP Professional SP1 with
IIS5.1
-----------------------------startof ASP Code-----------------------------
<%
Dim objTest
Set objTest = CreateObject("testInterop.test")
objTest.DoSomething
%>
------------------------------end of ASP Code------------------------------
2.2) I still get the following error
--------------------------------start of ASP
error--------------------------------
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object: 'testInterop.test'
/testInterop.asp, line 3
--------------------------------end of ASP
error--------------------------------
3) If I put the ASP code in VBScript, I get the following error:
----------------------------start of VBScript
Error---------------------------
C:\Temp\testactivex.vbs(2, 5) Microsoft VBScript runtime error: ActiveX
componen
t can't create object: 'testInterop.test'
----------------------------end of VBScript Error---------------------------
Why is this and how could this be resolved?
"Richard Blewett [DevelopMentor]" <richardb@develop.com> wrote in message
news:uIHwqBZpEHA.2304@TK2MSFTNGP14.phx.gbl...
> I assume you have not given the assembly a strong name and installed it in
the GAC. The problem is that the COM loader gets pointed to mscoree.dll (the
runtime) and then passes mscoree.dll the CLSID of the COM object (via
DllGetClassObject) mscoree goes to the registry and looks under that CLSID
and finds the assembly name, class anme and a bunch of other stuff. Now the
problem is mscoree doesn't know where your class is so it tries to load it
by name and fails dismally as the assembly isn't in the APPBASE (or
subdirectory) of the executing process (cscript.exe or inetinfo.exe I guess
in these scenarios).
> Just to show things working, change your regasm command line to
>
> regasm /tlb:testInterop.tlb testInterop.dll /codebase
>
> You will get a warning about the assembly not having a strong name but
just ignore that for now. Hopefully enverything will now work (regasm puts
the path to the assembly - the CODEBASE - under the CLSID as well so mscoree
knows where to find it).
> In reality however, you should strong name and GAC the interop assembly
>
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
[microsoft.public.dotnet.framework]
Patrick - 29 Sep 2004 12:30 GMT
Nice one!
The ProgId was set to MyOrg.web.publications.Test and not testInterop.Test!
So CreateObject("MyOrg.web.publications.Test") works!
> Have a look in the registry and find out what the InprocServer32 key looks like for your .NET object.
>
> Also, ASP and vbscript are creating the object via its progid - is testInterop.test the fully qualified name (including full namespace) of the
class you are trying to create?
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.framework/<On0O3lgpEHA.868@TK2MSFTNGP10.phx.gbl>
> This is weird.....
>
[quoted text clipped - 71 lines]
>
> [microsoft.public.dotnet.framework]
Patrick - 29 Sep 2004 15:30 GMT
Now that I have got the mickey mouse .NET interop problem sorted (exposing
.NET library to ASP/VB6), I want to demo the real problem I am having.
What I want to achive is actually expoing a C#.NET Class Library for making
Web Service calls to ASP pages.
From my mickey mouse example, I learnt the following:
1) It's best to define interfaces as follows:
--------------------start of interface--------------------
using System.Runtime.InteropServices;
namespace MyOrg.web.publications
{
//[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://twoten.press.
net/webservices/")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
public interface ITest
{
void DoSomething();
}
}
--------------------end of interface--------------------
2) The class, I just need to implement the interface (other than using
[ClassInterface(ClassInterfaceType.AutoDual)])
3) install the .NET dll into gac
4) use regasm to install the type library
5) the DLL usable with Late Binding:
e.g. Set objTest = CreateObject("MyOrg.web.publications.Test")
***The real real use/problem I am having is as follows:
(The code for the web service client class library is as follows)
---------------Start of WebService client Class Library Code---------------
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.IO;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
using System.Runtime.InteropServices;
namespace MyOrg.web.publications
{
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="iOrderSoap",
Namespace="http://testServer/webservices/")]
public class Order : Microsoft.Web.Services2.WebServicesClientProtocol ,
IOrder
{
/// <remarks/>
public Order()
{
this.Url = "https://testServer/iPubData/iOrder.asmx";
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://Pub.press
.net/webservices/PlaceOrder",
RequestNamespace="http://Pub.press.net/webservices/",
ResponseNamespace="http://Pub.press.net/webservices/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void PlaceOrder(SimpleOrderData order)
{
try
{
StreamWriter fileStream;
fileStream = File.CreateText("c:\\temp\\test.txt");
fileStream.WriteLine("TestOrder=" + order.TestOrder);
fileStream.WriteLine("FirstName" + order.FirstName);
fileStream.WriteLine("Surname" + order.Surname );
fileStream.WriteLine("order.OrderLines(0).StockCode" +
order.OrderLines[0].StockCode);
fileStream.Flush();
fileStream.Close();
//fileStream.WriteLine("" + );
// this.Invoke("PlaceOrder", new object[] {
// order});
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex);
}
}
/// <remarks/>
public System.IAsyncResult BeginPlaceOrder(SimpleOrderData order,
System.AsyncCallback callback, object asyncState)
{
return this.BeginInvoke("PlaceOrder", new object[] {
order}, callback, asyncState);
}
/// <remarks/>
public void EndPlaceOrder(System.IAsyncResult asyncResult)
{
this.EndInvoke(asyncResult);
}
}
---------------End of WebService client Class Library Code---------------
1) I could compile, gacutil /i and regasm the class library with no problem
2) When I try to use it in ASP as follows:
2.1) Set objOnlyOrder =
CreateObject("MyOrg.web.publications.SimpleOrderData")
2.2) I get the following error:
------------------------start of asp error------------------------
Active Server Pages error 'ASP 0115'
Unexpected error
/test.asp
A trappable error (C0000005) occurred in an external object. The script
cannot continue running.
------------------------end of asp error------------------------
3.1) If I try to use it from VBA with Early Binding, then there are no
errors, but the class library doesn't seem to be reading reading in the
write value by writing to "C:\temp\test.txt" (it simply creates a blank
test.txt file)!
-------------------------start of VBA Code-------------------------
Dim objOnlyOrderLine As New iPubClient.OrderLine
Dim objOnlyOrder As New iPubClient.SimpleOrderData
Dim objIPubClient As New iPubClient.Order
Dim arrOrderLines(0) As String
objOnlyOrderLine.StockCode = "A123"
objOnlyOrderLine.Quantity = 2
objOnlyOrder.TestOrder = True
objOnlyOrder.FirstName = "Mickey"
objOnlyOrder.Surname = "Mouse"
arrOrderLines(0) = objOnlyOrderLine
objOnlyOrder.OrderLines = arOrderLines
MsgBox "before"
objIPubClient.PlaceOrder objOnlyOrder
MsgBox "after"
Set objOnlyOrderLine = Nothing
Set objOnlyOrder = Nothing
Set objIPubClient = Nothing
-------------------------End of VBA Code-------------------------
> Have a look in the registry and find out what the InprocServer32 key looks like for your .NET object.
>
> Also, ASP and vbscript are creating the object via its progid - is testInterop.test the fully qualified name (including full namespace) of the
class you are trying to create?
> Regards
>
> Richard Blewett - DevelopMentor
> http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.framework/<On0O3lgpEHA.868@TK2MSFTNGP10.phx.gbl>
> This is weird.....
>
[quoted text clipped - 71 lines]
>
> [microsoft.public.dotnet.framework]
"Peter Huang" - 30 Sep 2004 09:38 GMT
Hi Patrick,
I will research the issue and update you with new information ASAP.
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" - 01 Oct 2004 06:33 GMT
Hi Patrick,
I reviewed the thread and find that our colleague is working with you on
this issue, I think you may try to take care with that thread.
Thank you for you understanding.
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Patrick - 03 Oct 2004 22:05 GMT
I still couldn't get this working :-(
I *suspect* it is something to do with the fact my client class inherits
from Microsoft.Web.Services2.WebServicesClientProtocol, which obviously is a
.NET Managed class. I can't think of how I could expose that as well as the
inheritance tree to COM (in fact, I think inheritance tree are flattened).
In fact, I very much suspect, the class is having trouble looking for
this.url (which is from the base class). Is there a solution to this
(without having to re-write WebServicesClientProtocol)?
> Now that I have got the mickey mouse .NET interop problem sorted (exposing
> .NET library to ASP/VB6), I want to demo the real problem I am having.
[quoted text clipped - 8 lines]
> namespace MyOrg.web.publications
> {
//[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://twoten.press.
> net/webservices/")]
> [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)]
[quoted text clipped - 42 lines]
>
> /// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://Pub.press
> .net/webservices/PlaceOrder",
> RequestNamespace="http://Pub.press.net/webservices/",
[quoted text clipped - 95 lines]
> > Richard Blewett - DevelopMentor
> > http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.framework/<On0O3lgpEHA.868@TK2MSFTNGP10.phx.gbl>
> > This is weird.....
> >
[quoted text clipped - 84 lines]
> >
> > [microsoft.public.dotnet.framework]