473,382 Members | 1,657 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,382 software developers and data experts.

Type.GetType not finding the dll containing the method I want to use in a late bound context.

"Value cannot be null.\r\nParameter name: type" is the exception thrown
after the CreateInstance method below.

Type t = Type.GetType(GetConfigValue("PasswordProvider"));
IPasswordProvider ppdr= (IPasswordProvider)Activator.CreateInstance(t);

GetConfigValue DOES return the correct value from the config file -
"namespace.DBPassword, namespace"

It appears that Type.GetType is NOT finding the assembly whose name is the
same as the namespace above (DBPassword is the name of the class contained
within that assembly/dll.

In the remarks section for Type.GetType I read the following;

If the assembly has not been saved to disk when GetType is called, the
method returns a null reference . GetType does not understand transient
dynamic assemblies; therefore, calling GetType to retrieve a type in a
transient dynamic assembly returns a null reference (Nothing).

I can see that the dll DOES exist in the /bin/debug directory with a recent
timestamp. I would assume it has already been saved to disk when the search
is made for it.

Any ideas on how to troubleshoot this?

Thank you,
Greg
Nov 16 '05 #1
1 3182
Greg,

You should load the assembly first, through a call to the Load method on
the Assembly class (make sure to use the full assembly name). Fusion
*should* pick it up if it is in the bin directory.

Once you have that, you can call CreateInstance on the Assembly instance
returned, passing the full type name.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"hazz" <ha**@sonic.net> wrote in message
news:ez****************@TK2MSFTNGP11.phx.gbl...
"Value cannot be null.\r\nParameter name: type" is the exception thrown
after the CreateInstance method below.

Type t = Type.GetType(GetConfigValue("PasswordProvider"));
IPasswordProvider ppdr= (IPasswordProvider)Activator.CreateInstance(t);

GetConfigValue DOES return the correct value from the config file -
"namespace.DBPassword, namespace"

It appears that Type.GetType is NOT finding the assembly whose name is the
same as the namespace above (DBPassword is the name of the class contained
within that assembly/dll.

In the remarks section for Type.GetType I read the following;

If the assembly has not been saved to disk when GetType is called, the
method returns a null reference . GetType does not understand transient
dynamic assemblies; therefore, calling GetType to retrieve a type in a
transient dynamic assembly returns a null reference (Nothing).

I can see that the dll DOES exist in the /bin/debug directory with a recent timestamp. I would assume it has already been saved to disk when the search is made for it.

Any ideas on how to troubleshoot this?

Thank you,
Greg

Nov 16 '05 #2

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

Similar topics

7
by: Siggy | last post by:
How can I trap this error -User-defined type not defined - in order to make custom error messages, when there is a missing reference, or missing dll/ocx file. Siggy
6
by: Jim Bancroft | last post by:
Hi everyone, I'm having some trouble with the code below. I receive a compile-time error on the second line saying "; expected": private static void myTestFunction(long myLong) { ...
7
by: Clint Herron | last post by:
Howdy! I posted this question on CSharpCorner.com, but then realized I should probably post it on a more active newsgroup. This will be my only cross-post. I'm creating a game engine, and...
4
by: Chris Bower | last post by:
Reposted from aspnet.buildingcontrols: Ok, I've got a bunch of derived controls that all have a property Rights of type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so that I...
16
by: Dennis | last post by:
I have a class named "myclass" and an arraylist containing elements of type "MyClass". I want to get the value of a property of "MyClass" (a string type) for one of the arraylist elements. I...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
7
by: Martin Robins | last post by:
I am currently looking to be able to read information from Active Directory into a data warehouse using a C# solution. I have been able to access the active directory, and I have been able to return...
0
by: CrispinH | last post by:
Hi I've just upgraded some Type Editors from 1.1 to 2.0 and whilst they compile OK, I'm not getting any results in the test harness PropertyGrid. Usually when you select a particular property,...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...

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.