473,499 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TypeLoadException

I am attempting to write a class to expose the STL map class to .NET
languages as an IDictionary. As part of the implementation I created an
implementation of IEnumerator that contains a pointer to an iterator.
However any calls to the enumerators constructor result in a
TypeLoadException being thrown, stating that the type "std.iterator" can't
be found in the assembly.

Does anyone know:

1) What is causing this exception to be thrown?
2) Is there any way to get around it?

Thanks
Scott Wisniewski
Nov 17 '05 #1
2 2567
"Scott Wisniewski" <sc******@uwm.edu> wrote in message news:<eO**************@TK2MSFTNGP10.phx.gbl>...
I am attempting to write a class to expose the STL map class to .NET
languages as an IDictionary. As part of the implementation I created an
implementation of IEnumerator that contains a pointer to an iterator.
However any calls to the enumerators constructor result in a
TypeLoadException being thrown, stating that the type "std.iterator" can't
be found in the assembly.

Does anyone know:

1) What is causing this exception to be thrown?
2) Is there any way to get around it?

Thanks
Scott Wisniewski


I don't know if you have the same problem I did, but yesterday I
solved mine using the information given here regarding forward
declarations:
http://www.winterdom.com/mcppfaq/archives/000262.html
Nov 17 '05 #2
The problem is that I don't know exactly what to add a forward decleration
for.

The type that is giving the error is "std.iterator", which I assume is some
instantion of the std::iterator template, which serves as the base class for
the map classes iterator.

I tried placing a typedef in the stdafx.h file to instantiate the map
template with the paramters I use in my program like this

typedef System::Object * key_type;
typedef System::Object * data_type;
typedef ComparerPredicate< key_type > predicate_type;
typedef std::map<gcroot<key_type>, gcroot<key_type>, predicate_type>
container_type;
typedef container_type::iterator iterator_type;

however, the program still throws a TypeLoadException every time its run.

I have a class that looks like this in another file (with details removed
for clarity)....
public __gc class TreeDictionary : IDictionary_ {
public:
TreeDictionary() : pMap_(new container_type(predicate_type())){
}
//...
IDictionaryEnumerator * IDictionary::GetEnumerator() {
return new Enumerator(this);
}
private:
__gc class Enumerator_ : IDictionaryEnumerator_ {
public:
Enumerator_(TreeDictionary * dictionary) :
pDict_(dictionary),
pCur_(new iterator_type(dictionary->pMap_->begin()))
{
}
//...
private:
//..
iterator_type * pCur_;
TreeDictionary * pDict_;
};
//...
map_type * pMap_;
};

and comparer predicate defined as thus

class ComparerPredicate : public std::binary_function<T, T, bool> {
public:
ComparerPredicate() {
pComp_ = Comparer::Default;
}
ComparerPredicate(IComparer * pComp) : pComp_(pComp) {
}
bool operator()(const T& first, const T& second) const {
return pComp_->Compare(first, second) < 0;
}
private:
gcroot<IComparer *> pComp_;
};
Running new TreeDictionary() from a C# test driver works without any
problems.
However, when I try to do

TreeDictionary t = new TreeDictionary();

foreach (DictionaryEntry de in t) {
//blaaa...
}

I receive a TypeLoadException saying that std.iterator can't be loaded.

Why does the loader have a program with TreeDictionary::Enumerator_, but not
with TreeDictionary? Both have pointers to unmanged types, so I would think
that both would either or work, or not work.

Shouldn't instantiating map in the std.afx also instantiate map::iterator,
which should inturn instantiate std::iterator?

Why don't those template instantiatons create the necessary meta data?
"Donna Gresh" <gr***@us.ibm.com> wrote in message
news:aa**************************@posting.google.c om...
"Scott Wisniewski" <sc******@uwm.edu> wrote in message

news:<eO**************@TK2MSFTNGP10.phx.gbl>...
I am attempting to write a class to expose the STL map class to .NET
languages as an IDictionary. As part of the implementation I created an
implementation of IEnumerator that contains a pointer to an iterator.
However any calls to the enumerators constructor result in a
TypeLoadException being thrown, stating that the type "std.iterator" can't be found in the assembly.

Does anyone know:

1) What is causing this exception to be thrown?
2) Is there any way to get around it?

Thanks
Scott Wisniewski


I don't know if you have the same problem I did, but yesterday I
solved mine using the information given here regarding forward
declarations:
http://www.winterdom.com/mcppfaq/archives/000262.html

Nov 17 '05 #3

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

Similar topics

1
1551
by: cody | last post by:
my problem is as follows: abstract class A { abstract Foo(); static Doit() { A = new B(); } }
0
1129
by: daechulsohn | last post by:
Just thought I would contribute some knowledge for a change. After hours tracking down a problem with obfuscated code, where we were getting the exception : System.TypeLoadException: Method a...
0
1744
by: Magnus Lindhe | last post by:
Hello, I'm trying to deserialize an XML document into a objects with the XmlSerializer which works fine in my NUnit test suit but fails with a TypeLoadException in the server. The difference...
1
4683
by: DC | last post by:
Hi, I am programming a windows service and all went well until I needed to use a simple array of chars which I initialize like this: char test = new char {'\x002F', '\x005E'}; Immediatly...
1
1614
by: @ndre | last post by:
Any type declaration of double leads to a TypeLoadException when run in cf (no compilation error), i.e. cf = reduced c# set??? see example below comments? @ndre this compiles with cf, but give...
0
1454
by: Tintax | last post by:
Hi All, I'm trying to create a generic node class for generating class hierarchies like XmlNode/XmlDocument. Unfortunately I'm running into an interesting problem where my code compiles fine but...
0
1482
by: ryan groth | last post by:
Every three or four compiles I get a TypeLoadException everytime I run a web application on the same one or two dlls. The exception information is vauge, no file errors, no permission errors, no...
1
2412
by: :\\\\derian | last post by:
Hello All, I'm attempting to add a c# DLL that uses unmanaged code to my VB project. When I add the C# DLL to the project and compile, all goes well but when i hit F5, i get a...
0
1352
by: Pierre-Alain Vigeant | last post by:
Hi, I'm getting a TypeLoadException inside an object that is located in a DLL that is dynamically loaded. I have this main program "main.exe" that dynamically load "main.dll" using o =...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
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
7386
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...
1
4918
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...
0
3098
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...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.