- Home /
Create a .net library for hololens / uwp
Hello together,
i got an issue with one existing dll of us. Basically i try to convert a library of us with some basic network components to a .net version which can be used with unity and the hololens.
The problem i got here that i got it working with unity by using the .net 3.5 base class version of unity, which caused the issue that i cant use it with the hololens since it kinda requires uwp.
And when i tried to use a universal class library it had assembly errors in unity and crashed in visual studio when i ignored unity for that bit.
So basically i need to know to use which .net version to actually work with unity AND the hololens. At this moment iam just trying out everything that i can think off...
Thanks already for your help!
Greetings Alaitoc
Answer by Alaitoc · Mar 13, 2017 at 06:56 AM
Oh yeah, sorry that i didnt answer that question @Thijsvt.
I had to use a universal class library, imported the .dll into the unity project by adding it to the assets. Then i unchecked the plugin for the editor and compiled the project for uwp like you would do it normally for a hololens project. Then you should be able to see and use the referenced library in the created visual studio project.
For the part of the conversion of the old project (xamarin) to uwp. Basically i just created a universal class library and added all files as a link from the old project to the uwp project. The only changes i needed to make were removing threads and replacing them with tasks, so they would be compatible for both projects and needed to add a #ifdef for the network class with the sockets.
If you have any further questions, just ask and i will gladly help you out.
Greetings Alaitoc
hey @Alaitoc Thanks for replying. Do you have a thread example code by any chance? I am getting errors when tyring to compile and i think it's related to that part. Also it seems unity does not port my .dll's to the project for some reason.
Basically just replace the thread with a task:
private Task TestThread { get; set; }
public void StartTestThread()
{
m_bCancelThread = false;
TestThread = new Task(testThreadFunc);
TestThread.Start();
}
private void testThreadFunc()
{
do
{
// Do Something
}
while (!m_bCancelThread);
}
public void StopTestThread()
{
m_bCancelThread = true;
}
When are you getting errors when you want to compile though? In Unity or Visual Studio? $$anonymous$$ake sure for each .dll you import to check in Exclude Platforms the Editor. And i selected in the platform settings the sdk to UWP and scriptingbackend Dot Net, but not sure if that has any effect tbh.
In the build settings for windows store, i got Copy References and Unity C# Projects checked aswell.
A it seems i forgot to click copy references,
@Alaitoc Thanks for the example! it seems that my code just is not compatible for what i want to do because visual studio keeps complaining even though i use the correct methods that this is not available for my project.
i quess this is just the price we pay for monodevelop :S
No problem.
If you could provide some more detail on what you want to use, i probably could provide you more help with it. But maybe it is just not that easily compatible.
Wish you good luck anyway!
@alaitoc well it might be a bit to specific but I have 2 scenario's.
I would like to use the azure servicebus SD$$anonymous$$ functions but this is a no-go it seems because well the import doesn't even work.
Then you have the scenario where I want to use simple rest calls but I need to authenticate with the services of "System.Security.Cryptography" which are not able to import because the version of .net is different and the #if Windows_UWP or something similar just are not enough.
If you have any idea or brainfart on how to do this it would be more then welcome but then again I totally understand if that is to much of this is to specific.
Sadly i dont have a proper answer to those cases.
Though for 1. you might to check out this link and just maybe the library might be in a state where you can use it.
For 2. there should be core functions from the "System.Security.Cryptography" in UWP of some sort, but they are probably not enough for your scenario. So basically the only the solution would be to do a work around yourself and cut off the part for uwp where it goes wrong and add uwp compatible code from there. But this might be not really possible for you depending on your project and might take some time aswell.
So sorry that i cant really be much of a help, but i would be interested if you gain further insight on these aspects.
Wow this might be gold. going to try that library tommorow! Thanks man!
Answer by Thijsvt · Mar 12, 2017 at 07:36 PM
Alaitoc, Did you find the solution? I am struggeling with exactly the same issues....
Your answer
Follow this Question
Related Questions
Using .NET 4.6 features not supported by Unity WSA Build 2 Answers
Managed Plugin with System.Device assembly gives error 1 Answer
How can I have vuforia text recognition read in a phrase instead of just a single word. 1 Answer
Vicon DataStream SDK with unity 1 Answer
Why am I getting the Unity failed to run reference rewriter whenever I attempt to build my game? 2 Answers