I've downloaded and compiled Amazon's .NET SDK for Mechanical Turk, producing two DLLs: Amazon.WebServices.MechanicalTurk.dll and Amazon.WebServices.MechanicalTurk.Domain.dll .
I then created a new WPF project and added the two DLLs as references. When I create objects from their space, Intellisense has no trouble browsing the assemblies- I can see the classes inside.
When I compile, however, I get an "type not found" error from the compiler. Intellisense no longer works for the Amazon namespace, and the DLLs have vanished from the Object Browser window inside Visual Studio, though they're still listed as references in Solution Explorer.
What's going on? I think I'm missing something obvious. I can see, for example, MTConfig, but when I try to instantiate it, it fails and I need to re-add the DLLs to try again.
Thanks!
How have you added the references? Did you copy the DLLs into your new project's output folder and add references to them there? I can imagine that giving the behaviour you describe, if VS wipes the output folder before a build. If that's what's happening, simply move the DLLs to a different directory (I typically create a "lib" directory) and point the reference there.
What I did to solve this same problem was to recompile the DLLs changing the .NET version from 2.0 to 4.0 in the project properties. Not sure why that works, but in my case it solved the issue.
Related
I'm working on a C# project that is nearing release. As part of this, I have started building the project and testing it on another machine. This has revealed some odd problems. My biggest concern, though, is that my project is failing to run. I can do some basic things, but when I try to use my projects primary functionality it crashes. Using Visual Studio, I was able to determine the exception that was causing the crash.
Essentially, I'm getting a FileNotFoundException on the dll that contains most of my project's functional code. I'm not sure if I've made an error in adding the dll to my project, or if there's a problem in one of the files in the dll.
The dll was added as a reference using the Project -> Add Reerences feature of the user interface.
The dll contains three files which contain absolute file paths (these are for #import statements). Example follows.
#import "C:\Users\Me\Documents\Projects\MyProject\Delegates\bin\MyDelegate.tlb" raw_interfaces_only
My hang up is I'm not exactly sure what I'm doing wrong here. I suspect that those import statements are causing problems, but I'm not exactly sure how to fix them if they in fact are the problem. This is my first c#/c++ project so any help would be appreciated.
Adding the dll as a reference DOES NOT include the dll with your project--you are simply telling your project to use the library for your code. The dll will need to be installed on all computers that run your application, for your application to use the dll.
If the dll also uses three files (as you specified), then those files must also be included, and be installed in the expected path.
Presuming you have redistribution rights on the dll you mention, you can include the dll in your project. Be sure to set the "copy" property as "copy always" or "copy if newer" and change the reference to use the copy that ends up in you bin folder. Then you only need to be sure to include that dll and install it in the same folder as your application.
Strange situation.
inside a solution I have several projects. One of them is called Common, other is a web project (not a web application) called Internal.
Internal has a reference to Common, so every time I build the application, the common DLL is copied to the bin folder on the Internal website.
If I change a line of code on a class on the Common project and rebuilt it the DLL isn't updated on the Internal bin folder (even If I rebuild the internal) resulting in running the OLD code of the Common (If I have a breakpoint on Common, it show a warning saying that the code differs from the original and wont run). The only way I manage to solve it is manually deleting the Common DLL on Internal and then rebuilding.
My question is, how can I avoid it? How can the dll always be the same version on Internal?
Thanks
As requested by OP:
Try removing the reference and adding again though the 'Projects' option on the 'Add Reference' dialog. This should set up the DLL to be refreshed when it is rebuilt.
One of possible straightforward solutions could be the simple use of PostBuildEvent where you put batch-code that on successful build always copies files you need.
The bad about this that you increase your compilation time.
If you are using third party dll which has been developed been higher version VS2013/vs2015 (i.e .NEt 4.5 , 4.6 , 4.6.2) then it will not work properly in VS2010
Answer: Convert your project to VS2015 to resolve issue or install .NET 4.6.2 and user VS2013 and change framework to latest
I've got a project (project A)in vs2010 (c#) that I want to reference another project (.exe) (project B) that I created. Project A is a quick, down & dirty util that I will only use once but I need all the function calls and db calls from project B, so rather than cut, copy, pasting from one to another, I thought I could just reference project B in my references. I am able to point to the .exe and in code i can use it, but when I compile it, it complains about not being able to see it (the infamous "are you missing a using directive or assembly reference?" error).
Does anyone know how I can do this?
Most probably, also it's hard to say, you have .NET Framework version conflict. One of your projects has .NET Framework version which is not compatible with other.
Check in project properties of both of them the version of the framework.
Make them the same
Recompile both of them
and most probably the trouble will gone.
Hope this helps.
Make sure the namespace of classes you want to use from project A is included in the files in your project B in a using directive:
using projA.ExampleNamespace;
I have the same problem. When I first added the reference all worked fine. But some time later after a rebuild there were errors and the classes and namespaces of "project A" were not longer recognized. Removing and re-adding the reference solved the problem immediately (without rebuiling or anything). There were no errors in other code and all DLLs and EXEs were build correctly. Build Order and Build Dependency settings were also correct. Seems to be a strange bug in Visual Studio (I use 2013 Professional).
I also checked how the reference was set in csproj file. The csproj file didn't change at all after removing and re-adding the reference. Neither did the sln file.
Maybe it's some strange caching behavior. But as I used "Rebuild All" which cleans up temporary files imho, this shouldn't happen. Even restarting VS or the PC didn't help.
When I add a reference to my dll in Visual Studio project, I am able to use it, but when I compile my code or try to run it, I get an are you missing a using directive or an assembly reference?_ Error. I am able to confirm that I have the right using statement for my namespace and I am able to confirm that the dll is correctly loaded.
Anyone have any idea what I may not have right in this?
Go to project settings and make sure that you are not compiling the project for a .net version that includes the text "client profile".
I had just had an issue precisely like this, even if this is an old question thought I would add my 2c on what fixed it as none of the other answers helped:
For whatever reason, when I built the solution top to bottom a certain dll was not getting updated and output that held changed code. So while my solution had no visible errors, when you attempted to build, it was still referencing the old dll and started complaining.
It was simply a case of directly re-building the offending project and after that it picked up the latest dll and built happily.
This seemed to be a freak accident as no configuration had changed between when it worked / when it didn't.
Sometimes, JUST REBUILD THE SOLUTION.
The location of the DLL is important.
If you add a reference on your local machine to a DLL that is outside of your Visual Studio solution, it isn't necessarily copied into your solution files (depends on the type of solution/project).
If this is your problem, then you need to either put the DLL in the same path on the other machine, or copy it into your solution so it gets deployed along with the solution files, and change the reference.
You can also handle this with build instructions, but that might be beyond your aspirations at the moment.
Most likely your dll is referencing another dll that the client project is not referencing and your dll code is exposing a type or an interface from the 3rd dll to the client code.
If you post the exaCt message, we'll be able to help better.
Are you using .net 4.0?
If yes, this dll is probably not compatible with .net 4.0
In my case, the main project (WinForm) was configured Framework Target: FW 4.0 "client profile". I change to FW 4.0 and work perfect!!.
At first time i was looking in the referenced projects and they were ok, but de main project doesn't. I hope this help. Thank you.
In my case this compilation error has gone after adding the reference to Microsoft BCL Build Components via "Manage NuGet packages" context menu on problem project.
Before: I had project Main (console application) referencing project A (class library).
Project A had dependency on Microsoft BCL Build Components.
After: I started refactoring where I picked out several classes to the separate project New. It also depended on A. But the compilation error occurred on project New as if there was no reference New -> A (although Visual Studio didn't highlight allegedly not found interfaces and classes listed in the error list of compilation).
So I checked project A's dependencies and found there Microsoft BCL Build Components.
After adding it to New's dependencies everything worked fine.
The most interesting thing is that Main did not contain this dependency and it didn't need it.
Hope this helps.
You just Have to check your namespace of that class file again...it will work
I've got a C# project in visual studio that is building a DLL, and another console project which includes the first as a reference. These are both in the same solution.
The trouble is when I add methods to the DLL, then rebuild the console project doesn't seem to pick them up.
For example, in the DLL I have a class Converters. If I add a method
public static void test() {}
it just doesnt' show up in the console app at all. Intellisense doesn't autocomplete it, and if I manually type it in it gives a compiler error.
If I go in and delete the dll files then rebuild that works (or better yet, delete the bin and obj directories) but that seems rather drastic.
I'm sure this is a basic error, but I can't seem to find the solution after some googling.
How are you adding the reference? As a project reference or by browsing to the DLL? If you're using the latter then it will copy it locally to the bin directory of your console app and won't refresh it unless you manually delete it. If you add it as a project reference it will copy it as and when it needs to.
The exact thing happened to me once on a project - it turned out the build command wasn't configured to build these DLLs.
Check Build - Configuration Manager, and make sure the project is checked:
(Image from msdb - Setting the Build Configuration)
close Project visualStudio and
rebuild again your dll (other project visualStudio)
One of the things to note is the Target Framework of the Projects, if you compile your Project A with target framework different then that of Project B and it is referencing the dlls of Project A you may run into this kind of trouble. So, make sure that the target framework for both Projects is same.
Check that you don't have the ddl inside the bin folder of your project. Whilst I was adding the reference by browsing for the dll, I had forgotten that I manually copy pasted a version into that folder. No matter how many times I cleaned and rebuilt, it didn't seem to update.
Deleting that dll and re-referencing fixed the issue.
Change the reference to the dll to the Project, instead of the output.
This is certainly unexpected behavior. It sounds like the reference between the two projects is broken in some way. Two issues come to mind.
Possible problem with the reference. Try deleting the reference in solution explorer and readding the reference and seeing if that fixes things. When you re-add make sure it's a project reference and not a file reference.
It's possible that the time stamps on the files in your project are off. See if they are in the future.
check the folder which contains the reference. does it contain a refresh file with a relative path in it? if so, and if assembly names in the location pointed to by the relative path are common with those in of (project) references which should auto update, then these references no longer auto update! what you end up is a static reference to the assemblies present in the relative path contained in the refresh file.
you may also have to delete the projectreferences key in the sln file and add references afresh
I hate to beat a dead SO question but 8 years after the original question and none of the above solving the issue for me, my problem was in VS2013, but to solve it I simply removed and re-added the reference to the DLL in the project that invokes it.
I hope this helps some people in the newer VS realm having the same issue.