Lazy Registration issue with Activator.CreateInstance

G

Guest

I have currently an issue with the following piece of code. The assembly is
to run under com+ (as Library) and the class derives from ServicedComponent.

Code: C# - .NET framework V1.1.4322

// Prepare fully qualified class name

fullyQualifiedNetClassTypeName = Namespace + "." + ClassName + ", " +
AssemblyName + ", " + "Version=" + AssemblyVersion + ", " + "Culture=" +
AssemblyCulture + ", " + "PublicKeyToken=" + PublicKeyToken;

// Create an instance of the class

netStatusType = Type.GetType(fullyQualifiedNetClassTypeName,true);
netStatusObject = Activator.CreateInstance(netStatusType);

When the blue line executes, I receive the following exception: "A first
chance exception of type 'System.IO.FileNotFoundException' occurred in
mscorlib.dll . Additional information: File or assembly name
d:\projects\hfdm\03 - developing\01 - development\source\maincodeline\hfdm
services\dell.hfdm.processflowcontroller\bin\debug\dell.hfdm.processflowclasses.dll, or one of its dependencies, was not found."

I checked multiple times and the dll exists. If I register the assembly
manually in COM+, it works. If it uses the autoregistration process (when
Activator.CreateInstance(netStatusType)is executed) I get the exception. If I
remove EnterpriseServices specific configuration (the class does not derive
from ServicedComponent), it works.

Checking the call stack (below), I see a strange call: The Assembly.Load
method has the path of the assembly as parameter but it should be the
Assembly name. Is it a bug?

mscorlib.dll!System.Reflection.Assembly.InternalLoad(System.Reflection.AssemblyName
assemblyRef = {System.Reflection.AssemblyName}, bool stringized = true,
System.Security.Policy.Evidence assemblySecurity = <undefined value>,
System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0x1ac bytes
mscorlib.dll!System.Reflection.Assembly.InternalLoad(string assemblyString
= @"d:\projects\hfdm\03 - developing\01 -
development\source\maincodeline\hfdm
services\dell.hfdm.processflowcontroller\bin\debug\dell.hfdm.processflowclasses.dll",
System.Security.Policy.Evidence assemblySecurity = <undefined value>,
System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0x68 bytes

-------- THE (MAYBE) WRONG CALL -----------
mscorlib.dll!System.Reflection.Assembly.Load(string assemblyString =
@"d:\projects\hfdm\03 - developing\01 - development\source\maincodeline\hfdm
services\dell.hfdm.processflowcontroller\bin\debug\dell.hfdm.processflowclasses.dll") + 0x1c bytes
---------------------------------------------

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationDriver.NewLoadAssembly(string
assembly = @"d:\projects\hfdm\03 - developing\01 -
development\source\maincodeline\hfdm
services\dell.hfdm.processflowcontroller\bin\debug\dell.hfdm.processflowclasses.dll") + 0x2d bytes

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationDriver.InstallAssembly(System.EnterpriseServices.RegistrationConfig
regConfig = {System.EnterpriseServices.RegistrationConfig}, System.Object
obSync = {System.EnterpriseServices.CatalogSync}) + 0xcb bytes

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationHelperTx.InstallAssemblyFromConfig(System.EnterpriseServices.RegistrationConfig
regConfig = {System.EnterpriseServices.RegistrationConfig}, System.Object
sync = {System.EnterpriseServices.CatalogSync}) + 0x5c bytes

mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage
msg = {System.Runtime.Remoting.Messaging.Message}, int methodPtr = 0, bool
fExecuteInContext = true) + 0x1a6 bytes

mscorlib.dll!System.Runtime.Remoting.RemotingServices.ExecuteMessage(System.MarshalByRefObject
target = {System.Runtime.Remoting.Proxies.__TransparentProxy},
System.Runtime.Remoting.Messaging.IMethodCallMessage reqMsg =
{System.Runtime.Remoting.Messaging.Message}) + 0xcb bytes

system.enterpriseservices.dll!System.EnterpriseServices.ServicedComponentProxy.LocalInvoke(System.Runtime.Remoting.Messaging.IMessage
reqMsg = {System.Runtime.Remoting.Messaging.Message}) + 0x200 bytes

system.enterpriseservices.thunk.dll!System.EnterpriseServices.Thunk.Callback.CallbackFunction( pData = 173406288) + 0xd5 bytes

system.enterpriseservices.thunk.dll!System.EnterpriseServices.Thunk.Callback.DoCallback(System.Object
otp = {System.Runtime.Remoting.Proxies.__TransparentProxy},
System.Runtime.Remoting.Messaging.IMessage msg =
{System.Runtime.Remoting.Messaging.Message}, int ctx = 1339536, bool
fIsAutoDone = false, System.Reflection.MemberInfo mb =
{System.Reflection.RuntimeMethodInfo}, bool bHasGit = true) + 0x272 bytes

system.enterpriseservices.dll!System.EnterpriseServices.ServicedComponentProxy.CrossCtxInvoke(System.Runtime.Remoting.Messaging.IMessage
reqMsg = {System.Runtime.Remoting.Messaging.Message}) + 0x231 bytes

system.enterpriseservices.dll!System.EnterpriseServices.ServicedComponentProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage
request = {System.Runtime.Remoting.Messaging.Message}) + 0x55 bytes

mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData
msgData = {System.Runtime.Remoting.Proxies.MessageData}, int type = 1) +
0x42a bytes

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationHelper.TryTransactedInstall(System.EnterpriseServices.RegistrationConfig
regConfig = {System.EnterpriseServices.RegistrationConfig}) + 0x114 bytes

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationHelper.InstallAssemblyFromConfig(System.EnterpriseServices.RegistrationConfig
regConfig = {System.EnterpriseServices.RegistrationConfig}) + 0x122 bytes

system.enterpriseservices.dll!System.EnterpriseServices.RegistrationThreadWrapper.InstallThread() + 0x46 bytes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

compilationconfiguration 1

Top