none
Help to understand references to .Net assemby - need to use dll not in the same framework version RRS feed

  • Question

  • Hi,

    I have a solution with two projects:

    1. A library (dll) using Framework 3.5

    2. A Unity 3D* project which seems to use a subset of Framework 3.5 (Unity Subset v3.5)

    *Note: Unity 3D is a known software for videogames creation.

    In the DLL project I added the reference to System.Drawing. Since then I get the following warning in the Unity project which uses the resulting DLL (I translated from the original message I got in Spanish due to my installation):

    Main reference "myDllProject" cannot be resolved because it has an indirect reference to .NET Framework "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" assembly which could not be resolved in version the .NET Framework version of the current target. ".NETFramework,Version=v3.5,Profile=Unity Subset v3.5". To solve this problem, remove the reference to "myDllProject" or set the application target to a .NET Framework version which contains "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". MyUnityProject.CSharp

    I cannot change the .NET framework in the Unity project due to how Unity engine works. However I don't quite understand why this reference causes any issue, I would expect the Unity project to just run the DLL which would use it's respective .NET framework version (I mean, the DLL should work independently of where it is used, isn't it?), however seems like there is a dependency in the actual internal classes of the DLL project.

    So it would be really helpful if anyone can tell me why this dependency exist and how can I work around it (maybe adding the System.Drawing.dll directly in my project instead of referencing it from the framework installation folder?).

    Please let me know if anything was unclear.


    - Juanfra -


    • Edited by Juanfra 3 Wednesday, October 14, 2015 3:32 AM
    Wednesday, October 14, 2015 3:30 AM

Answers

  • Hi Juanfra 3,

    Based on your description, they are different projects. Mono and .NET Framework are two different implementations of .NET. They are different things. In .NET Framework 3.5 dll, it know where to get System.Drawing.dll and use it. But in Unity Subset 3.5, the compiler doesn't know how to deal with it.

    [In few words, I'm planning to use the .dll (which uses .NET 3.5) in other projects (not Unity projects), could be Java, C++, C#, or other languages that can use external dlls. Will I have issues with specific classes in each case?]

    Different technologies have different ways of calling external dlls.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 20, 2015 8:58 AM
    Moderator

All replies

  • Hi Juanfra 3,

    Unity Subset v3.5 is another implement of .NET. According to your description. It may not support System.Drawing.dll. I suggest you ask Unity3d related questions on its official forums.
    http://forum.unity3d.com/forums/scripting.12/

    Best Regards,
    Li Wang

    Thursday, October 15, 2015 1:35 AM
    Moderator
  • Thank you, however could you help me to understand why this is a problem? I mean, the .dll is created in a different project which uses .NET Framework 3.5, aren't the .dlls supposed to be isolated units that can be implemented in other different projects?

    I must say the Unity project seems to actually work, it throws errors when compiling from VS, but if I just deploy the .dll and let Unity compile its code by itself, the project runs fine. However I expect to reuse my .dll in other projects, some of them won't use .NET at all, they will just implement my .dll that uses the framework. What I am trying to do is actually possible, right?


    - Juanfra -

    Friday, October 16, 2015 12:31 AM
  • Hi Juanfra 3,

    [What I am trying to do is actually possible, right?]

    You need to remove System.Drawing reference from your dll and remove some code to fixed bug.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 16, 2015 5:51 AM
    Moderator
  • I think I didn't explained it well (since your answer seems to be to solve the Unity issue specifically).

    In few words, I'm planning to use the .dll (which uses .NET 3.5) in other projects (not Unity projects), could be Java, C++, C#, or other languages that can use external dlls. Will I have issues with specific classes in each case?

    Since I'm having issues with System.Drawing with a Unity project using my DLL, I don't understand how can I know which classes will give me troubles in other projects and languages.

    Note: In case it is not clear, the dll project and the Unity project are different projects, they just are in the same solution. The dll project uses .NET 3.5, and the Unity project uses Unity Subset 3.5.

    ...I'm starting to suspect this is just a bug of VS because I have both projects in the same solution.


    - Juanfra -

    Friday, October 16, 2015 11:06 PM
  • Hi Juanfra 3,

    Based on your description, they are different projects. Mono and .NET Framework are two different implementations of .NET. They are different things. In .NET Framework 3.5 dll, it know where to get System.Drawing.dll and use it. But in Unity Subset 3.5, the compiler doesn't know how to deal with it.

    [In few words, I'm planning to use the .dll (which uses .NET 3.5) in other projects (not Unity projects), could be Java, C++, C#, or other languages that can use external dlls. Will I have issues with specific classes in each case?]

    Different technologies have different ways of calling external dlls.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 20, 2015 8:58 AM
    Moderator