Reputation: 25
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
Upvotes: 0
Views: 37