I have a problem with k8061.dll library in VB project. I’m running Windows 7 (x86) and Visual Studio 2008. When I am trying to add reference to that library, there is this error message:
A reference to ‘{every-path-I-have-tried-to-move-dll-in}\K8061.dll’ could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
I have tried to add dll in my system32 folder, in bin folder in project folder and more other places…
I have also tried to add this file as an existing item and no error appeared, but still the functions of that library appears undeclared…
In code I am writing the lines similar to DEMO downloaded from Velleman site, such as:
Private Declare Function OpenDevice Lib "k8061.dll" () As Integer
When I want to use OpenDevice function VS warns me that declaration of this function is expected…
Where could be the problem, please, and how to solve it?
Thank you for your answer and help…
EDIT: I have also tried to create new project in .NET 2.0, 3.0 and 3.5 Framework…
You may try putting the DLL in the folder:
\bin\x86\Debug
or put it to Windows folder.
The compiler doesn’t seem to find it from the Windows\System32 folder.
If you get then error message:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Well, this doesn’t work either…
Directories where now I have K8061.dll: /Windows, /Windows/system, /Windows/System32, {project-folder}/My Project, {project-folder}/bin, /bin, /bin/Debug, /bin/x86/Debug, or just in {project-folder}…I think it’s not a problem of placing library somewhere, I just need to connect the library somehow with the new project.
It’s not possible to use “Project->Add reference” tool, because it writes that error above.
I have tried also to add library as “Project->Add existing file” - this operation is successful, but still it doesn’t work.
I have even tried to add dll as string resource in Project properties…
The compiler always writes me “Declaration expected” error, when I use any function from the library even if I declared it as shown above and in DEMO…
There must be some kind of magic 'cause DEMO project is working - it is written in an older version of Visual Basic and is already linked(I suppose), so my VS2008 converts it to new version and the compilation is OK…but in the new project it is impossible to add this dll…Of course I can build my project based on that DEMO, but it’s not the solution I want and in my view it’s bad solution…
Now I have another new information for you - it doesn’t work either on Windows XP SP3 and Windows Vista Business x64…errors are the same…
Perhaps I am badly configuring my new project…could you please say to me how to create a new clear project (for example Windows Forms Application template) and how to connect this k8061.dll to it?
So, I have reinstall Visual Studio and suddently it’s working. Than it seems you were right about location of dll library, perhaps VS was not able to detect new added library…I don’t know.
Thank you very much for helping me problem is solved and now I am going to look where the library really have to be and remove all her copies
Nice that you got it working
Indeed there were strange problems.
Meanwhile I created a new very simple K8061 project in VB2008 Express under Windows 7 x64.
I got it running. The K8061.DLL was placed to Windows folder.
Seems to work also if the DLL is put to folder \bin\x86\Debug.
From what I can tell you were trying to add the DLL to your project with Project->Add Reference as if it were a .NET Assembly (which also has the .dll extension). This is not possible since it isn’t a .NET Assembly file, it’s a regular Dynamic Link Library (DLL). It’s also not a COM component.
So just putting the dll in one of the search paths (%WINDIR%System32, …) is ok, you don’t have to add anything special to your project.