Execution failing with System.IO.FileNotFoundException

Hi,

I'm having a .Net C# Win App for which i'm trying to use the Smart Assembly. When I try to create the project and generate the assembly and run the application, i'm encountering the following issue.

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

This seems strange as the SearchPath which is included in the .settings file contains the above mentioned assembly. Also another weird thing is, this Assembly doesn't come in the list of the Dependencies whenever I try to create the Project. I'm seeing every other dll, except this in the list of the dependencies. 

Thanks,
Ravi
Tagged:

Best Answer

  • Jessica RJessica R Posts: 1,274 Rose Gold 4
    Accepted Answer

    Hi Ravi,

    Thanks for your post!

    If the EntityFramework.SqlServer.dll isn't showing up as a dependency for merging or embedding, there are two likely causes:

    EntityFramework.SqlServer isn't directly referenced by the main assembly

    SmartAssembly only lists dependencies that are directly references, so if this dll is only loaded dynamically, SmartAssembly won't pick up on it. If that is the case and you want to include it, a possible workaround for this is to just add a reference and create a dummy call to the assembly, and then embed. (You should embed instead of merging, to keep it as a separate assembly to be loaded. Please note though that if the EXE loads an assembly via reflection from a specific file path, you should refrain from both embedding and merging it as it will still need to be loaded from that path.)

    -or-

    EntityFramework.SqlServer is signed with Microsoft's public key token

    SmartAssembly automatically excludes dependencies that are signed with Microsoft's public key token from the list of assemblies to embed as these are often framework assemblies which users will already have on their machines. It is possible to force Microsoft-signed dependencies to appear in the list, however, by creating the registry key (from regedit), HKEY_LOCAL_MACHINE\SOFTWARE\Red Gate\SmartAssembly 6\SupportsMergingFramework, where SupportsMergingFramework is a string value set to 1, as below:

    On the other hand, it sounds like the error is coming up because the dll isn't in the output directory (if you're launching your exe from SmartAssembly, it will normally ask if you want to copy dependencies to the output path but it wouldn't do this if EntityFramework.SqlServer is indeed loaded dynamically, so that it's not detected as a dependency). It should work though to just manually copy it there.

    Hope that info helps but please let us know if not!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Answers

Sign In or Register to comment.