zach-yu / protobuf-net

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

ProtoBuf Unity version can not work on Unity4.3.1 and compiled to WinPhone8 #426

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please include an e-mail address if this might need a dialogue!
==============

What steps will reproduce the problem?
1. copy full/wp8/protobuf-net.dll into Unity Project
2. Compile the Project to WinPhone8 version
3.

What is the expected output? What do you see instead?
Error building Player: Exception: Failed to run reference rewriter with command 
"--target="Temp/StagingArea\protobuf-net.dll" --framework="C:\Program Files 
(x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0,C:\Program 
Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Libraries" --platform="C:\Program 
Files (x86)\Windows Phone Kits\8.0\Windows MetaData\Windows.winmd" 
--support="Temp/StagingArea/WinRTLegacy.dll" --winmdrefs="" --system=Unity 
--dbg=pdb 
--alt=System.Net;System.Net.Sockets,System.Net;System.Xml.Serialization;System.C
omponentModel,System.Windows;System.Threading,mscorlib". 
[Temp/StagingArea\protobuf-net.dll]
Error: type `System.Runtime.Serialization.FormatterServices` doesn't exist in 
target framework. It is referenced from protobuf-net.dll at System.Object 
ProtoBuf.BclHelpers::GetUninitializedObject(System.Type).

What version of the product are you using? On what operating system?
Ver:r668
Windows 8
Visual Studio 2012

Please provide any additional information below.

Original issue reported on code.google.com by xiao.ao....@gmail.com on 10 Jan 2014 at 1:14

GoogleCodeExporter commented 9 years ago
You could perhaps using the portable version instead? I'd be interested whether 
that works - but: importantly, the portable version is compiled without the 
FormatterServices bits.

Original comment by marc.gravell on 10 Jan 2014 at 1:27

GoogleCodeExporter commented 9 years ago
Hi marc.gravell,
I try to use the CoreOnly/portable/protobuf-net.dll in project, It reports 
Exception:

Built from '' repo; Version is '4.3.1f1 (cebd4d9b5122) revision 93830'; Using 
compiler version '160040219'
BatchMode: 0, IsHumanControllingUs: 1, StartBugReporterOnCrash: 1, 
shouldGiveDebuggerChanceToAttach: 0
Initialize mono
Mono path[0] = 'C:/Program Files (x86)/Unity/Editor/Data/Managed'
Mono path[1] = 'C:/Program Files (x86)/Unity/Editor/Data/Mono/lib/mono/2.0'
Mono path[2] = 'C:/Program Files (x86)/Unity/Editor/Data/UnityScript'
Mono config path = 'C:/Program Files (x86)/Unity/Editor/Data/Mono/etc'
Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y
IsTimeToCheckForNewEditor: Update time 1389362387 current 1389410601

Unhandled Exception: System.TypeLoadException: Could not load type 
'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 
'protobuf-net'.

  at (wrapper managed-to-native) System.MonoCustomAttrs:GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool)

  at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0 

  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 

  at System.Reflection.Assembly.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeManager.IsThisOrFriendAssembly (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeManager+Closure.Filter (System.Reflection.MemberInfo m, System.Object filter_criteria) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.MemberCache.FindMembers (MemberTypes mt, BindingFlags bf, System.String name, System.Reflection.MemberFilter filter, System.Object criteria) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeManager.MemberLookup_FindMembers (System.Type t, MemberTypes mt, BindingFlags bf, System.String name, System.Boolean& used_cache) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeManager.RealMemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeManager.MemberLookup (System.Type invocation_type, System.Type qualifier_type, System.Type queried_type, MemberTypes mt, BindingFlags original_bf, System.String name, IList almost_match) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Expression.MemberLookup (Mono.CSharp.CompilerContext ctx, System.Type container_type, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Expression.MemberLookupFinal (Mono.CSharp.ResolveContext ec, System.Type qualifier_type, System.Type queried_type, System.String name, MemberTypes mt, BindingFlags bf, Location loc) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Attribute.ResolveConstructor (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Attribute.Resolve () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Attribute.Emit (System.Collections.Specialized.ListDictionary allEmitted) [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Attributes.Emit () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.PropertyBase.Emit () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Property.Emit () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.TypeContainer.EmitType () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.RootContext.EmitCode () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 

  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

(Filename:  Line: 0)

Original comment by xiao.ao....@gmail.com on 11 Jan 2014 at 3:37

GoogleCodeExporter commented 9 years ago
Unity 4.3.4f1 can't work well also. Is there any solution?

Original comment by miaoda...@gmail.com on 19 Feb 2014 at 11:23

GoogleCodeExporter commented 9 years ago
If you are targeting phone 8, I strongly suggest using the phone 8 build. 
However, if you remove the PLAT_BINARYFORMATTER build symbol, it won't attempt 
to use it. In particular, the symbols in play here are as shown:

#if PLAT_BINARYFORMATTER && !(WINRT || PHONE8)
            return System.Runtime.Serialization.FormatterServices.GetUninitializedObject(type);
#else
            throw new NotSupportedException("Constructor-skipping is not supported on this platform");
#endif

Original comment by marc.gravell on 19 Feb 2014 at 1:25

GoogleCodeExporter commented 9 years ago
This is happening to me on one computer, but not on another, which is weird 
since they're the exact same dll. Maybe the unity metro build process is 
hitting the GAC or something.

Original comment by bryanliv...@gmail.com on 14 May 2014 at 5:50

GoogleCodeExporter commented 9 years ago
Upgrading to the latest unity seems to have fixed the problem.

Here is the error that I was getting.

Error building Player: Exception: Failed to run Reference Rewriter with cmdline 
--target="Temp/StagingArea\protobuf-net.dll" --framework="C:\Program Files 
(x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5" 
--platform="C:\Program Files (x86)\Windows 
Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd" 
--support="Temp/StagingArea\WinRTLegacy.dll" --system=Unity --dbg=pdb 
--alt=System.Xml.Serialization.[Temp/StagingArea\protobuf-net.dll]
Error: type `System.Runtime.Serialization.FormatterServices` doesn't exist in 
target framework. It is referenced from protobuf-net.dll at System.Object 
ProtoBuf.BclHelpers::GetUninitializedObject(System.Type).
Error: method `System.Object 
System.Runtime.Serialization.FormatterServices::GetUninitializedObject(System.Ty
pe)` doesn't exist in target framework. It is referenced from protobuf-net.dll 
at System.Object ProtoBuf.BclHelpers::GetUninitializedObject(System.Type).
Error: method `System.Byte[] System.IO.MemoryStream::GetBuffer()` doesn't exist 
in target framework. It is referenced from protobuf-net.dll at System.Void 
ProtoBuf.BufferExtension::ProtoBuf.IExtension.EndAppend(System.IO.Stream,System.
Boolean).
Error: type `System.ComponentModel.ImmutableObjectAttribute` doesn't exist in 
target framework. It is referenced from protobuf-net.dll at 
ProtoBuf.ProtoBeforeSerializationAttribute.
Error: method `System.Void 
System.ComponentModel.ImmutableObjectAttribute::.ctor(System.Boolean)` doesn't 
exist in target framework. It is referenced from protobuf-net.dll at 
ProtoBuf.ProtoBeforeSerializationAttribute.
etc....

Original comment by bryanliv...@gmail.com on 14 May 2014 at 8:26

GoogleCodeExporter commented 9 years ago
I had the same errors -- looks like Unity tries to import a different .dll for 
the WP8 build (one located in Assets/Plugins/WP8).  I used the 
CoreOnly/Unity/protobuf-net.dll in my Assets/Plugins folder, and then created a 
new Assets/Plugins/WP8 folder, and added the CoreOnly/wp8/protobuf-net.dll 
there.  Now it builds fine.

More detail here: 
http://forum.unity3d.com/threads/unity3d-compiled-to-windows-phone8-failed-use-p
rotobuf-net.238580/#post-1677345

Original comment by s...@bitbybitstudios.com on 26 Jun 2014 at 2:24