473,385 Members | 2,162 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,385 software developers and data experts.

TypeLoadException

I have created a DLL. It builds successfully without warnings.
I created an app that refereneces the DLL and it too builds.

However, when ever I try to use an object in the DLL
I get a "TypeLoadException", something like:
"Could not load type <name> from assembly <assembly name>"

Could someone tell me some common mistakes that result in this error?

Thank you in advance,
Eric
Jun 18 '06 #1
4 7175
"Eric B" <bo*********@invalid.com> wrote:
I have created a DLL. It builds successfully without warnings.
I created an app that refereneces the DLL and it too builds.

However, when ever I try to use an object in the DLL
I get a "TypeLoadException", something like:
"Could not load type <name> from assembly <assembly name>"

Could someone tell me some common mistakes that result in this error?


If you have an old version of the DLL which no longer exports the type,
and it is on the path (i.e. typically in the same directory) as the
program, then the program will give this error.

Is the .DLL file definitely up to date? Is the class library project
part of the same solution as the executable, so that VS does all the
required dependencies and copying? Try running .NET Reflector on the DLL
and checking that the type you're loading is in fact in from the DLL.

-- Barry

--
http://barrkel.blogspot.com/
Jun 18 '06 #2
Thanks for the feedback.
I assumed that if a reference was added and the DLL was
modified that the reference was still valid. I now have to
remove and add the reference everytime the DLL is modified
to avoid the problem.
This however is quite annoying. Is there a way to avoid this?
Thanks
Eric
"Barry Kelly" <ba***********@gmail.com> wrote in message
news:nt********************************@4ax.com...
"Eric B" <bo*********@invalid.com> wrote:
I have created a DLL. It builds successfully without warnings.
I created an app that refereneces the DLL and it too builds.

However, when ever I try to use an object in the DLL
I get a "TypeLoadException", something like:
"Could not load type <name> from assembly <assembly name>"

Could someone tell me some common mistakes that result in this error?


If you have an old version of the DLL which no longer exports the type,
and it is on the path (i.e. typically in the same directory) as the
program, then the program will give this error.

Is the .DLL file definitely up to date? Is the class library project
part of the same solution as the executable, so that VS does all the
required dependencies and copying? Try running .NET Reflector on the DLL
and checking that the type you're loading is in fact in from the DLL.

-- Barry

--
http://barrkel.blogspot.com/

Jun 19 '06 #3
"Eric B" <bo*********@invalid.com> wrote:
Thanks for the feedback.
I assumed that if a reference was added and the DLL was
modified that the reference was still valid. I now have to
remove and add the reference everytime the DLL is modified
to avoid the problem.
This however is quite annoying. Is there a way to avoid this?


Are the two projects part of the same solution? If they are, and you've
added the reference in the correct way (i.e. Add Reference | Projects
tab), then VS handle this automatically.

-- Barry

--
http://barrkel.blogspot.com/
Jun 19 '06 #4
Thanks again Barry,

I test the DLL with a test application that is part of the
same project as the DLL and seem to experience the issue.
I know this because I made some visual changes to a dialog
that was part of the DLL and those changes did not appear
until I removed and then readded the DLL using a slightly
different way to add it as follows:
Add Reference | Browse
I'll try your recommendation and see if this changes things.

Eric

"Barry Kelly" <ba***********@gmail.com> wrote in message
news:34********************************@4ax.com...
"Eric B" <bo*********@invalid.com> wrote:
Thanks for the feedback.
I assumed that if a reference was added and the DLL was
modified that the reference was still valid. I now have to
remove and add the reference everytime the DLL is modified
to avoid the problem.
This however is quite annoying. Is there a way to avoid this?


Are the two projects part of the same solution? If they are, and you've
added the reference in the correct way (i.e. Add Reference | Projects
tab), then VS handle this automatically.

-- Barry

--
http://barrkel.blogspot.com/

Jun 19 '06 #5

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

Similar topics

1
by: cody | last post by:
my problem is as follows: abstract class A { abstract Foo(); static Doit() { A = new B(); } }
0
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
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
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...
2
by: Eli Block | last post by:
When getting a type from a dynamically loaded assembly using Assembly.GetType, I receive the following exception: An unhandled exception of type 'System.TypeLoadException' occurred in...
1
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
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...
2
by: Scott Wisniewski | last post by:
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...
0
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...
0
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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
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,...

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.