Groups | Blog | Home
all groups > c# > february 2005 >

c# : Object reference not set to an instance of an object


julien
2/10/2005 10:27:21 PM
Hello,
I got the error "Object reference not set to an instance of an object"
in this piece of code:

Assembly asm = Assembly.LoadFrom(location);
System.Attribute[] attributes = Attribute.GetCustomAttributes(asm);

I checked:
* location: this is the full path + file name of a dll
* asm is not null. asm.GetName().Version gives me the correct version

I don't see what is going wrong.

Thank you
Nick Malik [Microsoft]
2/14/2005 7:58:30 AM
Hello Julien,

I would guess the following:
If the first line fails, the object isn't set when it becomes a parameter to
the second line.

e.g.
[quoted text, click to view]
this line didn't find the file.

Therefore, asm is null.

Therefore:
[quoted text, click to view]

produces an error.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
[quoted text, click to view]

AddThis Social Bookmark Button