I am trying to add a DLL as a reference to my project (64bit on VS2010 with the .NET Framework 4). But I am getting the following error:
A reference to 'XXX' could not be added. Please make sure that the file is accessible, and that it is a valid assemlby or COM component
Installing the DLL with RegSvr32 says:
The module was loaded but the entry-point DLLRegisterServer was not found...
Trying installing the DLL with RegAsm says:
error RA0000: "XXX" could'nt be loaded, because it's no valid .NET Assembly.
I have no idea hwat kind of DLL that is, but that it is contained inside a SDK which was written for the .NET Framework and in C#.
Can anyone help me with this?
Thanks a lot!
Sorry for my english:
either the dll is dll building for c# (managed) and you have just to add reference to your project : (right click on reference and select "add reference") -> you have to indicate where is locating your dll. After when you need to access at your Dll, you have to include the namespace.
either is not a dll building for c# you have to load the dll by using loadlibray
either your dll is corrupted..
Related
I have compiled our editor scripts into a single .dll file, and put it in /Assets/Editor directory:
These extended script menus are shown in editor correctly:
But it has this TypeLoadException when I click the menu. The type 'Util' is actually in 'UnityVS.x3dgame.CSharp.csproj' project, which is also a library project.
TypeLoadException: Could not load type 'Util' from assembly 'EditorLibrary'.
Scene2DBundleTool.GenerateSceneEffectLuaEditor ()
I have no idea how to solve this.
Here is some more information:
Solution structure:
EditorLibrary references:
Help wanted.
You get this error because you did not build the dll it properly. If you want to include Unity's API in your own dll, you must add also add Unity reference to the dll so that your dll can use those API.
You must the basic references such as, System, System.Core and System.Xml.
Now, you must add Unity's references to your dll project before build the dll project. The dll reference to add depends on where the Unity API came from.
Standalone API:
UnityEngine.dll - from C:\Program Files\Unity\Editor\Data\Managed
Editor API:
UnityEditor.dll - from C:\Program Files\Unity\Editor\Data\Managed
UI:
UnityEngine.UI.dll - from C:\Program
Files\Unity\Editor\Data\UnityExtensions\Unity\GUISystem
[Editor features]:
UnityEditor.UI.dll - from C:\Program
Files\Unity\Editor\Data\UnityExtensions\Unity\GUISystem\Editor
Finally, make sure to select the proper .NET framework in your dll project before building it. .Net Framework 2.0 should be fine.
Our Unity's path may be different but once you find the root path where it is installed, everything else is the-same.
Note:
When I said, add reference, I meant add reference to the library project you are building not to your Unity project. From Visual Studio, this can be done by going to Projects ---> Add Reference... ---> Browse...(Button) then select the appropriate dll file.
I am trying to reference a dll in my Visual Studio project and I am getting this error:
Please make sure that the file is accessible and that it is a valid assembly or COM component.
I tried using CMD with TlbImp.exe, and I got an error that says "the dll is not valid type library". The dll is written in C++ and I am trying to reference it in C# project.
You can reference the following in a .NET project:
Another .NET assembly of the same framework version, or prior (.exe or .dll)
COM components (.exe or .dll). .NET will have to create a COM wrapper.
For a plain vanilla C linked library (.dll), you have to use the DllImport attribute to declare external functions contained in the file, demonstrated here.
I have an application written in C# which interfaces with some custom hardware using a vendor supplied .Net assembly. The .Net assembly in turn loads another DLL at run time. I can add the vendor supplied assembly to my project but when I run it, the vendor assembly complains that it can't load the required DLL. I can work around this for the moment by copying the DLL to the bin\Debug and bin\Release folder.
The problem is that I will need to distribute this application to clients at some point and they will not have this DLL in place. I can't see how I can make the solution require it; I can't add it as a reference since I get the error "A reference to foo.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
I can't convert the DLL to a .Net assembly using TlbExp, it gives an error "The module was expected to contain an assembly manifest."
I thought if I published the application via "click once" that I could declare the dependency there but I don't see any way for this either. I also tried adding it as a file resource but this didn't seem to help.
I can see other questions on SO relating to how to invoke functionality in an external DLL but in this case, I just need a way to bundle the DLL with the project.
Thanks.
Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL)
The DllImportAttribute attribute provides the information needed to call a function exported from an unmanaged DLL. As a minimum requirement, you must supply the name of the DLL containing the entry point.
For further reference go here
Link to Review
You could add the dll as a resource, write it out as a byte[] to a file on loading, and do an Assembly.Load() at runtime for deployment.
You might have to use an AppDomain.AssemblyResolve Event to make sure the assembly resolves in case of multiple versions.
you could add both (all) of the dlls in your project as references and mark them as "copy local". That should do it unless the first DLL expects the second DLL in a specific place.
System.DllNotFoundException was unhandled Message=Unable to load DLL 'sqlite3': The specified module could not be found.
I already reference the DLL. I check it on Debug folder and it was there. I also search how to "include" it in the project but they don't specifically explain how to do it.
I'm following this example: http://www.codeproject.com/Articles/22165/Using-SQLite-in-your-C-Application
SQLite doesn't have a full .NET implementation, but available libraries are wrappers of a native one.
This means that not only .NET assembly must be referenced but you need to be sure native library is there too when applicacion is executed.
Summary: output folder will have a .NET assembly and a native assembly (C/C++ one) in order to work properly!
The System.Data.SQLite.dll is platform dependent assembly, and you mast add reference to appropriated assembly.
Follow the steps :
1)Add the Dll in debug folder
2)in your code add this
using System.Data.SQLite;
3) Add the reference by going to solution explorer and add it.
4) Check the version in app.config to verify it
I've created a dll using managed C++. Now I'm trying to use it from C#. I've added the Object to project references. Object browser shows the object in the dll correcly, path to the dll in object browser corresponds to the actual path.
However, when I run the C# program it complains:
Unhandled Exception: System.IO.FileNotFoundException: The specified module could
not be found. (Exception from HRESULT: 0x8007007E)
Any idea what else have to be done?
Thanks.
I think that you're missing the other assemblies or dll's references by your managed C++ assembly.
Does your managed C++ assembly have an other dependencies, including unmanaged dlls? You'll see this error at runtime if your referenced assembly fails to load a dependency.
Are you running the application in release on a machine without VS installed?
I only ask because I ran into a similar problem here: Mixed Mode Library and CRT Dependencies - HELP
if you scroll down to my answer you can see what I did that helped me.
Check that the c++ assembly is present in the same folder as your c# program. It should be copied over automatically if the 'Copy Local' property is set to true (on the reference to the c++ dll in your c# app).
If the c++ dll is there, the most likely problem is that the c++ dll depends on another non-managed dll which cannot be found (i.e. c# will not copy these to your app folder because it does not know about unmanaged references). You can use DependencyWalker on the c++ dll to check for missing dependencies.
Another probable couse could be a problem with your MSVC runtime dlls. see if DependencyWalker complains about missing MSVCR*.dll, MSVCP*.dll etc... files.