Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reflection in a Windows Service & WCF

Reflection in a Windows Service & WCF

Scheduled Pinned Locked Moved C#
csharpvisual-studiowcfdebuggingannouncement
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bernard Laplace
    wrote on last edited by
    #1

    Hi, I am trying to run the following code in a dynamically loaded WCF service hosted in a Windows Service. It seems I can't load types because of the following exception: Could not load file or assembly 'APLUGINASSEMBLY, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051' or one of its dependencies. The system cannot find the file specified. Here is the list of the referenced assemblies: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Viveo.Data, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051 NavigationProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullSystem.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Please note that the very same code works fine when I run the WCF Service from Visual Studio. :doh: Thanks.

    protected static void AnalysePlugins(Assembly[] Assemblies)
    {
    foreach (Assembly anAssembly in Assemblies)
    {
    try
    {
    foreach (Type aType in anAssembly.GetExportedTypes())
    {
    try
    {
    if (aType.GetInterface("ANINTERFACE") != null)
    {
    //Retrieves the name of each navigation
    string theNavigationName = (string)aType.InvokeMember("Name", BindingFlags.GetProperty, null, aType.GetConstructor(new Type[]{}).Invoke(new object[]{}), null);
    //Fills the data structures that keep reference of the navigation/type/assembly
    NavigationRepository[theNavigationName] = aType;
    PluginRepository[aType] = anAssembly;
    }
    }
    catch(Exception ex)
    {
    Trace.WriteLine(aType + " could not have its name queried");
    }
    }
    }
    catch (Exception ex)
    {

                    System.Diagnostics.EventLog.WriteEntry("BusinessServer", ex.Message);
                    System.Diagnostics.EventLog.WriteEntry("BusinessServer", string.Concat(anAssembly.GetReferencedAssemblies()));
                }
            }
        }
    
    B 1 Reply Last reply
    0
    • B Bernard Laplace

      Hi, I am trying to run the following code in a dynamically loaded WCF service hosted in a Windows Service. It seems I can't load types because of the following exception: Could not load file or assembly 'APLUGINASSEMBLY, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051' or one of its dependencies. The system cannot find the file specified. Here is the list of the referenced assemblies: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Viveo.Data, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051 NavigationProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullSystem.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Please note that the very same code works fine when I run the WCF Service from Visual Studio. :doh: Thanks.

      protected static void AnalysePlugins(Assembly[] Assemblies)
      {
      foreach (Assembly anAssembly in Assemblies)
      {
      try
      {
      foreach (Type aType in anAssembly.GetExportedTypes())
      {
      try
      {
      if (aType.GetInterface("ANINTERFACE") != null)
      {
      //Retrieves the name of each navigation
      string theNavigationName = (string)aType.InvokeMember("Name", BindingFlags.GetProperty, null, aType.GetConstructor(new Type[]{}).Invoke(new object[]{}), null);
      //Fills the data structures that keep reference of the navigation/type/assembly
      NavigationRepository[theNavigationName] = aType;
      PluginRepository[aType] = anAssembly;
      }
      }
      catch(Exception ex)
      {
      Trace.WriteLine(aType + " could not have its name queried");
      }
      }
      }
      catch (Exception ex)
      {

                      System.Diagnostics.EventLog.WriteEntry("BusinessServer", ex.Message);
                      System.Diagnostics.EventLog.WriteEntry("BusinessServer", string.Concat(anAssembly.GetReferencedAssemblies()));
                  }
              }
          }
      
      B Offline
      B Offline
      Bernard Laplace
      wrote on last edited by
      #2

      I found out! It works when I load the assemblies using LoadFrom instead of LoadFile (it is in a function that I have not provided).

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups