Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COM Interop problem
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00950657
Message ID:
00950694
Views:
20
Mark,
I don't know if this will help or not, but, calling from ASP.NET C#, I never have a problem. I actually use the free TLBIMP to create the .NET go-between proxy for the VFP mtdll, but, VS.NET should be doing the same thing behind the scenes. Here's the code(note the ASPCOMPAT keyword which may not apply to you since you're not using ASP.NET?):
< % @Page Language="C#" ASPCompat="true"
< % @Import Namespace="avfpdemo2_dotnetproxy"
< %
server x ;
x = new server() ;
try
   {
	Response.Write(x.main());
   }
catch(Exception ex)
   {
       	Response.Write("Caught .NET exception, source: " + ex.Source + " message: " + ex.Message);
   }
>Hello,
>
>We are having a problem with com interop. We have a Visual Foxpro dll (
>FOXPRO 8 ) that returns an ADODB.Recordset
>
>The fox dll is compiled as an Com+ dll. When we use that dll in ASP it works
>fine. When we try to use it in a c# application ( Windows or ASP.NET ) we
>keep getting exceptions.
>
>The first idea was to try the same thing with a VB com+ dll, but the same
>error occurs. It seems that the wrapper class generated by Visual studio .net
>doesn't function correctly.
>
>Below i will describe a few tests we did to find the source of the problem.
>We have a Com dll with the following Fox Code
>
>
>DEFINE CLASS testADODB as Session Olepublic
>    PROCEDURE moGetRecordSet as ADODB.RecordSet
>        loDB = CREATEOBJECT("test.testADODB_DB")
>        RETURN loDB.moGetRecordSet
>    ENDPROC
>ENDDEFINE
>
>DEFINE CLASS testADODB_DB as Session Olepublic
>    PROCEDURE moGetRecordSet
>        loRS = CREATEOBJECT("ADODB.RecordSet")
>        RETURN loRS
>    ENDPROC
>ENDDEFINE
>
>
>When i create a wrapper class in VS.NET 2003 ( By adding a reference to a
>COM dll ) and call the Com DLL with the following c# code
>
>
>test.testADODBClass testClass = new test.testADODBClass();
>ADODB.Recordset recset = testClass.moGetRecordSet();
>if( recset == null )
>    return;
>if( recset.State > 0 )
>{
>    lblResult.Text = "RecCount: " + recset.RecordCount;
>}
>else
>{
>    lblResult.Text = recset.GetType().ToString();
>}
>
>
>This code compiles just fine, but when I run this code i get an
>ExecutionEngineException. When I look in the documentation of this exception
>the remarks say: "Execution engine errors are fatal errors that should never
>occur." so that doesn't help either.
>
>The strange thing is that if I change the FOX dll defenition so that the
>return type is a variant instead of a ADODB.Recordset and cast it to an
>ADODB.Recordset in my C# code it works correctly.
>
>I'm also pretty sure the Com dll is correct because it works fine in classic
>asp and it is also possible to call the dll itself with the following C# code.
>
>
>object comObj;
>Type comType;
>comType = Type.GetTypeFromProgID( "myComProgID" );
>comObj = Activator.CreateInstance( comType );
>object ret = comType.InvokeMember( "myComFunction"
>	, BindingFlags.InvokeMethod | BindingFlags.Default
>	, null
>	, comObj
>	, new object[]{ "param1","param2", "param3" } );
>ADODB.Recordset recset = (ADODB.Recordset)ret;
>MessageBox.Show( recset.RecordCount.ToString() );
>
>
>So I think there is something wrong with the interop assembly generated by
>VS.NET. How can i use the COM wrappers generated by VS.net without getting
>this exception?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform