English isn’t my first language so I will do my best to explain to you.
I want to import an external DLL to my project (a third-party DLL) but when I try to import it, my DLL doesn’t appear between the options in the folder. For this reason I copied the DLL directly in the Assets folder. However, when I create a script and I use this DLL I get this error:
Assets/PruebaDDS.cs(4,7): error CS0246: The type or namespace name `nddsdotnet’ could not be found. Are you missing a using directive or an assembly reference?
I have put the using directive (“using nddsdotnet”), the DLL is in the Asset folder and in the References of MonoDev, so what could be the error?
This is my code:
using UnityEngine;
using System.Collections;
using System;
using nddsdotnet;
public class PruebaDDS : MonoBehaviour {
// Use this for initialization
void Start () {
// Create the DDS Domain participant on domain ID 0
DDS.DomainParticipant participant =
DDS.DomainParticipantFactory.get_instance().create_participant(
0,
DDS.DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT,
null, /* Listener */
DDS.StatusMask.STATUS_MASK_NONE);
if (participant == null) {
Console.Error.WriteLine("Unable to create DDS domain participant");
return;
}
}
// Update is called once per frame
void Update () {
}
}
To create a DLL, you will first need a suitable compiler. Not all compilers that produce .NET code are guaranteed to work with Unity, so it may be wise to test the compiler with some available code before doing significant work with it.
Maybe my DLL isn’t compatible with Unity? I really appreciate any help you can provide.
.NET 2.0 should be also good, ok then another question, when you click on the plugin in the Unity is it marked as compatible with “Any Platform” or “Editor” ?
Without a repro it’s really hard to say… maybe you’re simply using API incorrectly, download ilspy.net, drag that assembly on to it, and see what API is available.
It’s also possible the assembly isn’t loading because it depends on other assembly references that aren’t available. Where did this assembly come from?
By the way I’ve updated Unity (to Unity 5.0) and now I get this error:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) at System.Reflection.Assembly.GetTypes () [0x00000] in :0 at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in :0 at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in :0 at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in :0 at Mono.CSharp.Driver.LoadReferences () [0x00000] in :0 at Mono.CSharp.Driver.Compile () [0x00000] in :0 at Mono.CSharp.Driver.Main (System.String[ ] args) [0x00000] in :0
I opened that dll with ILSpy, and there’s no nddsdotnet namespace there, so the error regarding “using nddsdotnet” is a valid one.
Also, it seems, this dll was compiled from C++ with CLR support. I don’t think it’s possible to use it in Unity. In Unity you can only use pure managed dlls.
Hello all another cause of this, may be that the Unity Import Settings for your custom DLL are not configured correctly.This can happen if your Unity Editor platform is set to something not checked in these settings. As an example my dll in was not being fully accessed as I was excluding Win builds.
To check these, simply select your dll in the Unity project and check the inspector tab.
2018 … hit this bug in Unity again … but of course, the folks at Unity have removed the many-years-old workaround/fix “re-sync with monodevelop project”.
Quitting and restarting had the same effect. But I’d rather they hadn’t removed the menu option, since it worked, and is apparently still needed :).