Problem using DllImport on DLL that calls a 16-bit app

S

scott.sara.news

I am having major problems accessing some API's and I believe the
problem is a 16-bit app.

I originally had an application written in Borland Builder C++ 6
(32-bit)that loaded some API's for a specific database environment I
use. Everything worked great.

I am now trying to do the same thing in C# with the same DLL's but am
having a problem with one API call in particular. To begin using these
API's I have to start the environment by making an Init call. After
this, I can use any of the API calls I want. This Init call is what is
failing. Supposedly this call is responsible for starting up a 16-bit
EXE, which is the database environment. Could the .NET environment be
stopping this 16-bit app from being run from the DLL?

The funny thing is that if I start up my Borland app, and just let it
sit in the background, then I run my C# app, it works great! The Init
routine runs and works and all other calls work great. Obviously it is
because my Borland app has already run this 16-bit app and the C# call
doesn't have to.

Is there any way to force C# to run this 16 bit app from the DLL?

Any help would be greatly appreciated,

Scott
 
N

Nicholas Paldino [.NET/C# MVP]

Scott,

From what I know, it shouldn't prevent you from running the old 16-bit
application. Is it possible that the borland program performs calls to
initialize the C runtime (I remember something about this when using ATL),
or some other libraries that need to be initialized before the call to Init
is made (calls which would be inserted by default in a Borland app perhaps,
but not by default in .NET).

Hope this helps.
 
S

Scott

Thanks for the reply. I have gone through my Borland app with a fine
tooth comb and still cannot find what would make it any different from
my C# app.

I wonder if there is some sort of Project setting in .NET that I am
missing? It just seems funny that it cannot start the app, yet it can
use its API's no problem. It just pauses for a few seconds before
erroring out so it is obviously trying to start.

For the time being I have written a Borland app to do some interim work
for me. Hopefully I can get this working soon and get rid of the
Borland apps all together.

Thanks,
Scott
 
S

Scott

I found the problem! As it turns out, the directory I was creating my
project in is about 4 subfolders under My Documents. This path is way
too long for a 16-bit app. As soon as I moved my EXE out to a shallow
directory, directly under c:\, it worked perfectly!

Thanks for the reply and I hope that this helps someone else out there.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top