Re: Subject: Forcing a .NET obj exposed as COM to use StdCall instead of CdCall

From: Klaus H. Probst (usenet001_at_vbbox.com)
Date: 02/12/04


Date: Wed, 11 Feb 2004 22:09:17 -0700

Doug,

What you're talking about here is a completely different thing than COM.
I've seen these extension scripts in products like Mercator and PoepleSoft.
They basically load a DLL and call a method in it by using GetProcAddress
and a defined signature through a function pointer. However, you will not be
able to pull *that* off with .NET because you cannot create standard exports
in CLR assemblies. You'd need to use C or C++ or (maybe) Delphi. This is not
a problem with COM since the application is not using COM (at least in the
example you describe below).

If the script can call COM objects normally (instead of using
LoadLibrary/GetProcAddress) like, say, VBScript, then it's certainly
possible because .NET can create normal unmanaged COM wrappers around
managed assemblies. But the scenario you describe below is basically
impossible to achieve with plain .NET, COM or not.

-- 
____________________
Klaus H. Probst, MVP
   http://www.vbbox.com/
"Doug" <doug.robertson@pearlinvestments.com> wrote in message
news:DA6F82D5-34FF-4B35-ACEF-634A26C217AE@microsoft.com...
> I stand corrected about the stdcall issue.  I was repeating that
information from the reserch that a person who has a problem similar to mine
was doing.
>
> I need to make the VB.NET object callable from a program called Trade
Station.  It is a stock analysis and trading tool that is very importiant to
my company.  They have a scripting languge called easy language that is
built into the system.  It is supposed to be capable of extending itself by
calling external DLLs.  It is very picky about what DLLsit will see though.
>
> Others have had success using C++ to write a DLL that will work with Easy
Language, but I am hitting a brick wall with VB.  I am not a strong C++
programmer, but I am very good at VB.  I am hoping to find a way to make
interop expose my VB DLL in the same way that the C++ DLL is exposed.  Here
is a snippet of code that is from a working C++ DLL.  I hope it is
meaningful.  I am not sure :-(
>
> -----------stdafx.h-----------
>  // stdafx.h : include file for standard system include files,
> // or project specific include files that are used frequently, but
> // are changed infrequently
> //
>
> #pragma once
>
>
> #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
> // Windows Header Files:
> #include <windows.h>
>
> // TODO: reference additional headers your program requires here
> #define dll_entry( type )  extern"C" type __stdcall
>
>
> -----------a.cpp-----------
> // a.cpp : Defines the entry point for the DLL application.
> //
>
> #include "stdafx.h"
> #import "c:\Program Files\TradeStation\Program\TSKit.dll" no_namespace
> #import
"D:\documents\projects\TradeStationInterop\CSharp\bin\Release\CSharp.tlb"
>
> BOOL APIENTRY DllMain( HANDLE hModule,
>                        DWORD  ul_reason_for_call,
>                        LPVOID lpReserved
> )
> {
>     return TRUE;
> }
>
> double __stdcall MyTest(IEasyLanguageObject *pEL, int iNBars)
> {
> CSharp::_Class1 *com_ptr;
> CoInitialize(NULL);
> CSharp::_Class1Ptr p(__uuidof(CSharp::Class1));
> com_ptr = p;
> double d = com_ptr->TestDouble();
>
> return d;
> }
>
> -----------stdafx.cpp-----------
> // stdafx.cpp : source file that includes just the standard includes
> // a.pch will be the pre-compiled header
> // stdafx.obj will contain the pre-compiled type information
>
> #include "stdafx.h"
>
> -----------a.def-----------
> LIBRARY a
> EXPORTS
> MyTest


Relevant Pages

  • Re: [LogoForum] arguments evaluation sequence
    ... > which automatically searches the function "registerPrimitives " in a user ... > that dll. ... that uses your DLL (i.e. no need to search for registered primitives). ... No other libraries or headers need to be installed, ...
    (comp.lang.logo)
  • RE: Visual C++ Runtime Error
    ... the issue seemed to be caused by a specifi .dll of the application. ... issue with a couple of scripts I have running in a server 2003. ... We're running Windows 2003 Server Enterprise Edition on the ... Please contact the application's support team for more information. ...
    (microsoft.public.windows.server.scripting)
  • Re: What programming language for Future
    ... version of the app. ... app-provided scripts will change with the vm, ... for the sole reason that they can't rebuild a working dll. ... With modules in VM languages one ...
    (comp.lang.misc)
  • Re: IIS and .dll file access problems
    ... IIS treats resources with the .DLL extension as "executable" ... like .ASP, as "scripts". ... .DLL extension is requested by the browser, IIS WILL attempt to execute the ...
    (microsoft.public.inetserver.iis)
  • Re: how to export global variable in C dll?
    ... DLL will not link. ... Avoid including CRT/PSDK headers in your DLL headers. ... inside extern "C" block, they're still definitions. ... Now these globals are exported without name mangling ...
    (microsoft.public.vc.language)