Click here to Skip to main content
15,895,534 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Turning Existing Pile of Code into DLL Pin
led mike5-Sep-08 5:20
led mike5-Sep-08 5:20 
GeneralRe: Turning Existing Pile of Code into DLL Pin
Oddball5-Sep-08 5:28
Oddball5-Sep-08 5:28 
QuestionTo Fill DataSource of my ComBobox with Paper Orientation Enumeration Pin
mikobi2-Sep-08 19:52
mikobi2-Sep-08 19:52 
QuestionRAR compression Pin
dSolariuM29-Aug-08 19:38
dSolariuM29-Aug-08 19:38 
AnswerRe: RAR compression Pin
Paul Conrad30-Aug-08 8:05
professionalPaul Conrad30-Aug-08 8:05 
QuestionUpgrading vc 2003 project to vc 2008 Pin
Robin Imrie28-Aug-08 22:24
professionalRobin Imrie28-Aug-08 22:24 
AnswerRe: Upgrading vc 2003 project to vc 2008 Pin
Mark Salsbery29-Aug-08 9:19
Mark Salsbery29-Aug-08 9:19 
Questioncliext::list strange behavior Pin
ian__lindsay27-Aug-08 3:32
ian__lindsay27-Aug-08 3:32 
I am trying to use a cliext::list<> and am hitting various problems - apologies, its a long one - but stick with me Smile | :) . Before I start, I am using Visual Studio 2008 with service pack 1. I am (relatively) new to mixed mode programming - my background is pure C++ / MFC, etc - so it is entirely possible I am misunderstanding something. I have reduced my first problem to the following:

Header file:

#pragma once

#include <cliext/list>

private ref class TestClass
{
cliext::list<int> ^ m_list;
public:
TestClass(void);
};


.cpp file:

#include "StdAfx.h"
#include "TestClass.h"

TestClass::TestClass(void)
: m_list(gcnew cliext::list<int>())
{
}


Produces this little lot... (project name is LNK2022)

1>------ Build started: Project: LNK2022, Configuration: Debug Win32 ------
1>Linking...
1>TestClass.obj : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types (types: cliext.impl.list_impl<int,0>; fields: _Myhead): (0x0400000a).
1>TestClass.obj : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types (types: cliext.impl.list_impl<int,0>; fields: _Mysize): (0x0400000b).
1>TestClass.obj : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types (types: cliext.impl.list_impl<int,0>; fields: _Mygen): (0x0400000c).
1>TestClass.obj : error LNK2022: metadata operation failed (801311D7) : Differing number of fields in duplicated types (cliext.impl.list_impl<int,0>): (0x02000023).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118B) : Inconsistent implemented interfaces in duplicated types (types: cliext.impl.list_impl<int,0>; interfaces: System.Runtime.CompilerServices.CallConvStdcall): (0x09000001).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118B) : Inconsistent implemented interfaces in duplicated types (types: cliext.impl.list_impl<int,0>; interfaces: System.IDisposable): (0x09000002).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118B) : Inconsistent implemented interfaces in duplicated types (types: cliext.impl.list_base<int,0>; interfaces: System.Runtime.CompilerServices.CallConvFastcall): (0x09000003).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118B) : Inconsistent implemented interfaces in duplicated types (types: cliext.impl.list_base<int,0>; interfaces: System.Runtime.CompilerServices.CallConvThiscall): (0x09000004).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (cliext._Dehandle<int>): (0x02000021).
1>TestClass.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (cliext.is_handle<int>): (0x02000022).
1>LINK : fatal error LNK1255: link failed because of metadata errors
1>Build log was saved at "file://i:\dev\ians stuff\LNK2022\LNK2022\Debug\BuildLog.htm"
1>LNK2022 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Does anyone have any ideas? If I initialise the list in the header, the program compiles and links ok.

Ok, fine, I can live with that unless I want to hide my implementation of the constructor in the .cpp to reduce dependencies (my code is more complicated).

Anyway, next problem...

Header file:

#pragma once

#include <cliext/list>

private ref class TestClass
{
ref struct SInside
{
int mem1;
};

cliext::list<SInside ^> ^ m_list;

public:
TestClass()
: m_list(gcnew cliext::list<SInside ^>())
{}
};


No particular rocket science here, a nested struct being used as the type for the list container. Note initialisation in header - constructor removed from .cpp 'cos of point one above.

As soon as we construct the an object of type TestClass with the following in the form constructor:


TestClass ^ tmp = gcnew TestClass();


I get a message box with the following (my test app compiles to LNK2022.exe):

An unhandled exception of type 'System.TypeLoadException' occurred in LNK2022.exe

Additional information: Access is denied: 'Microsoft.VisualC.StlClr.IList`1[TestClass+SInside]'.


I am really not sure even what this is trying to tell me, but what I do know - after a lot of searching and head scratching (and randomly moving code) - if I move the nested struct outside of the class declaration, everything is fine. Again, in my real example this reduces my encapsulation, and I would rather not do it if possible.

If I move the nested struct to a public section of the class, all is ok too. I have tried the equivalent using std::list, and again all is fine (with a list of objects or pointers).

Question is, am I trying to do something that is not supported, have I done something obviously wrong, or is this a bug in the STL.net library?

<div class="ForumMod">modified on Wednesday, August 27, 2008 9:38 AM</div>
AnswerRe: cliext::list strange behavior [modified] Pin
George L. Jackson28-Aug-08 9:22
George L. Jackson28-Aug-08 9:22 
QuestionPlease check code update sqlserver with VC++6.0 Pin
aa_zz25-Aug-08 15:17
aa_zz25-Aug-08 15:17 
AnswerRe: Please check code update sqlserver with VC++6.0 Pin
Mark Salsbery26-Aug-08 5:56
Mark Salsbery26-Aug-08 5:56 
QuestionHow to load/use COM dll written in VS6 from VC++ .NET 2005 Pin
amalhotr25-Aug-08 10:03
amalhotr25-Aug-08 10:03 
QuestionRe: How to load/use COM dll written in VS6 from VC++ .NET 2005 Pin
led mike26-Aug-08 6:56
led mike26-Aug-08 6:56 
AnswerRe: How to load/use COM dll written in VS6 from VC++ .NET 2005 Pin
amalhotr26-Aug-08 7:37
amalhotr26-Aug-08 7:37 
QuestionPlease Guide I Update Sql2000 in VC++6.0 !!! Pin
aa_zz24-Aug-08 18:18
aa_zz24-Aug-08 18:18 
QuestionMultiple forms but with MDIParent container [modified] Pin
C# Beginner Nick24-Aug-08 16:56
C# Beginner Nick24-Aug-08 16:56 
AnswerRe: Multiple forms but with MDIParent container Pin
LionAM28-Aug-08 0:36
LionAM28-Aug-08 0:36 
QuestionMultiple Forms Pin
Polar_Sheep23-Aug-08 3:58
Polar_Sheep23-Aug-08 3:58 
AnswerRe: Multiple Forms Pin
teejayem23-Aug-08 4:50
teejayem23-Aug-08 4:50 
QuestionRe: Multiple Forms Pin
Polar_Sheep23-Aug-08 10:48
Polar_Sheep23-Aug-08 10:48 
AnswerRe: Multiple Forms Pin
dybs23-Aug-08 11:40
dybs23-Aug-08 11:40 
AnswerRe: Multiple Forms Pin
teejayem23-Aug-08 12:25
teejayem23-Aug-08 12:25 
QuestionRe: Multiple Forms Pin
Polar_Sheep23-Aug-08 18:13
Polar_Sheep23-Aug-08 18:13 
AnswerRe: Multiple Forms Pin
teejayem23-Aug-08 18:25
teejayem23-Aug-08 18:25 
NewsRe: Multiple Forms [modified] Pin
Polar_Sheep23-Aug-08 19:28
Polar_Sheep23-Aug-08 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.