473,729 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TypeLoadExcepti on

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
TypeLoadExcepti on being thrown, stating that the type "std.iterat or" 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 2591
"Scott Wisniewski" <sc******@uwm.e du> wrote in message news:<eO******* *******@TK2MSFT NGP10.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
TypeLoadExcepti on being thrown, stating that the type "std.iterat or" 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.iterat or", 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 ComparerPredica te< 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 TypeLoadExcepti on 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( ))){
}
//...
IDictionaryEnum erator * IDictionary::Ge tEnumerator() {
return new Enumerator(this );
}
private:
__gc class Enumerator_ : IDictionaryEnum erator_ {
public:
Enumerator_(Tre eDictionary * dictionary) :
pDict_(dictiona ry),
pCur_(new iterator_type(d ictionary->pMap_->begin()))
{
}
//...
private:
//..
iterator_type * pCur_;
TreeDictionary * pDict_;
};
//...
map_type * pMap_;
};

and comparer predicate defined as thus

class ComparerPredica te : public std::binary_fun ction<T, T, bool> {
public:
ComparerPredica te() {
pComp_ = Comparer::Defau lt;
}
ComparerPredica te(IComparer * pComp) : pComp_(pComp) {
}
bool operator()(cons t T& first, const T& second) const {
return pComp_->Compare(firs t, second) < 0;
}
private:
gcroot<ICompare r *> pComp_;
};
Running new TreeDictionary( ) from a C# test driver works without any
problems.
However, when I try to do

TreeDictionary t = new TreeDictionary( );

foreach (DictionaryEntr y de in t) {
//blaaa...
}

I receive a TypeLoadExcepti on 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.c om> wrote in message
news:aa******** *************** ***@posting.goo gle.com...
"Scott Wisniewski" <sc******@uwm.e du> wrote in message

news:<eO******* *******@TK2MSFT NGP10.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
TypeLoadExcepti on being thrown, stating that the type "std.iterat or" 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
1583
by: cody | last post by:
my problem is as follows: abstract class A { abstract Foo(); static Doit() { A = new B(); } }
0
1164
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 on type b from assembly is overriding a method impl. We traced it to a class that implements multiple interfaces, two of which defined the same method, with same name and same signature. That is,
0
1761
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 between the server and the NUnit test suit is that the server will load the assembly (Flux.Grease.Services.dll) as a plugin in its own AppDomain whereas the NUnit test suit reference the assembly in the usual way. The code that performs the...
1
4719
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 upon starting the service with this line in code (long before this line is even being used) I get a System.TypeLoadException which I cannot debug since it seems to happen somwhere deep in the
1
1646
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 an TypeLoadException: public class test_TypeLoadException { static void Main() {
0
1480
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 causes a System.TypeLoadException trying to load one of my classes. I've created a small example that replicates the problem. If I compile this sample using Visual C# 2005 Express Edition Beta1 then it generates the following unhandled...
0
1511
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 binding errors (according to fuslogvw), no file version problems, the dll that the type is coming from is in the web's bin directory and has the version specified on the error screen, the IL is valid in the dll of the type being loaded. One odd...
1
2437
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 System.TypeLoadException (could not load type.... from assembly...) Any ideas?
0
1365
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 = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(mainDLLPath, "FullyQualifiedNamespace.Main.EntryPoint") o.StartMain(Nothing, Nothing)
0
8913
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...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
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
9142
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...
0
8144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
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
4525
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...
2
2677
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.