I've got a couple of classes that use the AxWMPLib.MediaPlayer control, and I've just migrated all of my classes into a single library ( from a couple of windows forms projects ).
The problem I am having is that even after exposing references to the MediaPlayer COM Object, I am still getting 'missing assembly' errors for this namespace.
I wonder if there is anything that must be specifically done in a 'Class Library' project to include these references, or if I am just totally overlooking something obvious...
Suggestions for my seeming incompetence would be much appreciated...
Imported the DLLs directly from my original project ( which had been copied to the output directory in my original build ).
Related
In a specific project (meant for web-services) in my .net solution (Visual Studio), I have added a using directive:
using ourSystem.Common.WPF
and I also added the corresponding reference (pointing to the DLL) to the project file.
The web-services project compiles, builds, and works just fine until I try to add the WPF project.
When I add the WPF project, I get the error message:
Error CS0234 The type or namespace name 'WPF' does not exist in the namespace 'ourSystem.Common' (are you missing an assembly reference?)
I have looked at similar questions on stack overflow and web posts elsewhere, but nothing seems to work.
It appears that the problem must be some sort of incompatibility between files.
NOTE: The Visual Studio Solution (VS2019) I am working on has several projects, and this DLL/namespace works in many of the other projects, just not the project that I am trying to add it to.
Both the WPF project and the project I am trying to reference it in are v4.5.2
Thus, at least for that attribute, they should be compatible.
For what it's worth, I have also tried unloading projects, and reloading them. This often changes the error count from about 4 (all the same message) to well over 100, and it seems to lose all references to everything.
Edit added: It turns out the relative structure of the many projects within the solution (which I didn't describe in the original post of this question) was key in finding an answer. See my own answer below for details, if interested.
Any suggestions on how to fix this problem?
I was able to fix it essentially as follows:
I refactored the directory structure.
It had been
A-> Top Level GUI project that had called B & C
B-> Folder with the projects used by A including WPF, but not Web Service Project.
C-> Folder with Web Service Project
I then moved all of C to the same layer as B.
Having them in the same folder seemed to 'placate' the compiler.
I am not claiming that this was absolutely needed, nor that it should always be done, however it worked in my case.
I had to also redo some code within the C project to account for different layering within C's own folders (especially packages folder), as it still had legacy code as if it were the top-level project. The following link was useful in that: (especially the answer by Nikita R.)
How to fix re-layering problem
I've got a really strange error occurring in my solution one of my projects which is a class library is causing a project it is referenced in to throw a TypeLoadException. I've looked through various answers on SO and the closest to my issue is;
TypeLoadException was unhandled in C# [closed]
This answer led me to question if this was my issue, doing some digging in the debug folders I found that my project that was referencing my class library is generating a DLL and EXE with the same name, could this be my problem?
If so how do I fix this?, I have other class libraries in my solution that are also referenced in this project they are not generating both DLL and EXE files.
I don't believe it but I've actually found the cause via a colleague, hopefully this will help others who encounter this (nice one Adam).
The reason was my project referencing my class library had the same assembly name, I had been doing some re-jigging of my namespaces and hadn't noticed that my main project had the same name, this meant that when my code was built the compiler created a EXE for my main project and a DLL for my class library this in turn forced the TypeLoadException because the compiler had already loaded the EXE with the same name.
My code is now working. Thanks to all who took the time to post.
my class library is generating a DLL and EXE with the same name
Yes, that causes this problem. You can easily see it by running Fuslogvw.exe and logging all bindings. It is a somewhat odd quirk of Fusion, but when it looks for an assembly then it only looks at the filename and ignores the extension. It will accept both a .dll and a .exe as an acceptable match for the assembly it is looking for. Which is otherwise somewhat logical, there is no true difference between DLLs and EXEs when they contain managed code. Referencing an EXE is for example entirely supported.
There's no way to force the loader to do this differently. The workaround should otherwise be simple, just be sure to generate a distinct assembly names.
Under Project -> (YourProjectName) Properties -> Application, make sure that "Output Type" is set to "Class Library".
In C#, I made a ClassLibrary that has one Namespace and one Class.
I saved it and build it.
in other Projects, when i use it, I add it to my references by browsing to the .dll location.
But The Problem is that its name is not showing up in the Intellisense.
i.e when I: using ... my dll doesn't show ..
I'm Importing the library to a ConsoleApp.
both of the App and the library target Framework is .NET Framework 4.0
and I made their Assembly Version 4.0.0.0 so they're the exact same.
is there a setting or something that I'm missing ?
how can i make it pop up ?
I'm using VS2010 Professional
Thank you for your help
Maybe this be usefull, I was having a similar issue, I have a Web project, add the reference to a Class Library by selecting the project, but if I made a change on the class library, I canĀ“t see that change on the intellisense of the Web Project, after try many things, I see that in the recently added reference, the value of the option "Local Copy" was set "True", then I change it to false and everething works!
I had a similar issue but in my case it was a property on the class. If you go to the file properties and look for a Build Action. Somehow mine was set to Content it had to be set to Compile.
I am using Visual Studio 2013. I hope this helps someone else.
Is the namespace for your assembly different than the namespace for your currently open project? I've had times when the current project and an assembly share the same namespace path the intellisense can mess up.
In general, Visual Studio is pretty good about intellisense generation, especially for C#. But sometimes there are some interesting conditions regarding ambiguities, and especially mixing project types where it just doesn't quite work.
Placing your content in the same namespace makes me wonder if you've actually fixed the problem (it may just be autocompleting the namespace in the currently loaded project rather than the assembly), but if it allows you to continue working, then go with it!
Right click on project on which you add reference of your dll/project select menu project dependancies and select/MarkCheckBox for reference project/dll. then it will work fine.
If the class library project had its name changed after creation, then intellisense may fail finding it due to directory issues, I believe.
I created my class with the generic "ClassLibrary1" or whatever, and then later changed the default namespace, class name, and project name inside of VS2017. I closed VS2017 and changed the directory name to match my default namespace, and then re-associated the project file in VS2017, and then re-added the reference in my main project file.
All seems to be fixed now.
After I build a few of my references, which are present in the project and accessible through intellisense before the build is performed.
Unfortunately none of my projects are set to target Client Profile, as answered in this thread.
The type or namespace name could not be found
This seems to be the most common cause, does anyone know what else other than this can cause the same issue?
Edit:
The Types that aren't found are all from the referenced DLLs. I have the correct using directives for these and they are present in the resource folder, however they become underlined red after a build (I did try cleaning to).
My initial thought was the framework (the project is on v3.5), but I checked all my resources working or otherwise all where on v2 bar a few (working ones) on v4 which I removed temporarily to make sure we're causing issues.
Unable to access the project from my current location but will post any requested specifics as soon as I can.
edit:
Resolved the issue by deleting all of the custom class libraries... found and rebuilt each of their projects then added the new DLLs back into the project. Stored libraries weren't very organised, so I probably have some confliction between old/new versions.
Have you read the warning in the error list? You might need to install nuget package used by the referenced projects
for me the error warning was
All projects referencing "project file" must install nuget package Microsoft.Bcl.Build.
Are the projects being built correctly ?
Sometimes, you need to manually generate them (right click on them, generate), before being able to run a full build.
I dont exactly know why, but this might be the way to go for you.
~A few simple things to try before getting into more complicated water...
Try clicking:
Build->Clean Solution
Build->Build Solution
If this doesn't work, check your using statements are all there and correct, check your references all still exist.
I had a similar issue today, and I thought I would mention it here in case it helps someone else out. In my case, I have a VB.net Class Library which is referenced by a C# class library. The solution would build fine, but in the IDE, as soon as I started editing a file in the C# project, I would get errors about not finding a reference to the VB.Net library. It turns out that the VB.Net class library had a reference to System.web (lowercase w). I'm not sure how that came about -- but the solution was to delete that reference and replace it with a reference to System.Web (uppercase W).
Make sure all the projects in your solution have the same "Target framework" value
I have an F# application that references a C# assembly (in this case as a project in the same solution) in order to use an existing C# code base. The problem is that every now and then, the F# project seems to go fubar and not recognize the referenced C# assembly, giving me a "The namespace or module 'HCGInterfaces' is not defined". The C# Assembly compiles just fine. I have rebuilt/cleaned the solution, deleted the dlls, removed and re-added the reference and nothing seems to work. The only way that I can get the application up and running again is to delete the F# project and re-add all the F# files. Any idea why this happens and how to stop it from happening? Rebuilding a project from scratch each time is not a really fun option.
Thanks for your help!
[Update] I was able to get my project working again (although I don't know how or why), but now it won't recognize another C# library that I have referenced. In this case, it will not recognize any classes in it, only the interfaces that are part of the library. Very strange. I haven't been able to find anything about this issue, but I'm getting really frustrated with F# (or at least Visual Studio) at this moment!