简体   繁体   中英

Cannot load dll from another computer

I have an issue with loading a dll from another computer. It loads pretty fine from my station but when I tried testing it from another system that hasn't got Visual Studio installed, I get the following exception:

Date - 10 May 2012 12:01:48.0725000 - Exception has been thrown by the target of an invocation. Date - 10 May 2012 12:01:48.0881250 - System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. File name: 'System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' at ZENNLNGLIB.Process.ReadConfigFile() at ZENNLNGLIB.Process.ProcessFile(String fileName)

Assembly manager loaded from: C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\mscorwks.dll Running under executable C:\\Documents and Settings\\Administrator\\Desktop\\NLNG.Encryption\\NLNG.Encryption\\bin\\Debug\\NLNG.Encryption.exe --- A detailed error log follows.

=== Pre-bind state information === LOG: User = WS001ITS106\\Administrator LOG: DisplayName = System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (Fully-specified) LOG: Appbase = file:///C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : ZENNLNGLIB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: No application configuration file found. LOG: Using machine configuration file from C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config. LOG: Post-policy reference: System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/System.Xml.Linq.DL L. LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/System.Xml.Linq/Sy stem.Xml.Linq.DLL. LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/System.Xml.Linq.EXE. LOG: Attempting download of new URL file:///C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/System.Xml.Linq/System.Xml.Linq.EXE. LOG: Attempting download of new URL file:///C:/zennlnglib/System.Xml.Linq.DLL. LOG: Attempting download of new URL file:///C:/zennlnglib/System.Xml.Linq/System.Xml.Linq.DLL. LOG: Attempting download of new URL file:///C:/zennlnglib/System.Xml.Linq.EXE. LOG: Attempting download of new URL file:///C:/zennlnglib/System.Xml.Linq/System.Xml.Linq.EXE.

This is how I'm loading my dll:

Assembly u = Assembly.LoadFrom(@"C:\test\test.dll");

    Type t = u.GetType("Test.Process");
    MethodInfo m = t.GetMethod("ProcessFile");

    try
    {
        object[] myparam = new object[1];
        myparam[0] = @"C:\test\testFile.csv";

        result = (string)m.Invoke(null, myparam);

        Console.WriteLine(result);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message.ToString());
        Console.WriteLine(ex.InnerException.ToString());
        System.Threading.Thread.Sleep(100000);
    }

System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified

pretty says what happens. Check if the right version (3.5) of the .NET Framework is installed on the other machine where the error occurs.

if you try to load it from the locations which are printed below, look for the System.Xml.Linq dll in

C:/zennlnglib/System.Xml.Linq.DLL

I guess

C:/Documents and Settings/Administrator/Desktop/NLNG.Encryption/NLNG.Encryption/bin/Debug/

does not exist at the target machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM