locked
Could not load file or assembly RRS feed

  • Question

  • Hi

    I get the following warning while loading my assembly which is in a folder inside my root folder

     

    The assembly named 'SmartTrade.Plugins.RedCoal' was loaded from 'file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/Plugins/SMS/SmartTrade.Plugins.RedCoal.dll' using the LoadFrom context. The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.

     

    Later methods in this assembly as called and one of the methods creates in instances of a class which is in another dll in the same subfolder and this causes the following error:

    The assembly with display name 'Interop.RedcoalMessaging' failed to load in the 'Anonymous' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Interop.RedcoalMessaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    File name: 'Interop.RedcoalMessaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

    === Pre-bind state information ===
    LOG: User = ST-AKL\amitesh
    LOG: DisplayName = Interop.RedcoalMessaging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
     (Fully-specified)
    LOG: Appbase =
    file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/
    LOG: Initial PrivatePath = NULL
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\VSS2005\v3.2\SmartTrade_Set2\SmartTrade_DevBuild\SmartTrade.vshost.exe.Config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL
    file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/Interop.RedcoalMessaging.DLL.
    LOG: Attempting download of new URL
    file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/Interop.RedcoalMessaging/Interop.RedcoalMessaging.DLL.
    LOG: Attempting download of new URL
    file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/Interop.RedcoalMessaging.EXE.
    LOG: Attempting download of new URL
    file:///C:/VSS2005/v3.2/SmartTrade_Set2/SmartTrade_DevBuild/Interop.RedcoalMessaging/Interop.RedcoalMessaging.EXE.

     

    Below is the code for loading the assembly:

    Friend Sub Load(ByVal sAssemblyFileName As String, ByVal oPluginGroup As IPluginGroup)

    Dim oAssembly As [Assembly]

    If Path.GetDirectoryName(sAssemblyFileName) = "" Then

    sAssemblyFileName = Path.Combine(Application.StartupPath, sAssemblyFileName)

    End If

    If File.Exists(sAssemblyFileName) AndAlso _

    (sAssemblyFileName.Substring(sAssemblyFileName.Length - 4, 4) = ".dll") Then

    ' the .dll file exists

    Trace.WriteLine(String.Format("Loading Plugin Assembly: '{0}'.", sAssemblyFileName))

    ' load the assembly given the filename

    oAssembly = [Assembly].LoadFile(sAssemblyFileName)

    If Not oAssembly Is Nothing Then

    ' load the assembly into the appdomain given the assemblyname

    AppDomain.CurrentDomain.Load(oAssembly.GetName)

    ' process all the types in the assembly

    ProcessPlugins(oAssembly, sAssemblyFileName, oPluginGroup)

    ' tracing message

    Trace.WriteLine(String.Format("Plugin Assembly Load Succeeded: '{0}'.", sAssemblyFileName))

    Else

    ' tracing message

    Trace.WriteLine(String.Format("Plugin Assembly Load Failed: '{0}'.", sAssemblyFileName))

    End If

    Else

    Trace.WriteLine(String.Format("Failed to find the assembly: '{0}.'", sAssemblyFileName))

    End If

    End Sub

     

     

    Any help will be appreciated

    Monday, March 31, 2008 3:23 AM

Answers