sameera

I have a Excel document level customization project that is dependant upon another common class library project.
When I increment the version number of the class library the VSTO project fails to load it during run time.
The exception I get:

Could not load file or assembly 'CommonLibraryPrj, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69128d937baea9c7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The version of the library is now 1.0.1.0.
When I change it back, every works fine, but the library version MUST be updated as it's another product on its own.

How do I fix this


Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

Ji Zhou ¨C MSFT

Hi Sameera,

I try to perform your scenario with the following steps, if I have any misunderstanding about your problem, please feel free to point it out.

1. Create a ClassLibrary.dll (v1.0.0.0) using Visual Studio 2005 and C#.

2. Create a VSTO Excel document level solution, and add the ClassLibrary.dll created above as reference in this project. Build VSTO project.

3. Update ClassLibrary.dll with a new version number (v1.0.1.0).

4. Copy the new ClassLibrary.dll to VSTO projectĄŻs debug directory and replace the original file

5. Then open the customization document will raise the error you mentioned above.

But from my opinion, sadly to say, there is not a way to work around this behavior except you refer the new library and rebuild your VSTO. Without rebuilding VSTO project, the customization codes will not recognize new version dll by itself.

Thanks

Ji






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

Ji Zhou ¨C MSFT

For your information: after rebuild your solution, you can use Publish Wizard to update the deployed assembly, more information you can get from this link:

http://msdn2.microsoft.com/en-us/library/1h4c4ebb(VS.80).aspx

Thanks

Ji






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

sameera

Actually no, I have them both in the same solution. And dependcies are properly set so that the VSTO project is built only after the class library. And I've tried rebuilding them, removing the project reference (to the Class lib) and re adding it etc.
But I still get the same error.

There's a manifest file in XL that keeps this reference to the library version. And I suspect that somehow this is not getting updated to take the new library version. Could that be it I don't know how to update it manually.




Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

Ji Zhou ¨C MSFT

Hi,

Sorry, I still cannot reproduce your scenario. This time I create two projects into one solution. And set VSTO projectĄŻs dependency as ClassLibrary. But once I rebuild the solution. My vsto project will get the right version of ClassLibrary and copied it to Local place. Everything works fine.

I do not think this caused by manifest in excel file. The error message states that exception throws when your customization codes load the ClassLibrary, but not when your document loads your customization codes.

Thanks

Ji






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

sameera

HI Ji,

Thank you very much for your help.

But, this is really weird.
This does not happen in any other test project I create either. Only on the actual product (where it really matters Sad ) Also there are other projects in the solution that work correctly when their versions are incremented.

Maybe there's something in the VSTO project (specific to the project itself) that's holding on to this old reference. Here's the interesting bit: the class library has a webservice proxy class which is being used by the VSTO project. I think this is where the problem is.






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

sameera

After really messing around (regenerating strong names etc) now I get the error at compile time:

Error 10 The type '<a web service type name appears here>' is defined in an assembly that is not referenced. You must add a reference to assembly '<common library name>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69128d937baea9c7'.
<path to file>.cs 120 13

I get few of those errors and also:

Error 13 Argument '1': cannot convert from 'typeA [path to common library\commonprj.dll]' to typeA []'
<path to file>.cs 120 97






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

sameera

Oh finally fixed.
After deleting bunch of files in %appdata%\Company Name\LibraryName<some GUID> and rebuilding, finally worked.



Thanks.




Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

Ji Zhou ¨C MSFT

Hi,

Good news to hear your resolving the issue!

Thanks very much for your share of the solution. The problem is really weird. Putting your solution here will benefit other people in future.

Thanks again! J

Thanks

Ji






Re: Visual Studio Tools for Office Addin fails to load a DLL which had its version updated.

sameera

Hi!

Thank you also for taking the time out to help figure this out