Hi all,

I'm using System.Activator.CreateInstance(type), to dynamically instantiate
a .Net class. I'm doing this inside a serviced component in the Construct
method. If the COM+ application is configured as library everything goes as
expected the type is instantiated.

Here is the piece of code that is giving me trouble:

asm = Assembly.LoadFile((assPath));  // Assembly loads OK
// The problem seams to be here why?
Type t = asm.GetType(type); // t returns null in a COM+ Server app???
ipc = (IMyComponent)System.Activator.CreateInstance(t); //BUMM

If however I change the COM+ application to a Server application it stops
working and I get this exception:

Unhandled Exception: System.Runtime.InteropServices.COMException
(0x8004E025): COM+ Activation failed because an initialization function
failed.  Check the event log for more information.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode, IntPtr errorInfo)
   at System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType,
Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri)
   at
System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(T
ype serverType)
   at
System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(T
ype serverType, Object[] props, Boolean bNewObj)
   at Test.Main(String[] args) in
C:\Projects\PipeLineTest\TestPipeline\Tester.cs:line 14
Press any key to continue

Can anyone help; I'm going mad with this.

Thanks,

Pedro


Pedro Moreira Santos
-----------------------
MCP, MCAD, MCSD

[EMAIL PROTECTED]
http://weblogs.pontonetpt.com/pmsantos

Se a vida fosse curta todos os homens seriam poetas.
If life was short every man would be a poet.

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to