Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InProcProxyFactory.CreateInstance called from WCF Service

I am trying to use the ServiceModelEx library from IDesign. When I try to call:

InProcFactory.CreateInstance();

from with in a WCF Service (basically calling WCF Service B from WCF Service A), I get the following error:

Could not find dynamic assembly

The code that is failing is:

  internal static Assembly[] GetWebAssemblies()
  {
     Debug.Assert(IsWebProcess());
     List<Assembly> assemblies = new List<Assembly>();

     if(Assembly.GetEntryAssembly() != null)
     {  
        throw new InvalidOperationException("Can only call in a web assembly");
     }
     foreach(ProcessModule module in Process.GetCurrentProcess().Modules)
     {
         assemblies.Add(Assembly.LoadFrom(module.FileName));
         if (module.ModuleName.StartsWith("App_Code.") && module.ModuleName.EndsWith(".dll"))
         {
             assemblies.Add(Assembly.LoadFrom(module.FileName));
         }
         if (module.ModuleName.StartsWith("App_Web_") && module.ModuleName.EndsWith(".dll"))
         {
             assemblies.Add(Assembly.LoadFrom(module.FileName));
         }
     }
     if (assemblies.Count == 0)
     {
         throw new InvalidOperationException("Could not find dynamic assembly");
     }
     return assemblies.ToArray();
  }

The assemblies are not pre-fixed with App_Web or App_Code because this is not a web site or a web application (it is a WCF Service). The code does work, however, if I call it from a web site, web application or EXE. Is this by deisgn?

like image 783
user472292 Avatar asked Aug 05 '26 14:08

user472292


1 Answers

Maybe the modules you expect have simply not been loaded in this scenario.

like image 188
Brad Thomas Avatar answered Aug 09 '26 22:08

Brad Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!