> > I must be doing something really stupid. I just created a solution with
> > .NET
[quoted text clipped - 22 lines]
> Regards,
> Will
> One more update. When I create a .NET 2003 forms app and declare the dll
> entry point as in the following:
>
> [DllImport("D:\\TEES\\TEES\\TEES\\Debug\\TEES", EntryPoint="TestRNAV")]
> extern "C" int TestRNAV(char* vectorInitFile, char* vectorInputFile);
WinForms run on the .Net platform. What you are doing here is marking an
external function with the DllImport attriubte so that the compiler and
runtime for .Net conspire to insert the code the hops the fence fence
between .Net and the the unmanaged side of things, marshalls the arguments,
delegates to the unmanaged external function, and unmarshalls its return.
> It works just fine.
I love it when things work. :-)
>I cannot use the same technique in the DLL that calls
> the other DLL because first of all the compiler does not like the
> following
> line in the calling DLL:
>
> using namespace System::Runtime::InteropServices;
It is always a good idea to qualify words like "choke" with the exact text
of the compiler message. But if it occurs when trying to use .Net classes in
a native application it is a non-starter anyway.
> But even if someone could tell me how to fix that problem, I do not want
> to
> have either DLL compiled with the CLR or even as C++ for that matter
> because
> they need to interoperate with a LINUX environment.
I should tell you that I know nothing of 'nix, 'nux and 'pux development.
> PS: I believe that I noticed, when playing with Visual Studio 2005 Beta 2
> that there was a place in Project Properties to indicate that you could
> build
> without the CLR. Is there the equivalent in .NET 2003?
Sure. From the menu choose Project->Properties. Highlight the General item
under the Configuration folder in the left pane. In the right pane make sure
"Use Managed Extensions" is set to No.
So, I should tell you that you confuse me. :-) Earlier you said you were
compiling C source. But in a later post you mentioned a .cpp file extension.
So, assuming C++ is what you are after I created a solution with two console
applications - one executable, one DLL - with VS.Net 2003. This is the
source to the toy DLL:
// Adll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
__declspec(dllexport) int nAdll = 46;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
__declspec(dllexport) void Relnav_Exec(
void *init,
void *inputs,
void *state,
void *telem)
{
int x = nAdll;
}
This is the source to the toy executable:
// Main.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
__declspec(dllimport) void Relnav_Exec(
void *init,
void *inputs,
void *state,
void *telem);
__declspec(dllimport) int nAdll;
int _tmain(int argc, _TCHAR* argv[])
{
printf("nAdll= %d\n", nAdll);
Relnav_Exec(0, 0, 0, 0);
return 0;
}
It works here.
If you send me an email address (remove ".no.spam" and please don't post my
address in the group) I'll ZIP up the project.
Regards,
Will