Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a project going on witch uses a DLL from an ERP system. The DLL is used to get information from the ERP, like invoices and such. The error i am getting is:

Inner Exception 1: FileNotFoundException: Could not load file or assembly 'SnelStartGatewayInterface, Version=12.48.37.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

But in the same window I used 'watch 1' to see the current using assembly's with the method:

AppDomain.CurrentDomain.GetAssemblies()

It returns a couple of assembly's. This is the one loaded in and exactly the same as seen in the error:

+ [36] {SnelStartGatewayInterface, Version=12.48.37.0, Culture=neutral, PublicKeyToken=null} System.Reflection.Assembly {System.Reflection.RuntimeAssembly}

Why would it return me the error?

Ps. I have tried the exact same method and dll in a windows forms test app and it was running fine.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
235 views
Welcome To Ask or Share your Answers For Others

1 Answer

Like Pawl Lukasik mentioned in the comments, you should look at the dependencies.

To do this, use:

private List<string> ListReferencedAssemblies()
{
    List<string> refList = new List<string>();
    var assemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
    foreach (var assembly in assemblies)
    {
        refList.Add(assembly.Name);
    }

    return refList;
} 

to see all referenced assemblies.

Or with LINQ:

private List<string> ListReferencedAssemblies()
{
    return Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(x => x.FullName).ToList();
} 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...