Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Product Architecture
Message
From
09/02/2009 10:37:19
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
07/02/2009 17:37:14
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Miscellaneous
Thread ID:
01379573
Message ID:
01380314
Views:
50
>>>>>>John,
>>>>>>About your second approach...
>>>>>>
>>>>>>So what you're saying is that I build my core components (NewsReader, Blog, ProductList, etc...) and have them each in a DLL. I would use reflection to load the DLL's. If a client wants to use NewsReaderOnSteroids instead of NewsReader, I would just develop the new component and deploy it in place of the existing DLL? I suppose I could use my config file to specify while DLL should get loaded for the component.
>>>>>>
>>>>>>I would think that this approach would lean heavily on implementing effective interfaces?
>>>>>
>>>>>
>>>>>That's true. If you want, I can send you some code snippets that we used. We allowed our clients to add custom code processing to an import process so that we didn't have to rewrite the entire load. The dll's were loaded on the fly using reflection and executed the customers code in the custom dll.
>>>>
>>>>John,
>>>>Some code snippets would be very helpful.
>>>>
>>>>I am having issues with the LoadData line saying "Object reference not set to an instance of an object" and I just can't figure out the syntax to create a new instance of my class.
>>>>
>>>>            Type myType = Assembly.LoadFile(@"C:\Newsletter.dll").GetType("NewsLetter");
>>>>
>>>>            INewsletter myNewsLetter = myType;
>>>>
>>>>            myNewsLetter.LoadData();
>>>>
>>>
>>>
>>>You can create an instance of myType with Activator.CreateInstance. Then check out Method.Invoke for actually running the method. I can't send the code till monday...
>>
>>I might be able to figure it out from that. Thanks again!
>
>PMFJI, Take a look at message# 1250223 and the rest of the thread for some ways to do this.

Using that thread I've found a method that works:
            System.Runtime.Remoting.ObjectHandle o = Activator.CreateInstanceFrom(@"C:\Newsletter.dll", "NewsLetter.NewsLetter");
            INewsletter myNewsLetter = (INewsletter)o.Unwrap();
I can now utilize myNewsLetter to use the functionality in the component I'm loading. Seems pretty straightforward. Thanks!
Very fitting: http://xkcd.com/386/
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform