Re: DllImportAttribute problem with VC++.Net by evilpixie
evilpixie
Wed Apr 12 10:45:02 CDT 2006
I used the wizard. (Go to New->Project->select Console Application from
choices listed and then poof! Automagically I have a set of files.)
This code is eventually going to be in a Windows Service. I am
writing/testing it outside of the Service shell because I was told that it's
easier to debug that way. (I am new to VC++.Net) This advice came with the
advice to select the Console Application setup.
In the documentation for the .dll, it is listed as int WINAPI
DNAGetRTValueAsString(char *szPoint, char *szValue, unsigned short nValue)
If I list it as such in my code (with the windows.h header file) I get the
same error.
Thanks for your help, I really appreciate it!
Sande
"William DePalo [MVP VC++]" wrote:
> "evilpixie" <evilpixie@discussions.microsoft.com> wrote in message
> news:4535B31C-54CB-4FE2-BE4E-7AF2908065EB@microsoft.com...
> > I'm using visual c++.net 2003 and I'm having a problem getting
> > DllImportAttribute to import a function from a .dll...
> >
> > The error message that I'm receiving:
> >
> > LIBCMTD.lib(wincrt0.obj) : error LNK2019: unresolved external symbol
> > _WinMain@16 referenced in function _WinMainCRTStartup
> > C:\DATA\Visual Studio Projects\eDNA Test Code\Debug\eDNA Test Code.exe :
> > fatal error LNK1120: 1 unresolved externals
> >
> > Here is my code:
> >
> > #include "stdafx.h"
> > #include "time.h"
> > #include <string>
> >
> > #using <mscorlib.dll>
> >
> > using namespace System;
> > using namespace System::Runtime::InteropServices;
> > using namespace System::IO;
> > using namespace std;
> > using namespace System::Collections;
> >
> > [DllImportAttribute("ezdnaapi.dll", EntryPoint= "DNAGetRTValueAsString",
> > CharSet=CharSet::Auto)]
> > extern int DNAGetRTValueAsString(char *szPoint, char *szValue, unsigned
> > short nValue);
> >
> >
> > The dll is in the systems32 folder.
> > Can anyone give me some advice with this?
>
> The error message is telling you that it can't find a proper entry point for
> your application. What kind of application do you want to build? Did you
> create the project from scratch or use the wizard?
>
> Regards,
> Will
>
>
>