com - CreateObject C# -
i have native code com object, , trying instantiate c#. com registered in dcom components , in registry.
this i'v try do:
public static void main(string[] args) { type t = type.gettypefromprogid("caseconsole.application"); dynamic app = activator.createinstance(t); dynamic c = app.case; c.opencase("17-16", 0); }
if try instantiate com-type then, the:
notimplementedexception
the execption thrown @ line:
dynamic c = app.case;
as set breakpoint @ line, i'v looked "app" , error present
i'v looked in type t , shows: iscomobject = true
as vbs works great:
dim app dim c set app = createobject ("caseconsole.application") set c = app.case c.opencase "17-16", 0
as vb.net works
sub main() dim app dim c app = createobject("caseconsole.application") c = app.case c.opencase("17-16", 0) end sub
but not in c#
for c# example looked @ sources
http://www.codeproject.com/articles/990/understanding-classic-com-interoperability-with-ne
https://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx
equivalent code of createobject in c#
my guess must invoke methods invokemember or security thing...
please can c# example working?
update rename case c wasn't fault.
your c# program subtly different vbs , vb.net programs. apartment state of thread runs code different. exception comes proxy, should interpreted "running code worker thread not supported". nicely done. fix:
[stathread] public static void main(string[] args) { // etc.. }
note added [stathread] attribute. technically not correct this, console mode app not provide correct kind of runtime environment single-threaded com objects if vb.net app works have little fear. if ever notice deadlock you'll know for. worked when used late-binding through invokemember because uses idispatch , has different proxy.
Comments
Post a Comment