Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I use .DLL as refrence in web project it is OK, when I use the same .dll file as a refrence in windows project this error happened when I use using myDLLFile;

The type or namespace name "myDLLFile.dll" could not be found (are you missing a using directive or an assembly reference?) D:\VS2010\SAP_GUI_DT\SAP_GUI_DT\Plant.cs
Posted
Comments
Manfred Rudolf Bihy 2-Jan-11 6:07am    
Did you try what I asked of you yet?

Check whether this DLL is compatible with windows forms (and also if the .Net framework version is compatible).
 
Share this answer
 
Comments
Hassan Abde El-Naeim 2-Jan-11 4:34am    
how to check .Net framework version is compatible ?
Hassan Abde El-Naeim 2-Jan-11 4:35am    
how to check .Net framework version is compatible
Manfred Rudolf Bihy 2-Jan-11 6:08am    
@HNaeim: Why was this marked as the "accepted answer"?
Hassan Abde El-Naeim 2-Jan-11 8:56am    
I tried but not solved
Manfred Rudolf Bihy 2-Jan-11 12:06pm    
@HNaeim: So why are you answering him and not to me, if your tried what I told you?
You said use "using myDLLFile;". That is most probably not correct. The using statement needs a name space that is defined in your DLL. To confirm that myDLLFile is the correct name space look into your WinForm solution. If your WinForm solution (that works as you said) also uses
...
using myDLLFile;
...

then your "using" statement is OK, BUT you still need to add a reference to that DLL under "References" in the solution view.

Best Regards,

Manfred
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Jan-11 17:24pm    
Good point about using MyDLLFile - my 5 again.

Actually, paying attention for the name space should come first. If you use right name in source code but there is no right reference, VS will say "... did you forget to add reference..." or (in case of Framework reference) even say "you should reference ...". Very convenient.

Also, please see my comment on your comment on "benefit #2" -- I think it explains everything to remove the controversy.
The answers you already have so far are good enough, but let's ask: is myDLLFile.dll your own (or if you have a source code for it) or this is a 3-rd party with no accessible source code?

This makes great difference. If you have a source code, include it in the same solution and use "Project reference" instead of reference to executable. (Go to project's Solution Explorer -> Reference -> Add Reference -> the tab Projects.) I will give you great benefits over executable reference (Add Reference -> the tab Browse).

Benefit #1: Solution's project dependencies are set up automatically;
Benefit #2: you will greatly appreciate it if you upgrade your myDLLFile.dll: incremented version information will not force you to re-set this reference (it will for executable reference).
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 2-Jan-11 16:37pm    
I must object to the Benefit #2. Changes made to project for myDLLFile can have adversary effects. Especially when myDLLFile is used for many different projects that can have changing requirements to said myDLLFile project. Then you need to setup a solid change management, but that is another story. :)
Anyway, if he has the source code your's is also an option he should consider. Hence my 5!
Sergey Alexandrovich Kryukov 2-Jan-11 17:16pm    
Manfred, thank you for your vote.

Your're not quite right about benefit #2; I can prove it. I did both. You're right about effect of the version, but... look at the project (not myDLLFile.exe but the one referencing it) as a text file, look at that reference. If this is binary reference, it contains the full name: version, signature token (it's very beneficial to use signing in real-life projects as well!). Should you modify any of this in the referenced project => version of signature mismatch => compile-time error -- for a good reason! -- this is one reason versions and signatures are designed for. Now, do the same if both projects are in the same solution linked with project references. Look at this project as a text again -- no extra information this time, only a node name of a project. Why? For a good reason again. VS reasonably assumes you only compile at the level of solution, where there is no ambiguity about version if the referenced assembly. It allows you to modify version/signature at any time ***safely***. I think you got the point.
Manfred Rudolf Bihy 2-Jan-11 17:43pm    
Ok SAKryikov, you've spread it out to why it's good for .NET & VS reasons. My argument still holds though, when you are reusing libraries across sveral projects it wont really work without CM that takes different versions of one and the same library into consideration. Maybe we're just looking at this from slightly different angles.
Sergey Alexandrovich Kryukov 2-Jan-11 22:12pm    
I agree with your argument. Now you make a good about two different angles of view. If something is a benefit from one point of view and not (but not worse) from another point of view, overall it's still a benefit. Deal?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900