zach-yu / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Problems when loading protobuf as reference of dynamically loaded assembly #379

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am using protobuf-net.dll 2.0.0.622. 

What I am trying to do is to load an C# assembly (let's say xyz.dll) which has 
a reference on the protobuf-net.dll. 

First I create a byte buffer array of the file contents of xyz.dll. 
Next I call Assembly ass = Assembly.Load(buffer), loading the assembly. 
But when I try to call ass.GetTypes(), it crashes. 
I used fusion log to determine more information, giving the following log 
output: 

=== Pre-bind state information ===
LOG: User = NESSEE-DEV\user
LOG: DisplayName = protobuf-net, Version=2.0.0.622, Culture=neutral, 
PublicKeyToken=257b51d87d2e4d67
 (Fully-specified)
LOG: Appbase = file:///C:/Users/user/Documents/Visual Studio 
2010/Projects/NESSEE_AFT/Core.Service/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Core.Service.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\user\Documents\Visual 
Studio 2010\Projects\NESSEE_AFT\Core.Service\bin\Debug\Core.Service.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from 
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: protobuf-net, Version=2.0.0.622, Culture=neutral, 
PublicKeyToken=257b51d87d2e4d67
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/user/Documents/Visual 
Studio 2010/Projects/NESSEE_AFT/Core.Service/bin/Debug/protobuf-net.DLL.
LOG: Assembly download was successful. Attempting setup of file: 
C:\Users\user\Documents\Visual Studio 
2010\Projects\NESSEE_AFT\Core.Service\bin\Debug\protobuf-net.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: protobuf-net, Version=2.0.0.621, Culture=neutral, 
PublicKeyToken=257b51d87d2e4d67
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

As you can see, it is referencing the revision 622, but it found revision 621, 
leading to this crash. 

Any idea why this happens? 
Are you able to fix that? 

If you are in need of more information, please contact me: 
thomas.meschke@gmail.com

Kind regards, 
Thomas

Original issue reported on code.google.com by Thomas.Meschke on 21 May 2013 at 8:13

GoogleCodeExporter commented 9 years ago
It didn't pull 621 out of the air. So: where did it get 621 from? The error 
message suggests that C:\Users\user\Documents\Visual Studio 
2010\Projects\NESSEE_AFT\Core.Service\bin\Debug\protobuf-net.dll is 621, which 
you should be able to validate from the file explorer / file properties. You 
could try making sure "Specific Version" is "false" in the reference 
properties, or you could use a versioning policy in your config - but 
ultimately the main issue here is that your application got a copy of 621 from 
somewhere, when it expected 622. My biggest advice, then, is to ship the 
*expected* version of the dll.

For reference, IIRC 621 is from nuget, 622 is from google-code; they are 
slightly out of step at the moment, which will be fixed next deploy.

Original comment by marc.gravell on 21 May 2013 at 8:42