473,795 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.AVe ct<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.c pp" 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::Cla ssY^ Y;
public:
ClassX(){Y = gcnew TryInclude::Cla ssY;};
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::Cla ssY::ClassY()
{ IVectY = gcnew AVect<int>;
//a IVectY = gcnew AVectNT;
}
void TryInclude::Cla ssY::Method(){ IVectY->Append(2);}

Nov 17 '05 #1
0 1161

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

Similar topics

6
11538
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 function directly in the header file, or if the change the function to non-template. For example... *** Why am I getting a link error for template function f() in the code below?
1
5879
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 my webpage <URL
0
1367
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. Mostly this is done using a command object and a datareader. The data can also be edited - also using a command object and the executenonquery method. There is one page that uses a repeater. This works fine with no errors until you have...
0
1722
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) when including any files for templates .. #include <fstream> , #include <string>, #include <vector>, #include <list> etc... The funny thing is that was not happening before, it really used to work fine with templates. By removing the STL include...
1
1473
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, y; public: Coord (int i1, int i2) : x(i1), y(i2) {
12
2144
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 = New XslTransform()
6
4756
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 appreciated. Thanks in advance
3
7368
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 MFC6 <afxtempl.h> to get it to compile with the better standards confomance (mainly omitted typename, and lazyness with specialized templates - using BASE_CLASS & TYPE instead of CObList & CObList*) Now I get some strange linker errors, and I don't...
7
5026
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. I created the websetup and built the MSI, have the bundled version. Copied to webserver and ran Websetup.msi. Said I had to remove old version, which I did, then reran WebSetup.msi and keeps giving me this error. "The installer was interrupted...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.