Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions Can we store PROGID information in database and dynamically load the component



Dynamically load the component using PROGID

View(s): 20808

Can we store PROGID information in database and dynamically load the component?

Answer 1)

Yes, we load the component dynamically if we know the ProgID. But in general we will not store ProgID in database, instead we store in configuration file (web.config/app.config).

Once you read the ProgID from database/config, we load the object using Server.CreateObject. See below code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim a = Server.CreateObject("Scripting.FileSystemObject")
        Dim MyFile = a.CreateTextFile("e:\testfile.txt", True)
        MyFile.WriteLine("This is a test.")
        MyFile.Close()
End Sub

But this solution is easy if your target language is VB.NET as it supports late binding. And also C# 4.0 supports late binding using keyword (dynamic). But if we want to achieve same in rest of C# versions (1.1,2.0,3.0), we need to write lengthy code using reflection.


  Asked in:  ValueLabs   Expertise Level:  Experienced
  Last updated on Saturday, 25 January 2014
4/5 stars (6 vote(s))

Register Login Ask Us Write to Us Help