Hi -
Here's another dllimport question. I'm attempting to access native code from managed code. In this case, I'm using the open source tinyXml - a C++ library and wrapping it with a C++/CLI class. I'm able to compile the source code into a win32 dll. I'm exposing a class - TiXmlDocument using __declspec(dllexport). I also expose the base classes. No problem.
On the C++/CLI side (VS2005), I can create an object pointer, i.e. TiXmlDocument *t ; Here's the header info:
__declspec(dllimport) class TiXmlDocument
{
public:
TiXmlDocument(const char *);
}
You may see where the trouble is be brewing. When I attempt to create an object that take's a file name as an argument, in this case, a xml doc to load, I get the LNK2028 error ... "__thiscall TiXmlDocument::TiXmlDocument(char const *)" .. ref-d in function "int __clrcall main(cli::array<class System::String ^>^"
The declaration is as follows:
String ^s = "demo.xml";
char* ps = (char*)Marshal::StringToHGlobalAnsi(s).ToPointer();
TiXmlDocument doc(ps);
Here's my win32 dll side:
class __declspec(dllexport) TiXmldocument : public TiXmlNode
{
public:
TiXmlDocument( const char * docName);
...
}
I wasn't clear if I had to tag the public method definitions also. I tried with and without with the same results.
What am I missing
Thanks,
Mike

YA DllImport question...
Matt Warren
I took a step back (again) with some simple hello world stuff. Using VS2005, I created a win32 dll with Exports enabled. I then created a hello world C++/CLI console app (/clr). I included the header file per your suggestion - "HelloWorldWin32Dll.h", referenced the HelloWorldWin32Dll.lib in the linker and everything builds fine. I added another constructor as follows:
CHelloWorldWin32Dll(const char * doc);
Now I'm able to create a few basic objects:
CHelloWorldWin32Dll *c1 = new CHellowRorldWin32Dll();
CHelloWorldWin32Dll *c2 = new CHelloWorldWin32Dll("doc.xml");
Also:
String^ s = L"doc.xml";char* ps = (char*)Marshal::StringToHGlobalAnsi(s).ToPointer();
CHelloWorldWin32Dll *c3 = new CHelloWorldWin32(ps);
works, too, as does intellisense. Looks like I've got some old school C++ code in the tinyXml libs that !IJW (doesn't just work). Unfortunately, this may point me back to P/Invoke.
Pierce Blaylock
John-at-WSRB
Goofs