Konnte nicht geladen, Datei oder assembly

Habe ich eine einfache ausführbare Datei, ich möchte eine dll in. Ich habe es als Referenz. Ich habe eine app.config-Datei, weil die dll ist letztendlich nicht, werde in die ausführbare Datei ein Verzeichnis. Wenn ich mein Programm ausführen aus der IDE, alles ist fein, b/c, die die dll kopiert wird, ist es lokal, aber sobald ich ziehe meine ausführbare Datei aus, es stürzt ab. Meine fusion-Protokoll impliziert es, dass es die angegebene Datei nicht gefunden.

Meiner Main () - Methode:

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);

Assembly assembly = null;
String dllLocation = @"C:\BMS_ACTD\bin\DX\Tools\BmsReplayAnalysis.dll";
IToolsInterface myProgram = null; //from ToolsInterface.dll
try
{
    assembly = Assembly.LoadFrom(dllLocation);
}
catch
{
}

foreach (Type myType in assembly.GetTypes())
{
    if (myType.GetInterface(typeof(IToolsInterface).FullName) != null)
    {
        myProgram = (IToolsInterface)assembly.CreateInstance(myType.Namespace + "." + myType.Name, true);
        myProgram.RunTool();
        break;
    }
}

Hier ist meine config Datei:

<runtime>
    <dependentAssembly>
        <assemblyIdentity name="ToolsInterface" publicKeyToken="null" culture="neutral" />
        <codeBase version="1.0.0.0" href="file://C:/BMS_ACTD/bin/DX/Globals/ToolsInterface.dll"/>
    </dependentAssembly>
</runtime>

Möchte ich nicht haben, um sorgen machen starke benennen. Ich habe nur 1 version der dll, und das ist alles, was ich kümmern.

hier der Auszug aus der fusionlog:

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\greenj\Desktop\BmsReplayLauncher.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = BMS-JMGREEN\greenj
LOG: DisplayName = ToolsInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/greenj/Desktop/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = BmsReplayLauncher.exe
Calling assembly : BmsReplayLauncher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\greenj\Desktop\BmsReplayLauncher.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\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:/Users/greenj/Desktop/ToolsInterface.DLL.
LOG: Attempting download of new URL file:///C:/Users/greenj/Desktop/ToolsInterface/ToolsInterface.DLL.
LOG: Attempting download of new URL file:///C:/Users/greenj/Desktop/ToolsInterface.EXE.
LOG: Attempting download of new URL file:///C:/Users/greenj/Desktop/ToolsInterface/ToolsInterface.EXE.
LOG: All probing URLs attempted and failed.
Ist Ihr .config-Datei umbenannt, passend zu Ihrem Programm? Eg: program.exe => program.exe.config?
Ich muss zu formulieren, die ursprüngliche Frage basierend auf Ihrer Antwort. Ich hatte die falsche config (hatte das vshost-version). Having said that, das ist meine Frage, aktualisiert in einer Sekunde.

InformationsquelleAutor Jason | 2011-07-27

Schreibe einen Kommentar