A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or
-
Wednesday, June 21, 2006 6:35 AM
When i add a .dll file as a reference in C# application it shows an error :
A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component.
Willfin David
All Replies
-
Wednesday, June 21, 2006 7:54 AM
I assume you are working with VS2005. So here is the work around for that
Execute "tlbimp <....>.dll"
<Drive>:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>TlbImp.exe <....>.dll
This command creates <...>CORELib.dll and add it as a reference to the project.
Hope this works, Let me know the result..
-
Wednesday, June 21, 2006 9:04 AM
I have compiled as said but it shows the error,
TlbImp : error TI0000 : The input file 'E:\dotnet\Projects\ABClib128\ABClib.dll' is not a valid type library.WIllfin
-
Wednesday, June 21, 2006 9:13 AM
I think you need to build your own Interop dll
check this link
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=272955&SiteID=1
-
Wednesday, June 21, 2006 9:22 AM
I cannot build an other dll file because this .dll file is given by the client as a driver for communicating with the USB port. Any suggestions?
Willfin
-
Wednesday, June 21, 2006 9:45 AM
Try this work around..
For the <..>.dll with a strong name:
First: sn -k mykey1.snk
Second: tlbimp <...>.dll /out: mydll1.dll /keyfile:mykey1.snk -
Wednesday, June 21, 2006 10:02 AM
It shows the same error:
TlbImp : error TI0000 : The input file 'E:\dotnet\DeviceDriverAPI\Devi
ceDriverAPI\ABClib.dll' is not a valid type library.Willfin
-
Wednesday, June 21, 2006 10:04 AM
It shows the same error:
TlbImp : error TI0000 : The input file 'E:\dotnet\DeviceDriverAPI\Devi
ceDriverAPI\ABClib.dll' is not a valid type library.What does this represent "is not a valid type library.".Whether the dll contains code other than CSharp.?
Whether the dll have to be changed?
Willfin
-
Wednesday, June 21, 2006 4:20 PM
hi,
to reference assembly in .net the assembly must have .net metadata format, not like the old assembly, i don't know how to reference the old dll files but once i heard you can do that by p/invoke, as i said i didn't do that b4 so i can't provide more information but you might find this link usefull
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/PInvokeLib.asp
or you can search MSDN for that
http://lab.msdn.microsoft.com/search/Default.aspx?__VIEWSTATE=&query=p%2Finvoke&siteid=0&tab=0
hope this helps
-
Saturday, April 21, 2007 6:48 AM
Hi,
When i add a .dll file(which has been developed in Visual Basic) as a reference in c# application it shows an error:
A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component.
Could u give me a solution. -
Wednesday, May 02, 2007 4:03 AM
Have you tried to register the dll first using regsvr32 <dllName> ? I tried doing that and could use the dll in the .net project.- Proposed As Answer by Sathiyanath Thursday, September 02, 2010 1:48 AM
-
Tuesday, May 29, 2007 6:20 AMTried the above solution..but no luck !!!
-
Tuesday, May 29, 2007 1:18 PM
I have had VS2005, both standard and express edtiions, lock up and stop when I mix C# and VB. By that I mean this. I have a VB project, and want to use a .dl created with C#, and vice-versa. Doesn't happen all the time, but only when I mix the languages through .dll files that contain forms.
Rudedog
-
Tuesday, May 29, 2007 3:04 PMUse P/Invoke instead. I assume you know the functions you need to call in the dll, so create a static nested called NativeMethods (for consistency) and add the external method signatures to it. Mark each extern method with the DllImport(string) attribute:
Code Snippetprivate static class NativeMethods
{
internal const string DllName = "ABClib.dll"; // handy const
[DllImport(DllName)]
internal static extern <returntype> MethodName(parameters...);
//...
}
The dll must either be a registered server or in the same directory as the process image (exe). I suggest you add the dll-file to your project, and set its 'Copy to Output Directory' property to 'Copy always' or 'Copy if newer', that way it's easy to debug your program from VS. -
Friday, November 30, 2007 8:21 PM
I have the same problem. Apparently this problem has been known for over a year and there's still no solution. The DLL is fine -- the problem is with the Microsoft *** we're using for development!
This happens regularly. Just this morning I tried to open an attached bitmap in Microsoft Outlook. It refused, with a cryptic error message. Imagine that: The Microsoft *** wouldn't even open a simple bitmap file! I Googled the error message and found the fix, requiring a change to an obscure Registry entry.
I'm learning Linux.
-
Thursday, February 21, 2008 11:06 PM
Could you point us at the fix you found on Google, please ? I have just found the exact same problem.
Using this DLL is fundamental to the RSS Screensaver C# example on the website. Clearly nobody tested it on a machine with just the DLL. Beggars belief that after so many years of building development tools something as poor as this could stay out there for so long. And they wonder why we aren't rushing to adopt Vista ! How can we, when their own devt tools won't work with it. At least not outside Washington state !
-
Monday, February 25, 2008 7:45 PM
It didn't seem to be asked in the original thread, but what kind of .dll is it? Is it a regular Windows .dll? Is is an ActiveX (COM) .dll, or is it a .Net Assembly?
If it is a standard Windows .dll, then you cannot reference it. You must instead call the .dll using the platform invoke layer. See pinvoke.net for examples of how calls are made.
If it is a COM dll, then it must be registered first and then you can reference it from the COM tab on the Add References Dialog.
If it is a .Net assembly, then you can find it by clicking Browse on the Add Reference dialog.
BTW: This thread was almost 4 months old.
Chris
-
Tuesday, June 10, 2008 6:57 PM
OK, After much searching, and finding no answer I have found a solution!!!!!
This is for C# in VS2005.
Step 1) Add the DLL as a resource. To do this open the project, select the resources tab, select "add existing file" and add the DLL as a resource.
Step 2) Add the name of the DLL as a string resource.
Step 3) Add this code to your main form-load: (In this example my project is called "USBXpress_TestPanel", and the DLL file I'm using is "SiUSBXp.dll").
Code Snippetif (System.IO.File.Exists(USBXpress_TestPanel.Properties.Resources.DLLName + ".DLL") == false)
{
System.IO.StreamWriter OutStream;
System.IO.BinaryWriter BinStream;
// Create the DLL file
OutStream =
new System.IO.StreamWriter(USBXpress_TestPanel.Properties.Resources.DLLName + ".DLL", false);BinStream =
new System.IO.BinaryWriter(OutStream.BaseStream);BinStream.Write(USBXpress_TestPanel.Properties.
Resources.SiUSBXp);BinStream.Close();
}
So the first time your code runs it will detect the missing DLL in it's default directory and create the file. This way the DLL is actually embedded in your exe, so you don't have to mess with the deployment files or anything.
- Proposed As Answer by mkamoski2 Monday, April 16, 2012 2:46 PM
-
Wednesday, June 11, 2008 3:34 PM
Whoat?
I dont think the problem is that the .DLL was not found. The problem really seems to be that the DLL just is not written as a COM object, let alone written in a .Net language.
As stated by several users above => you'll have to make your own calls in the DLL. Do a google on this subject, add searches on : 'interop', 'p/invoke', 'platform invoke', 'marshal', 'DLLImport'. I've been trought this dll-hell aswell... You'll end up with a class looking like:
Code Snippet[DllImport("SharedDLL", EntryPoint="PUBLICPROCEDURE")]
public static extern void PublicProcedure();
[DllImport("SharedDLL", EntryPoint="TAKESLONGRETURNSLONG")]
public static extern CWLong TakesLongReturnsLong(CWLong value);
[DllImport("SharedDLL", EntryPoint="TAKESSTRING")]
public static extern void TakesString([MarshalAs(UnmanagedType.BStr)] string value);
[DllImport("SharedDLL", EntryPoint="TAKESANDRETURNSSTRING")]
[return: MarshalAs(CWBString)]
public static extern string TakesAndReturnsString([MarshalAs(CWBString)] string value);
Then, you can use your local methods in your code...
For example... MyClass.TakesString("Hello World") sends the string "hello world" to the procedure takesstring(string value) in shareddll.dll, wich is located right next to my .exe (or in the windows/system32 folder).
I'm pretty sure that when you got the DLL, there was some kind of documentation about the entry points...
-
Tuesday, August 11, 2009 1:18 AM
Thanks, this helped me!!! was searching for hours how to use this 3rd party API created in older version of VS. It was giving me the same error message... I am using Visual Studios 2008.OK, After much searching, and finding no answer I have found a solution!!!!!
This is for C# in VS2005.
Step 1) Add the DLL as a resource. To do this open the project, select the resources tab, select "add existing file" and add the DLL as a resource.
Step 2) Add the name of the DLL as a string resource.
Step 3) Add this code to your main form-load: (In this example my project is called "USBXpress_TestPanel", and the DLL file I'm using is "SiUSBXp.dll").
Code Snippetif (System.IO. File .Exists(USBXpress_TestPanel.Properties. Resources .DLLName + ".DLL" ) == false )
{
System.IO. StreamWriter OutStream;
System.IO. BinaryWriter BinStream;
// Create the DLL file
OutStream = new System.IO. StreamWriter (USBXpress_TestPanel.Properties. Resources .DLLName + ".DLL" , false );
BinStream = new System.IO. BinaryWriter (OutStream.BaseStream);
BinStream.Write(USBXpress_TestPanel.Properties. Resources .SiUSBXp);
BinStream.Close();
}
So the first time your code runs it will detect the missing DLL in it's default directory and create the file. This way the DLL is actually embedded in your exe, so you don't have to mess with the deployment files or anything.
-
Wednesday, September 22, 2010 10:43 AM
Encountering same problem
(((((A reference to the "vixDiskLib.dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component. )))
...
...
...
I m unable to get success at the specifed solution written above. Plz help me out quickly. I've stuck at this problem since one year.Now itz very very urgent.Plz....................
-
Monday, September 27, 2010 8:38 AMThis worked for me. Many thanks
-
Monday, December 20, 2010 12:07 PM
so good 非常正确,Thank you very much
-
Friday, February 11, 2011 4:09 PM
This solutions worked for me. It seems the dll I was using was built using Visual Basic. That's why registering it with regsvr32 was necessary.
Thanks EarthChild!
-
Wednesday, March 16, 2011 6:00 PM:) Thanks, this did the trick!
-
Monday, October 10, 2011 12:05 PM
it must work, i tried it
you have to install the dll using the regsvr32
-
Monday, April 16, 2012 2:56 PM
Dear Mattster --
Your answer is GREAT and it really worked for me.
I did change (hopefully improve) it a little bit by employing a "using" block, etc, as noted below...
string myDllFileName = MyProject.Properties.Resources.DLLName.Trim() + ".dll"; if (!System.IO.File.Exists(myDllFileName)) { using (System.IO.StreamWriter myOutStream = new System.IO.StreamWriter(myDllFileName, append: false)) { System.IO.BinaryWriter myBinStream = new System.IO.BinaryWriter(myOutStream.BaseStream); myBinStream.Write(MyProject.Properties.Resources.p4bridge); } }
Thanks.
-- Mark Kamoski
- Edited by mkamoski2 Monday, April 16, 2012 2:57 PM Switch to use named-parameter.
- Edited by mkamoski2 Monday, April 16, 2012 5:26 PM Note that closing the FileStream closes the StreamWriter implicitly.
- Edited by mkamoski2 Monday, April 16, 2012 5:44 PM Updated code to be more concise and simple.
- Proposed As Answer by anilkumar thumma Wednesday, October 10, 2012 7:22 AM
-
Monday, May 07, 2012 10:37 AM
This worked for me. Thank you very much!I assume you are working with VS2005. So here is the work around for that
Execute "tlbimp <....>.dll"
<Drive>:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin>TlbImp.exe <....>.dll
This command creates <...>CORELib.dll and add it as a reference to the project.
Hope this works, Let me know the result..
-
Friday, August 31, 2012 2:14 AM
Dear mkamoski2:
I can't seem to get this to work for VS2010. It seems like the file exists but then in a following step, the program can't find the dll. I'm also using the dll from SiLabs. I have added the dll and SLUSBXpressDLL.cs as resources. Here's my code snippet:
string myDllFileName = HIPPY.Properties.Resources.SiUSBXp + ".dll";
MessageBox.Show("starting System.IO.File.Exists");
if (System.IO.File.Exists(myDllFileName) == false)
{
using (System.IO.StreamWriter myOutStream = new System.IO.StreamWriter(myDllFileName, append: false))
{
System.IO.BinaryWriter myBinStream = new System.IO.BinaryWriter(myOutStream.BaseStream);
myBinStream.Write(HIPPY.Properties.Resources.SiUSBXp);
}
}
else
MessageBox.Show("System.IO.File.Exists(myDllFileName)");
MessageBox.Show("starting SLUSBXpressDLL.SI_GetNumDevices");
SLUSBXpressDLL.Status = SLUSBXpressDLL.SI_GetNumDevices(ref DevNum);
MessageBox.Show("DevNum = " , DevNum.ToString());
Any ideas?
Thanks,
John

