managed C++ link error

G

Gary Hughes

I'm getting the following error when attempting to link a
managed C++ dll. I can't find any reference to these
errors with google. Can anyone help? I've included the
class definition causing the errors below.

Everything compiles fine and all the types are defined, it
appears that the template type
itga::blush:rder_collection::iterator is causing the trouble.

Gary.

Compiling...
OrderEnumerator.cpp
Linking...
Creating library z:\bin\ITGAdotnetd.lib and object
z:\bin\ITGAdotnetd.exp
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131187) : Inconsistent method declarations in
duplicated types (types: OrderEnumerator; methods: .ctor):
(0x06000001).
OrderEnumerator.obj : error LNK2022: metadata operation
failed (80131188) : Inconsistent field declarations in
duplicated types (types: OrderEnumerator; fields:
m_current): (0x04000013).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

Build log was saved
at "file://z:\src\desk\client\dotnet\Debug\BuildLog.htm"
ITGAdotnet - 3 error(s), 0 warning(s)

---------------------------------------------------------

public __gc class OrderEnumerator : public
System::Collections::IEnumerator
{
public:

OrderEnumerator(const itga::blush:rder_collection_ptr&
collection,
const
itga::blush:rder_collection::iterator& position);

~OrderEnumerator();

__property System::Object* get_Current();
bool MoveNext();
void Reset();

private:

itga::blush:rder_collection_ptr* m_orders;
itga::blush:rder_collection::iterator* m_current;

};
 
B

Brian Pietsch

I've had this before and was never able to narrow down the exact cause, but
is seemed to have to do with the order of #using<> statements (esp. when
you're including header files that also have #using<> statements). Make
sure you're not #using anything twice if you don't need to or at all if you
don't need it.

Brian
 
G

Gary Hughes

Thanks for the clues Brian but no joy. I have stripped
things down so that I have four files.

OrderEnumerator.h
OrderEnumerator.cpp
OrderCollection.h
OrderCollection.cpp

These files are not included in any other project files.
Adding #include "OrderEnumerator.h" to OrderCollection.cpp
causes the error in question. I don't actually use
anything from OrderEnumerator.h I just include the file.
There are no #using statements in these files. I include
the definitions of the itga:: stuff via stdafx.h, I have
tried including them directly in both the header and cpp
files in question as well.


Furthermore if I comment out the use of
itga::blush:rder_collection::iterator then the problem goes
away. Everything compiles fine and I use the
itga::blush:rder_collection::iterator elsewhere (in a plain cpp
library and a COM wrapper library) with no problems both
with VC++ and G++ on solaris.

All the unerlying cpp files have include guards and the
managed header files all have #pragma once.

It appears VC++ is generating some kind of symbol
information and getting it wrong, maybe involving forward
declarations?

btw, I'm using visual studio 2003.

Does anyone have any clues?
 
G

Gary Hughes

Furthermore if I simply put all the code from
OrderEnumerator.[h|cpp] into OrderCollection.cpp it
compiles and links without a problem.
 
G

Gary Hughes

-----Original Message-----

--------------------

This usually happens because somehow the compiler puts slightly different
metadata in two modules for the same type. At link time, when the metadata
is merged, this error is emitted because the name for the type is the same,
but there is some descrepancy in the rest of the metadata describing that
type. The first thing I would look at are the command line options used to
compile the two modules, and then I would look at the includes leading up
to the definition of the type for the two modules. Both of these things can
sometimes affect the metadata for a type. If these don't yield any clues,
then I would use metainfo to dump the metadata for the two object files,
and look for the differences that way. Often this will lead you back to the
includes or the command line options.

I hope this helps. Good luck!

Hi Daniel,

No luck still, the two files in question
OrderCollection.cpp and OrderEnumerator.cpp have exactly
the same build options. They each include the unmanaged
code through a single header which is included in stdafx.h.

I used metainfo to dump the .obj files and I can't see any
differences in the type in question
itga::blush:rder_collection::iterator, although I am admittedly
inexperienced with this and could be missing something.

I had initially thought it must be something along the
lines of what you mentioned with include order causing the
problem however I don't see how this can be the case as
the type is included from one point only.

I've tried creating a simple test case but have been
unable to do so.

Gary.
 
D

Daniel Tomko [MSFT]

--------------------
From: "Gary Hughes" <[email protected]>
Sender: "Gary Hughes" <[email protected]>
Subject: RE: managed C++ link error
Date: Thu, 7 Aug 2003 22:36:22 -0700


Hi Daniel,

No luck still, the two files in question
OrderCollection.cpp and OrderEnumerator.cpp have exactly
the same build options. They each include the unmanaged
code through a single header which is included in stdafx.h.

I used metainfo to dump the .obj files and I can't see any
differences in the type in question
itga::blush:rder_collection::iterator, although I am admittedly
inexperienced with this and could be missing something.

I had initially thought it must be something along the
lines of what you mentioned with include order causing the
problem however I don't see how this can be the case as
the type is included from one point only.

I've tried creating a simple test case but have been
unable to do so.

Gary.

Would it be possible to try this without precompiled headers? I'm just
thinking of ways to reduce complexity to narrow down the problem.
 
G

Gary Hughes

-----Original Message-----

I've already tried that, I've also tried to create a
separate project with a really simple test case but I
can't get it to fail so somehow the complexity of the real
project is making it break.

Gary.
 
D

Daniel Tomko [MSFT]

--------------------
From: "Gary Hughes" <[email protected]>
Sender: "Gary Hughes" <[email protected]>
Subject: Re: managed C++ link error
Date: Wed, 6 Aug 2003 22:25:59 -0700
Message-ID: <[email protected]>

Furthermore if I simply put all the code from
OrderEnumerator.[h|cpp] into OrderCollection.cpp it
compiles and links without a problem.
-----Original Message-----
Thanks for the clues Brian but no joy. I have stripped
things down so that I have four files.

OrderEnumerator.h
OrderEnumerator.cpp
OrderCollection.h
OrderCollection.cpp

These files are not included in any other project files.
Adding #include "OrderEnumerator.h" to OrderCollection.cpp
causes the error in question. I don't actually use
anything from OrderEnumerator.h I just include the file.
There are no #using statements in these files. I include
the definitions of the itga:: stuff via stdafx.h, I have
tried including them directly in both the header and cpp
files in question as well.


Furthermore if I comment out the use of
itga::blush:rder_collection::iterator then the problem goes
away. Everything compiles fine and I use the
itga::blush:rder_collection::iterator elsewhere (in a plain cpp
library and a COM wrapper library) with no problems both
with VC++ and G++ on solaris.

All the unerlying cpp files have include guards and the
managed header files all have #pragma once.

It appears VC++ is generating some kind of symbol
information and getting it wrong, maybe involving forward
declarations?

btw, I'm using visual studio 2003.

Does anyone have any clues?
link defined, -
.

Is there any way you could send us a small, self contained repro for this.
I've been playing with it a little, and haven't had any luck. I'm curious
enough about this, but really need to play with it and debug it.

If you have such a repro case, please send it directly to me. Just remove
the "online." from my email address.
 
S

Samarpan

Hi,
I am getting a strange LNK Error 1215 saying

fatal error LNK1215: metadata operation failed (8013110E) : Database file is corrupt and may not be usable.

when I am trying to declare any function in my entire project .. sometimes I reset some events it works fine ... It even happened when I tried to declare variables and used .. When I used the same code in the page load event it worked .. Dont know what is happening ? Pls help me ........ This is a real showstopper for me as I am almost on the delivery stage ..... Please please help me ...

Thanks in advance
Samarpan


From http://developmentnow.com/g/42_2003_8_0_0_152364/managed-C-link-error.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 
P

Peter Oliphant

I think I can solve your problem, same thing happened to me...

Let me guess. Your project started out under one version of the compiler
(say, 2002), and you loaded it up into another one (say, 2003), and it
converted it for you. Well, in my case, this conversion was not perfect, and
2 weeks later I also got random error 1215 errors. The compiling errors you
get will be random and not make sense (e.g., you add a line of code and
something totally unrelated that use to work stops working).

Solution? Create a BRAND NEW project under the new compiler (in the example
above, 2003) of the same type, copy your source over, and it should work
now.

This might also happen converting to 2005, but my experience was conversion
from 2002 to 2003. The weird part is it all worked great until 2 weeks
later, so that really made it tough to figure out what went wrong! The point
being that you might have converted your project a long time ago and this
still could be the cause.

By the way, if you look down lower in this newsgroup, around October 19th at
2:16PM, you'll see a thread I started when this happened to me called
"LINKER ERROR 1215"...

Let me know if that was your problem too... : )

[==P==]
 
V

vampyren

I have the same problem. I had a .NET project which i had not used for
a while and now when i try to build i get this error:
fatal error LNK1215: metadata operation failed (8013110E) : Database
file is corrupt and may not be usable.

I tried everything and finally i changed the "Create/Use/ Precompile
header" option to "Create Precompiled Header (/Yc)" and recompiled and
to my supprise it started to work again!

hope it helps

Peter said:
I think I can solve your problem, same thing happened to me...

Let me guess. Your project started out under one version of the compiler
(say, 2002), and you loaded it up into another one (say, 2003), and it
converted it for you. Well, in my case, this conversion was not perfect, and
2 weeks later I also got random error 1215 errors. The compiling errors you
get will be random and not make sense (e.g., you add a line of code and
something totally unrelated that use to work stops working).

Solution? Create a BRAND NEW project under the new compiler (in the example
above, 2003) of the same type, copy your source over, and it should work
now.

This might also happen converting to 2005, but my experience was conversion
from 2002 to 2003. The weird part is it all worked great until 2 weeks
later, so that really made it tough to figure out what went wrong! The point
being that you might have converted your project a long time ago and this
still could be the cause.

By the way, if you look down lower in this newsgroup, around October 19th at
2:16PM, you'll see a thread I started when this happened to me called
"LINKER ERROR 1215"...

Let me know if that was your problem too... : )

[==P==]

Samarpan said:
Hi,
I am getting a strange LNK Error 1215 saying

fatal error LNK1215: metadata operation failed (8013110E) : Database file
is corrupt and may not be usable.

when I am trying to declare any function in my entire project .. sometimes
I reset some events it works fine ... It even happened when I tried to
declare variables and used .. When I used the same code in the page load
event it worked .. Dont know what is happening ? Pls help me ........ This
is a real showstopper for me as I am almost on the delivery stage .....
Please please help me ...

Thanks in advance
Samarpan


From
http://developmentnow.com/g/42_2003_8_0_0_152364/managed-C-link-error.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 

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