.net - GAC – Assembly is in the GAC but “Could not load file or assembly” -
I have an interop DLL which was generated by Visual Studio for a third party COM object that I am one. Dll I am consuming in NET
I have registered both the interlock DLL in my consumer DLL and GAC. I have to use GAC because these DLLs are being used by a SharePoint 2010 workflow.
When the execution goes to the point where my DLL calls the call to DL, the following error "" file could not be loaded or the assembly "..." the system specified file "expected version and public With the key "could not be found.
If I check the Fusion Assembly binding log viewer, the following error log entry is listed in the Interop DLL:
log: GAC lookup was unsuccessful.
I can see that assembly in GAC, and it has the correct version and public key token, as the file is specified in the notfoned exception.
What's going on?
The problem is that, the version and public key are valid, processor architecture Interop should match your calling DLL. And, of course, the target framework should be the same version.
My DLL MSIL (agnostic, ANCPP) processor was compiled, but for some weird reason, Visual Studio insisted on compiling the interop x386.
(It may not be the cause of a problem in general, but my SharePoint server is 64 bit, which can cause symptoms to appear).
Interop yourself the solution:
1 - Cancel your DLL and Interop registration with GAC.
2 - Start the Visual Studio Command Prompt The Visual Studio Edition that is related to the .NET Framework is targeting its DLL (i.e. I developed my DLL in Visual Studio 2010). To do this step, I needed to start the Visual Studio 2008 Command Prompt)
3 - Generate Interopate using Tlbmp
< Code> tlbimp & lt; Full path and file name is COM .tlb & gt; /out:c:\.Interop.CoolThirdParty.dll/keyfile: & lt; Full path and snk file name & gt; / Machine: Agnewrite / Namespace: CooltartParty
/ Machine: Agnostic Interp is the reason for targeting MSIL Processor Architecture, which is my DLL
4 - Remove the old reference of the interop in your DLL project
5 - Delete the old interop file and replace it with the one you just created (like c:. Interop.CoolThirdParty.dll)
6 - Add a reference to the new interop in your interface.
7 - Reconstruction
8 - Register a new interop in your new build DLL and GAC
This should start working .
Comments
Post a Comment