Question

I'm trying to write a mixed-mode DLL, let's call it 'Client', to replace some unmanaged classes with their managed equivalents. Everything works fine on my personal machine, but when I check the source code in, our build machine won't build the project. It doesn't recognize the Managed classes I'm using from another DLL, called 'Core.'

I think the issue has to do with precompiled headers. Here's why:

To use the classes from 'Core', I added a reference to the 'Core' project in the 'Client' Project. If I remove this reference and then build the project on my personal machine, it still works. The CLR PCH doesn't recompile after removing the reference, though. If I recompile the CLR PCH, and then compile the project, it fails with the same errors that I get on the build machine: the managed classes are not recognized.

It seems to me that the managed classes from DLL's you import are defined in the precompiled header. I haven't been able to verify this, but that's the best guess I have. Does anyone have any insight they can shed on this issue? Are project references in Mixed DLL's resolved by putting hooks into the managed PCH?

Steps to Reproduce

The following makes no sense to me:

  1. Get Client to build.
  2. Remove the Reference from Client to Core. Compile Client. Client STILL builds. This is not expected.
  3. Recompile the Client PCH, then compile Client. Compile Client fails: the classes in 'Core' are undefined. This is expected behavior.
  4. Add Reference to Core, compile. Compile Client fails for the same reason. This is not expected
  5. Recompile the Client PCH, then compile Client. Client compiles fine.

My conclusion from this experiment is that the References are inserted into the project via precompiled headers, and that something is broken with the way this works, at least on our build machine.

Was it helpful?

Solution

There is another way to add references to a managed / mixed mode dll in C++/CLI - it's to add #using Core.dll to Client. This might solve your build problem.

OTHER TIPS

It can't work like that can it, because you don't need to use a precompiled header.
All a PCH does is allow you to speed up the build.
It doesn't do anything special with references.....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top