Visual Studio .NET - Compare and contrast LoadLibrary(), CoCreateInstance(), CreateObject() and Assembly.Load().

Asked By chitanya chitanya on 06-Feb-07 01:25 AM
end of post

Advanced Question - Robert Stanton replied to chitanya chitanya on 06-Feb-07 09:48 AM

Why are you asking this question?

Assembly.Load is the easiest. It will dynamically load an assembly based off the string name (or even raw byte array). You then have an assembly object from which you can use its metadata to do things with. Great for reflection.

LoadLibrary is the pInvoke way of doing things. It will basically load a dll into memory for you. I prefer not to use it. Assembly.Load returns an assembly object.

CreateObject is for use with COM. Basically when you want to load a com library.

CoCreateInstance will create an instance of a com object. I haven't ever needed this.

thank u just for interview purpose - chitanya chitanya replied to Robert Stanton on 06-Feb-07 09:57 AM

end of post

You should experiment with the methods before trying to talk about them

Robert Stanton replied to chitanya chitanya on 06-Feb-07 12:31 PM
Before going into an interview I would recommend that you try experimenting with those methods in code to see how they behave. I would also search through MSDN for some more detailed info.