473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Link error when using Templates

I am using Visual Studio 2005 Beta1 and get the following errors when
building a .NET class library (called TryDLLPr in the example below). Any
advice on what's wrong will be greatly appreciated. The errors given are:

TryDLLPr.obj : error LNK2022: metadata operation failed (801311D6) :
Differing number of methods in duplicated types (TryInclude.AVect<int>):
(0x02000005).
LINK : fatal error LNK1255: link failed because of metadata errors

The following code, in the three files indicated, reproduces the errors.
Uncommenting the //a lines and deleting the corresponding lines do not give
any errors, indicating that the problem is related to my use of a template.
Also, uncommenting the //b lines and deleting corresponding lines in
"Included.h" and "Included.cpp" builds without error, but that route is not
attractive in my real applications.

//------------------------
//TryDLLPr.h
#pragma once
#include "Included.h"
namespace TryDLLPr
{public ref class ClassX
{private: TryInclude::ClassY^ Y;
public:
ClassX(){Y = gcnew TryInclude::ClassY;};
void Method(){Y->Method();};
};}
//-------------------------
//Included.h
#pragma once
namespace TryInclude
{template <class T> ref class AVect
{protected:
int iSize;
public:
AVect(){iSize=0;};
void Append(T _TI){iSize++;};
};
//aref class AVectNT
//a{protected:
//a int iSize;
//a public:
//a AVectNT(){iSize=0;};
//a void Append(int _TI){iSize++;};
//a};
public ref class ClassY
{AVect<int>^ IVectY;
//a AVectNT^ IVectY;
public:
ClassY();
void Method();
//b ClassY(){IVectY = gcnew AVect<int>;};
//b void Method(){IVectY->Append(2);};
};};
//-----------------------
//Included.cpp
#include "StdAfx.h"
#include "Included.h"
TryInclude::ClassY::ClassY()
{ IVectY = gcnew AVect<int>;
//a IVectY = gcnew AVectNT;
}
void TryInclude::ClassY::Method(){ IVectY->Append(2);}

Nov 17 '05 #1
0 1123

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Suzanne | last post by:
Hi++, I get a link error when I try to call a template function that is declared in a header file and defined in a non-header file. I do *not* get this link error if I define the template...
1
by: Thomas P. Fuller | last post by:
Hi, Thanks in advance for any help in this matter. I need to embed a link in the text portion of an xml element's value. For example, <some_element> Hi, my name is Tom, and you can find...
0
by: kate_cha | last post by:
Hello, I'm new to .net, so this may be a really easy question....I have been working on a .net application - each web page pulls information from a an access database and writes it to the screen. ...
0
by: JimmyS | last post by:
I am getting this error .. c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stl_alloc.h(305) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701)...
1
by: Don Kim | last post by:
I'm trying to compile the following code from "C++ Templates" Book by Josuttis and Vandervoorde, and I keep getting link errors: //coord.hpp #include <cstdlib> class Coord { private: int x,...
12
by: Amanda | last post by:
I have tried everything with this! I get an error stating "Index was outside the bounds of the array" My code looks like this.... xmlDoc = New XmlDocument() xmlDoc.Load("xml.doc") xslDoc...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Leith Bade | last post by:
I have been trying to use the new Visual C++ Toolkit 2003 with the VC6 IDE I set up the executable, inlcude, and library directories to point to the new compilers I had to fix a few errors in the...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.