Can VB.NET / ASP.NET MVC call the charp enterpriceservice.component COM+ component of .NET 4.6.1 through progid?

易安 蔡 0 Reputation points
2024-03-24T14:02:00.0166667+00:00

Can VB.NET / ASP.NET MVC call the charp enterpriceservice.component COM+ component of .NET 4.6.1 through progid? Currently, when calling the enterpriceservice.component component, there are conflicts between System._comobject and enterpriceservice.component types, or problems that cannot be read or called.

Using Obj As System.EnterpriseServices.ServicedComponent = Activator.CreateInstance(Type.GetTypeFromProgID("PCYCLE2000.CCYCLE20002", True))
    Dim objArgs As Object() = {}
    Dim p As New ParameterModifier()
    Dim mods As ParameterModifier() = {}
    objArgs = New Object() {TOBJ}
    p = New ParameterModifier(objArgs.Length)
    mods = New ParameterModifier() {p}
    dObjOut = CStr(Obj.GetType().InvokeMember("GETDATA", BindingFlags.InvokeMethod, Nothing, Obj, objArgs, mods, Nothing, Nothing))
End Using

fail at InvokeMember() 'System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation. ---> System.InvalidCastException:Unable to cast COM object of type 'System.__ComObject' ' to interface type 'System.EnterpriseServices.ServicedComponent'。Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.\r\n\r\nServer stack trace: \r\n at PCYCLE2000.CCYCLE20002.GETDATA '(String OrderId)\r\n atSystem.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)...

Using Obj As Object = Activator.CreateInstance(Type.GetTypeFromProgID("PCYCLE2000.CCYCLE20002", True))
    Dim objArgs As Object() = {}
    Dim p As New ParameterModifier()
    Dim mods As ParameterModifier() = {}
    objArgs = New Object() {TOBJ}
    p = New ParameterModifier(objArgs.Length)
    mods = New ParameterModifier() {p}
    dObjOut = CStr(Obj.GetType().InvokeMember("GETDATA", BindingFlags.InvokeMethod, Nothing, Obj, objArgs, mods, Nothing, Nothing))
End Using

fail at InvokeMember() 'System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation. ---> System.InvalidCastException:Unable to cast COM object of type 'System.__ComObject' to interface type 'System.EnterpriseServices.ServicedComponent'。Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.\r\n\r\nServer stack trace: \r\n at PCYCLE2000.CCYCLE20002. 'GETDATA(String OrderId)\r\n at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)...


Using Obj As Object = CreateObject("PCYCLE2000.CCYCLE20002")
    dObjOut = Obj.GETDATA(TOBJ)   
End Using

fail at CreateObject 'System.InvalidCastException:Unable to cast COM object of type 'System.__ComObject' to interface type 'System.EnterpriseServices. 'ServicedComponent'。Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.\r\n\r\nServer stack trace: \r\n at PCYCLE2000.CCYCLE20002.GETDATA(String OrderId)\r\n 'at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)\r\n

need help,please,thanks a lot

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,255 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,249 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,571 questions
{count} votes