VB 2008 <The system cannot find the reference specified> - vb.net

I've created a class library in Visual Studio 2008, and when I try to add the dll as a reference, I get the message in the title for the Path field in my project references. I've been going for a week trying to figure out this issue, and I haven't been able to come up with anything. The strange thing is I can add the same reference to a Visual Studio 2010 project, and it works perfectly fine.
I used VS 2008 to build it because the dll isn't used in house and needs to be compatible with .Net 3.5. Any ideas?
EDIT: I also found out that referencing the dll in a c# project works fine as well. It's only Visual Basic that's causing me problems.

Resolution
Using DependencyWalker, I was able to find out that some obscure dll was indirectly being
referenced (IEShims.dll) but couldn't be found. After a little more trial and error, I found my project had a specified reference path (Project Properties -> References -> Reference Paths) that pointed to the project's DEBUG directory. I had to remove that reference path, which then resolved the above issue.

Related

Adding a reference to a DLL, while keeping it a native DLL instead of an ActiveX Control

I'm forced to use a third-party COM component in an application, and I'm having issues adding the reference to my project.
I've added this DLL as a reference to a project before, but in the past it would link directly to the DLL, such that the "Path" in the reference's properties would be filesystem path where the DLL was installed (i.e. not relative to my solution's directory). However, now, when I add the reference, the "Path" is to my project's obj directory, "Embed Interop Types" is set to True, and it's listed as an ActiveX component (which is not correct).
Then, I stumbled upon this MSDN article, which says:
If you want to add a reference to a registered COM DLL that contains an internal manifest, unregister the DLL first. Otherwise, Visual Studio adds the assembly reference as an ActiveX Control instead of as a native DLL.
Well, there you have it. That's my exact problem. I need the native DLL, but I'm getting an ActiveX Control instead. So, I did as it suggested and unregistered the DLL. However, when I then try to add the reference, I get an error saying:
A reference to ... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
If I register the DLL again, I'm able to add it as a reference, but again, it's added as an ActiveX control. At this point, I don't know what else to do. Microsoft is very clear that I must unregister it before adding it as a reference, but then Visual Studio 2013 apparently won't let me add an unregistered DLL. Any one have any idea how to work around this?
UPDATE
So, apparently a recent update to this app made COM the only option (no directly using the DLL). The fact that it was added as ActiveX didn't mean anything. The problem turned out to be that this was a 32-bit library trying to run in 64-bits. I knew that was a potential problem, but switching the platform target to x86, still resulted in an error so I ended up chasing a red herring. Turns out IIS Express 8 runs natively as 64-bits even if the platform target of the site you're debugging is 32-bit. I had to go into Visual Studio options and uncheck the flag that tells IIS Express to run 64-bit (under "Web Projects") and then everything ran fine.
So, since adding the registered DLL was pretty much a no-go, I focused instead on trying to figure out why Visual Studio wouldn't let me add it when it was unregistered. I mean, sure, I might get an error about it being an unregistered DLL once I tried to run the project, but it should at least let me add it as a reference, regardless.
I eventually stumbled upon tlbimp.exe, which according to Microsoft:
The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types defined within the original type library.
Okay. Well anyways, I opened a Visual Studio Developer Prompt (regular cmd doesn't have tlbimp.exe on the path), and ran my DLL through it. It created a new DLL, which I was able to add as a reference, and it satisfied my project dependencies. However, I haven't tested it just yet to make sure everything still works as it should once this thing is running, so I'll update with what I find there.
UPDATE
Yeah, so this doesn't work either. I get the same error once it's running saying that the class is not registered. Only now, I can't register this DLL because tlbimp.exe removes the entry-point.

ResourceManager is not declared. It may be inaccessible due to its protection level issue

I have a question about importing a National Instruments (NI) library to my Visual Studio 2012 project. (Using Visual Basic .NET, Windows 7 and Visual Studio 2012)
I currently test the FindReources(NI-VISA) example project to apply some of the functions to my project.
The sample project was working fine, and it was returnning resource data corrent.
However, when I tried to apply Find Resource function to "My project" an error message kept appearing such as "ResourceManager is not declared. It may be inaccessible due to its protection level"
What I did was...
First, I added a reference to my project
Second, I imported "Imports NationalInstruments.VisaNS" to my Visual Basic file
However, the error keep appearing, so I can't use function.
And, when I restart Visual Studio and check the Object Browser, there is a NI-VISA reference and the error is gone.
However, when I run the project, NI.VisaNS library just disappear...
I am not really sure why this happens, because the sample project from NI is working without any trouble.
Is there a missing step to import and use the NI library?
I just found a solution.
The functions which I wanted to use was only working for .NET 4.5. However, my system was using .NET 4.0.
After I switched to .NET 4.5 for my project, it worked fine.
Try to find that file/resource in Solution Explorer. It should be there somewhere in the tree. If it has a blank icon next to it, that means that the file is not included in the project. Click the right mouse button over the file and add it.

Visual Studio won't find references

I'm working with some application handed over by another person in which I must document the requirements, build and deploy processes.
The problem here is that Visual Studio (2005) is throwing a lot of errors since it can't find the references for the dlls.
This obviously won't let VS build the project.
Everything works fine on the persons computer but not on mine, even though the project references the same folder where the dlls are, the bin folder.
How can I circumvent these problems and get VS to properly reference the dlls?
The following printscreen shows the references screen for the project.
My guess is that your DLL uses a more recent .NET framework than your application does.
Check the properties for your DLL source (right-click on the DLL code in the solution explorer and choose Properties). Go to Application - Target .NET framework and compare the version to the one the application itself uses (right-click on the project code). Note: under your application properties check both the settings under Application - Target .NET framework AND under Publish - Prerequisites.
For what it's worth, even after changing the .vbproj file and removing many lines about hard coded values,
I eventually checked out the project again removed all references to the given DLL and then added it using the GUI.
Lesson learned, don't try to change out one DLL for a newer version without using VB2005 GUI.
The easiest solution will probably be to transfer everything to another project. It will be incredibly time consuming to find where visual studio has left the hard coded path at.
WOOT!!!! Compile the DLL file to a lower version of the .NET framework, and it will fix the problem!!!!
The paths in the project file cannot be the same or the assemblies referenced have a different version.
It might be worth unloading your project and the editing it to inspect where it's looking and for what version.
I had the same problem with an older Visual Studio Project that I opened in Visual Studio 2008. I tried to add new references to the project and got permanent errors that the dll's cannot be found. After the migration of the Project to Visual Studio 2010 I got the following error message when I tried to add a new reference:
'mySample.dll' or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change ...
After changing the projects .NET Framework to a newer version everything works fine.
Good suggestions in other answers. In my case, it was because the libraries weren't copied (downloaded) successfully: the files existed, but were 0 kB.
Did a clean, which removed all the DLL's and then VS2008 complained it couldn't find the references (Duh!!!) and wouldn't rebuild....luckily I had and old version of the dll's and replaced them in the directory AND THEN did a rebuild to replace them...all references are now OK and we're back to normal....good old VS 2008

Custom modules: Namspace-troubles after converting to Visual Studio 2012

I have several custom modules in separated projects (class libraries), not directly in the website-project itself. My predecessor used to work with Visual Studio 2008 in order to edit the modules.
Now, after migrating the project to Visual Studio 2012, I've got strange errors telling me about required references to the DotNetNuke - Assembly. This assemblies reside in the bin-folder of the correspondenting project, nothing has changed there since the migration:
The references seem to be okay:
I can hit F12 on e.g. TabController (which resides in DotNetNuke.Entities.Tabs), this would open the object browser as expected. I can't see what's wrong here. When I compile, the error-list is full of Reference required to assembly 'DotNetNuke, Version=5.0.0.799, Culture=neutral, PublicKeyToken=null' containing the type 'DotNetNuke.Entities.Tabs.TabInfo'. or similar.
I remember vaguely that there was "DotNetNuke Project Templates" installed in the old Visual Studio 2008. Could that be an issue, too?

Project 'MyProject' requires a reference to version '14.0.0.0' of assembly 'Microsoft.Office.Interop.Excel'

I have Visual Studio 2010 and a VB Project that had a reference to Microsoft.Interop.Excel 12.0. Well recently I changed the reference version to 14.0. That was actually a mistake and now I need to bump it back down to version 12.0. However I get this error in my project now...
Project 'MyProject' requires a reference to version '14.0.0.0' of assembly 'Microsoft.Office.Interop.Excel', but references version '12.0.0.0'
of assembly 'Microsoft.Office.Interop.Excel'.
I tried removing references and adding the com object to, but no avail. Does anyone have clue?
The issue was resolved after I finally realized there was a .dll in my Solution that had a reference to the Interop.Excel 14.0.0.0.