Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Akeyn · Apr 04, 2021 at 10:35 AM · monodevelop

How to include MEF in Unity 2020 LTS ? (resolved)

I tried to include MEF library in Unity 2020 LTS

My project settings

Scripting Backend: Mono

Api Compatibility Level: .Net Standard 2.0

Here are my steps to try and include an external library:

  1. nupkg has been loaded from nuget.org

  2. Then i got the system.componentmodel.composition.5.0.0.nupkg

  3. And when i unpacked .nupkg file i got netstandard2.0/System.ComponentModel.Composition.dll

  4. Then i added System.ComponentModel.Composition.dll to Assets folder

  5. Then i got this error messages in console:

Error: Could not load signature of System.ComponentModel.Composition.Hosting.CompositionContainer:ReleaseExports due to: Could not resolve type with token 0100003c (from typeref, class/assembly System.Lazy`2, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51) assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Lazy`2 member:(null) signature:

Search for information

Some people say to create mcs.rsp file, which is now called scs.rsp as far as I understand.

And inside the file you have to add this line, it is only valid for mcs.rsp :

-r:System.ComponentModel.Composition

And for the file scs.rsp it should be correct:

-r:System.ComponentModel.Composition.dll

But I found Unity3d Manual page Referencing additional class library assemblies

And the following was written inside:

If your Project uses the .NET Standard

API Compatibility Level, you don’t need to take any additional steps to

use part of the .NET class library API.

Does this mean that I do not need to perform any additional steps in order for the library to start working?

It would be great if someone could help with this issue.

I have already tried the following points, but nothing works:

  • different versions of Unity (2018 LTS, 2019 LTS)

  • different versions of Api Compatibility Level (.Net 4.0)

  • creating scs.rsp file

  • creating mcs.rsp file

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Akeyn · Apr 06, 2021 at 11:29 AM

I was able to make the library work.

I was looking for a solution for a long time, came across the fact that this library is contained in .NET 4.x and I had to figure out how to import library it better, and I found a very simple solution it is take the library from the Unity folder and drop it into the Assets folder

Steps to import .dll

  1. I took the System.ComponentModel.Composition.dll library along the following path C:\Program Files\Unity\Hub\Editor\2020.3.2f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit

  2. Then I changed the Api Compatibility Level from .NET Standard 2.0 to .NET 4.x

  3. Voila everything works.

    If it was helpful, please like it ;)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image krupps · Nov 08, 2021 at 05:46 PM 1
Share

OMG, you are such a life saver! Why .Net Standard doesn't work, but I did notice even though the api is pointed to 2.0, the Unity project is still 4.7.1. I did did my library in 4.7.1, which was a pain since VS 2019 doesn't allow you too. I did all your recommendations and Finally I have my DryIoc using DI on all my game objects. Kudos!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

158 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is this a bug in MonoDevelop? I do NOT see what is wrong 2 Answers

error CS1041: Identifier expected 1 Answer

Start animation with different game object 0 Answers

WHY CAN'T I USE Time.deltaTime?! 2 Answers

Is it possible to Run R Code from Unity C# in Mono or .NET? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges