paul
2006-08-18 20:57:06 UTC
I found a very interesting issue that may draw you pro's attention:
I built a COM class using VS 2005 with Framework 2.0,and the code is as
below:
//----------------------Code Begin----------------------------------
using System;
using System.Runtime.InteropServices;
namespace Test99
{
#region Interface published by your COM class
[Guid("FE1EB79E-3513-487e-ADFF-2B61C6CB4730"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IComClass1
{
[DispId(1)]
string myHelloWorld();
}
#endregion
[Guid("3B10A420-D36E-4056-BE0F-DD085433B966"),
ProgId("Test99.Class"),
ClassInterface(ClassInterfaceType.None)]
[System.Web.Services.WebServiceBindingAttribute()]
public class Class1 :
Microsoft.Web.Services2.WebServicesClientProtocol, IComClass1
{
public Class1()
: base()
{
}
//if I comment the attribute below,it works
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("SomeURL",
RequestNamespace = "SomeURL", ResponseElementName = "SomeName",
ResponseNamespace = "SomeURL", Use =
System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle
= System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return:
System.Xml.Serialization.XmlElementAttribute("ReturnValue")]
public string myHelloWorld()
{
return "My Hello World";
}
}
}
//--------------------------Code
End------------------------------------------------
I checked "Register for COM interop" option in Build section of the
project property,sign the assembly with a strong name key file and
register to GAC
Then I try to use this COM object in VB6,VBA and ASP,and the result is:
1.In both VB6 and VBA ,I can call this COM object without any problems
by using either early binding or late binding.
2.In ASP page,when using early binding(referenced dll and used new
object stuff in the code),it gave me error message like "Class Class1
undefined";when use late binding(used createobject stuff),it gave the
error like "Error Type:Server object, ASP 0177 (0x80131509) 80131509"
That's not all, the most interesting thing is when I comment the code
"[System.Web.Services.Protocols.SoapDocumentMethodAttribute("SomeURL",
RequestNamespace = "SomeURL", ResponseElementName = "SomeName",
ResponseNamespace = "SomeURL", Use =
System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle
= System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]" ,I can
call it from ASP page by using late binding while the early binding
still gave the same error message.
So,any ideas?
I built a COM class using VS 2005 with Framework 2.0,and the code is as
below:
//----------------------Code Begin----------------------------------
using System;
using System.Runtime.InteropServices;
namespace Test99
{
#region Interface published by your COM class
[Guid("FE1EB79E-3513-487e-ADFF-2B61C6CB4730"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IComClass1
{
[DispId(1)]
string myHelloWorld();
}
#endregion
[Guid("3B10A420-D36E-4056-BE0F-DD085433B966"),
ProgId("Test99.Class"),
ClassInterface(ClassInterfaceType.None)]
[System.Web.Services.WebServiceBindingAttribute()]
public class Class1 :
Microsoft.Web.Services2.WebServicesClientProtocol, IComClass1
{
public Class1()
: base()
{
}
//if I comment the attribute below,it works
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("SomeURL",
RequestNamespace = "SomeURL", ResponseElementName = "SomeName",
ResponseNamespace = "SomeURL", Use =
System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle
= System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return:
System.Xml.Serialization.XmlElementAttribute("ReturnValue")]
public string myHelloWorld()
{
return "My Hello World";
}
}
}
//--------------------------Code
End------------------------------------------------
I checked "Register for COM interop" option in Build section of the
project property,sign the assembly with a strong name key file and
register to GAC
Then I try to use this COM object in VB6,VBA and ASP,and the result is:
1.In both VB6 and VBA ,I can call this COM object without any problems
by using either early binding or late binding.
2.In ASP page,when using early binding(referenced dll and used new
object stuff in the code),it gave me error message like "Class Class1
undefined";when use late binding(used createobject stuff),it gave the
error like "Error Type:Server object, ASP 0177 (0x80131509) 80131509"
That's not all, the most interesting thing is when I comment the code
"[System.Web.Services.Protocols.SoapDocumentMethodAttribute("SomeURL",
RequestNamespace = "SomeURL", ResponseElementName = "SomeName",
ResponseNamespace = "SomeURL", Use =
System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle
= System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]" ,I can
call it from ASP page by using late binding while the early binding
still gave the same error message.
So,any ideas?