Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How can I create an instance of a System.Web.UI.Control viaCreateInstanceAndUnwrap?

Reply
Thread Tools

How can I create an instance of a System.Web.UI.Control viaCreateInstanceAndUnwrap?

 
 
kkaminski@kcura.com
Guest
Posts: n/a
 
      01-08-2008
Our clients want the ability to write their own custom web controls
that will get dynamically loaded onto a page. Essentially, they will
provide one or more DLLs that contain classes that will inherit from a
specialized base class. This specialized base class is essentially a
MustInherit class that inherits from System.Web.UI.Control. Our
clients want the ability to add, update, and remove these DLLs at any
time in order to change the system without having to restart IIS. I've
been struggling with this problem for a few days, and I've now hit a
stumbling block I'm having trouble overcoming.

From what I've read - In order to load an assembly into my ASP.NET
application in such a way that I can change it at a moment's notice
without restarting IIS, I have to create a new AppDomain. Here's how
I'm creating the AppDomain:

Dim setup As New System.AppDomainSetup
setup.ApplicationBase = path
setup.ShadowCopyFiles = "true"
appDomain = System.AppDomain.CreateDomain("RemoteLoaderDomain ",
System.AppDomain.CurrentDomain.Evidence, setup)

The "path" variable is the path to the directory that contains the
DLLs I'm planning on loading. I created a test DLL that contains a
class that inherits from my specialized base class and is marked as
Serializable. I then try to load it using CreateInstanceAndUnwrap

appDomain.CreateInstanceAndUnwrap("myAssemblyName" ,"myFullQualifiedPathName")

This call fails with the following exception:

System.Runtime.Serialization.SerializationExceptio n: The type
System.Web.UI.Control in Assembly System.Web, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not marked as
serializable.
Server stack trace: at
System.Runtime.Serialization.FormatterServices.Int ernalGetSerializableMembers(RuntimeType
type, Boolean excludeNonSerializable)
at
System.Runtime.Serialization.FormatterServices.Get SerializableMembers(Type
type, StreamingContext context)
at
System.Runtime.Serialization.Formatters.Binary.Wri teObjectInfo.InitMemberInfo()
at
System.Runtime.Serialization.Formatters.Binary.Wri teObjectInfo.InitSerialize(Object
obj, ISurrogateSelector surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at
System.Runtime.Serialization.Formatters.Binary.Wri teObjectInfo.Serialize(Object
obj, ISurrogateSelector surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectWriter.Serialize(Object
graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Serialize(Stream
serializationStream, Object graph, Header[] headers, Boolean fCheck)
at
System.Runtime.Remoting.Channels.CrossAppDomainSer ializer.SerializeMessageParts(ArrayList
argsToSerialize)
at
System.Runtime.Remoting.Messaging.SmuggledMethodRe turnMessage..ctor(IMethodReturnMessage
mrm)
at
System.Runtime.Remoting.Messaging.SmuggledMethodRe turnMessage.SmuggleIfPossible(IMessage
msg)
at
System.Runtime.Remoting.Channels.CrossAppDomainSin k.DoDispatch(Byte[]
reqStmBuff, SmuggledMethodCallMessage smuggledMcm,
SmuggledMethodReturnMessage& smuggledMrm)
at
System.Runtime.Remoting.Channels.CrossAppDomainSin k.DoTransitionDispatch(Byte[]
reqStmBuff, SmuggledMethodCallMessage smuggledMcm,
SmuggledMethodReturnMessage& smuggledMrm) Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData&
msgData, Int32 type)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName,
String typeName)

I've been trying to get this to work for a few hours now, and I've had
no luck. Is it simply not possible to do what I want through the .NET
framework? Oh - also, this is being written using .NET 1.1. I cannot
move to a different version of the framework.

Any help on this would be appreciated.

Thanks!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Failed to generate a user instance of SQL Server. Only an integratedconnection can generate a user instance. Harlan Messinger ASP .Net 2 03-28-2010 06:51 PM
why can't an instance instantiated within a class method access aprotected instance method? Greg Hauptmann Ruby 9 06-16-2008 10:16 AM
Can you create an instance of a subclass with an existing instance of the base class? Sandra-24 Python 18 04-29-2006 04:01 PM
Can you set a class instance's attributes to zero by setting the instance to zero? Gerard Flanagan Python 3 11-19-2005 06:58 PM



Advertisments