dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersGaurav Arora
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

How will u load dynamic assembly? How will create assemblies at run time?


Posted Date: 27 Jun 2008      Posted By:: Radha     Member Level: Silver    Member Rank: 0     Points: 1   Responses: 4



How will u load dynamic assembly? How will create assemblies at run time?





Responses

#256668    Author: Kumar Velu      Member Level: Gold      Member Rank: 124     Date: 27/Jun/2008   Rating: 2 out of 52 out of 5     Points: 6

Following code sample loads assembly from GAC (global assembly cache) on button click:

protected void btn_Click(object sender, EventArgs e)
{
AssemblyName asm = new AssemblyName("ClassLibrary1, Version=1.1.0.0, Culture=neutral, PublicKeyToken=fbc28d9ca2fc8db5");
Assembly al = Assembly.Load(asm);
Type t = al.GetType("ClassLibrary1.Class1");
MethodInfo m = t.GetMethod("Method1");
str = "reflection - " + (string)m.Invoke(null, null);
MessageBox.Show(str);
}

Refer:http://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html



 
#257069    Author: www.DotNetVJ.com      Member Level: Gold      Member Rank: 29     Date: 28/Jun/2008   Rating: 2 out of 52 out of 5     Points: 6

Hi,

There are basically two methods in .Net to generate dynamic code through your program. One is to use CodeDom library while other is to use Reflection Emit library. The System.CodeDom library is used to generate the standard CLS (Common Language Specification) compliant code that can be emitted in any of .Net languages. On the other hand, the System.Reflection.Emit library is used to generate the MSIL (Micrsoft Intermediate Language) code. Dot Net Reflection Emit allows us to construct assemblies, modules, types at runtime and define code inside these types.

Check out the below link
http://www.velocityreviews.com/forums/t94243-dynamic-assembly-loading-strategy.html

Thank s-- Vj
http://dotnetvj.blogspot.com

Thanks -- Vijaya Kadiyala
http://www.DotNetVJ.com
Microsoft MVP
Me & My Little Techie



 
#257070    Author: www.DotNetVJ.com      Member Level: Gold      Member Rank: 29     Date: 28/Jun/2008   Rating: 2 out of 52 out of 5     Points: 6

Hi,

There are basically two methods in .Net to generate dynamic code through your program. One is to use CodeDom library while other is to use Reflection Emit library. The System.CodeDom library is used to generate the standard CLS (Common Language Specification) compliant code that can be emitted in any of .Net languages. On the other hand, the System.Reflection.Emit library is used to generate the MSIL (Micrsoft Intermediate Language) code. Dot Net Reflection Emit allows us to construct assemblies, modules, types at runtime and define code inside these types.

Check out the below link
http://www.velocityreviews.com/forums/t94243-dynamic-assembly-loading-strategy.html

Thank s-- Vj
http://dotnetvj.blogspot.com

Thanks -- Vijaya Kadiyala
http://www.DotNetVJ.com
Microsoft MVP
Me & My Little Techie






 
#257583    Author: Ratheesh      Member Level: Gold      Member Rank: 711     Date: 30/Jun/2008   Rating: 2 out of 52 out of 5     Points: 1

Assembly.loadFrom("filepath")


An example looks as follows:

using System;

namespace Demo.Interfaces
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public interface IPlugin
{
int Calculate(int input);
}
}

Create this class in a separate class library (so that it becomes a separate assembly file). In this example, I'm just using an interface with one method in order to calculate a left-associative calculation on integer values. Basically, what I want to do is something like this:

(((((input operation1) operation2) operation3) operation4) operation5)

Where every operation is execute by a class implementing the IPlugin interface. An example of some implementations is this:

using System;
using Demo.Interfaces;

namespace Demo.Test
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Test1 : IPlugin
{
public int Calculate(int input)
{
return input * 2;
}
}

public class Test2 : IPlugin
{
public int Calculate(int input)
{
return input + 3;
}
}
}



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : How to retreive the value of last identity has been updated in a database (SQL Server)?
Previous : Difference between assembly manifest & metadata?
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.