Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling for HoloLens #6

Closed
motionsmith opened this issue Mar 23, 2017 · 10 comments
Closed

Error compiling for HoloLens #6

motionsmith opened this issue Mar 23, 2017 · 10 comments
Assignees
Labels
Milestone

Comments

@motionsmith
Copy link

motionsmith commented Mar 23, 2017

Hello,

I'm trying to use zxing.unity.dll on the HoloLens. I'm so close.

When building, I'm getting the following error, related to System.ComponentModel.BrowsableAttribute:
Reference rewriter: Error: type System.ComponentModel.BrowsableAttribute doesn't exist in target framework.

There are about 4 of these errors that reference this namespace in various places. I saw a video online of someone who was successful in deploying ZXing to Unity/HoloLens, but they didn't mention this issue. I'm not sure if it's some version difference. But anyway, here are some specs:

  • Unity 5.5.1f1
  • ZXing.Net (not sure the version, but recent as of today)
  • Visual Studio 2015

Thank you!
Eric

@motionsmith
Copy link
Author

Following up with more info, it seems to be related to some post process that HoloToolkit is doing... so not sure if this falls under anyone's jurisdiction. The call stack reveals:

PostProcessWinRT:RunReferenceRewriter() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:560) PostProcessWinRT:Process() (at C:/buildslave/unity/build/PlatformDependent/WinRT/SharedSources/CSharp/PostProcessWinRT.cs:127) UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions) HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:219) HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:30)

@micjahn
Copy link
Owner

micjahn commented Mar 23, 2017

I think the ZXing.Unity build isn't perfect. But I can't test it myself. I looked a little bit around in the internet
and found some posts which describe solutions for the same or a similar problem.
Perhaps that would help you:
https://forums.hololens.com/discussion/3263/zxing-unity-barcode-dll-issue
https://forums.hololens.com/discussion/2337/has-anyone-been-able-to-successfully-use-zxing-in-their-hololens-app
https://mtaulty.com/2016/12/28/windows-10-uwp-qr-code-scanning-with-zxing-and-hololens/
It would be great if someone with more experience on unity can give me some hints (or a pull request) with changes in the zxing codebase to get it running out of the box.

@motionsmith
Copy link
Author

Thanks for the links. I think there are a lot of options to try. My current hypothesis is that there is an incompatibility with the HoloToolkit. But I still have a lot of options to try. I'll check in if I make any progress today.

@motionsmith
Copy link
Author

motionsmith commented Mar 23, 2017

@micjahn I found this user who has the same problem.
https://forum.unity3d.com/threads/zxing-net-and-browsableattribute.429933/

We need to remove references to the System.ComponentModel.BrowsableAttribute class/namespace. Do you think that the Unity build of ZXing.Net can go without this namespace? How hard would it be to remove?

(BTW, the other option mentioned in the thread produces a litany of other errors due to IL2CPP incompatibilities. I think removing the BrowsableAttribute references is lower friction).

I tried to build ZXing.Net right out of the box but got a bunch of errors. I'm not sure if it's a VS config issue, or what the problem is. If you are able to walk me through how to build ZXing.Net, maybe I can work to remove BrowsableAttribute. If you know how to safely remove reference to it in the Unity build of ZXing, that would be even better. :)

@motionsmith
Copy link
Author

Update: I think that we need to wrap the [Browsable] attributes in #if !UNITY. I can't compile the Unity build to find out (see my other thread), but I've copied the entire .NET 3.5 project into Unity and have been slowly combing through errors. That browsable attribute is one of the pieces that HoloLens doesn't like.

@micjahn
Copy link
Owner

micjahn commented Mar 24, 2017

I don't understand why other users get it running with the published assembly.
Anyway, ZXing.Net should be buildable out of the box. If you use VS 2012 or newer you have to disable
parallel builds because the different projects stay in the same directory and using the same obj directory.
I will remove the Browsable attribute next time and build a new binary. Hopefully this week.

@motionsmith
Copy link
Author

@micjahn It does work on Unity, just not a UWP application built by Unity (published as a Windows Store App). The error comes when Unity compiles for UWP, specifically.

So I guess the directive would be #if !UNITY && UWP. I'd be happy to pursue making this pull request if you can help me with my problem building the Unity-specific DLL.

@micjahn
Copy link
Owner

micjahn commented Apr 2, 2017

I made a special build without the Browsable attribute.
Please try it with your UWP app.
https://www.dropbox.com/s/9tzhrnvqco6csf1/zxing.unity.dll?dl=0

@motionsmith
Copy link
Author

Thanks! I'm going to try this asap.

@micjahn
Copy link
Owner

micjahn commented May 9, 2017

Next version of ZXing.Net will included binaries for unity without the Browseable attribute. Source code changes are already within the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants