Where to specify the reference to DLL?

B

BG

Hi,
I have created a C++/CLI dll, say D, with VS 2005.
Now I want to use it in a project, say P, which is a console solution of
type managed C++.
They both compile with /clr .
D has a ref class which I want to use in P.

With header file of D included in P, P compiles fine, but then I get several
such link errors
TestDriver.obj : error LNK2020: unresolved token (06000018) MyClass::MyFunc
Attempted solutions:
1. _declspec(dllexport)
In D, if I change
ref class MyClass to
ref class __declspec(dllexport) MyClass, I get several such errors
__declspec(dllexport)/__declspec(dllimport) cannot be applied to a managed
type
during compile.

2. Tried to add D.dll as reference in P using Properties page. Didn't work.
Still got link time errors.
3. Tried to add D.dll as Project reference in P using Properties page. Still
got linking errors.

Questions:
1. In D, do I need to specify some functions for export? If so, how? All the
functions I want to use are in a ref class.
2. In P, where do I need to add a reference to D?
3. Any other link time attribute I need to add/modify?

Thanks for your help.
 
T

Tamas Demjen

BG said:
Questions:
1. In D, do I need to specify some functions for export? If so, how? All the
functions I want to use are in a ref class.

It's as simple as declaring it public:

public ref class MyClass [...]

Now MyClass is accessible to other managed modules.
2. In P, where do I need to add a reference to D?

#using <MyClass.dll>

or adding a reference to it in your project. What errors did you have?
Did you add the DLL's path to your #using path?
3. Any other link time attribute I need to add/modify?

The DLL must be on the path, so your application can find it.

Tom
 
B

BG

Tamas Demjen said:
BG said:
Questions:
1. In D, do I need to specify some functions for export? If so, how? All
the functions I want to use are in a ref class.

It's as simple as declaring it public:

public ref class MyClass [...]
Oops and Thanks.
That's exactly what I hadn't done.
 

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