Click here to Skip to main content
15,883,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I have a dll, this dll is referenced in a project.
I have a second project that needs use some methods from that dll

How can I call those methods only referencing the project that has the dll ?
Posted
Comments
Richard MacCutchan 3-Mar-14 11:28am    
You don't do it that way. You reference the methods in the DLL and link to it in your project.

Add a reference to the DLL directly to your new project: open your project in VS, expand the Project branch in the Solution explorer, then right click "References".
From the context menu, select "Add Reference..." and wait for the dialog - If can take a little while to appear.
You can now either use the "Projects" tab on the left hand side of the dialog or use the Browse key to locate the DLL file. Press "Add" and the "Close" to add your reference.
 
Share this answer
 
Comments
memd24 3-Mar-14 12:09pm    
I know how to add a reference to another project or dll. The problem is that I cannot reference my second project to that dll because my project is web and the dll is c++. I need to call the methods only referencing the project or the dll of the own project
OriginalGriff 3-Mar-14 12:26pm    
Provided it's a C++ .NET DLL it isn't a problem: just put the DLL in your websites Bin folder using "Add Existing Item..." and you can use the assembly directly.
If it's a native DLL, then you will need to use DLLImport for each method you want to use.
It simply makes no sense. Why? (Why?!) If you need to reference only the assembly referencing the DLL (you are not "referencing" DLLs, you reference only assemblies; a DLL is the executable module of the assembly, there could be other modules), you need to reimplement methods in question again, using the referenced assembly. But why bothering?

Anyway, I explained you the way; now you decide.

—SA
 
Share this answer
 
Comments
memd24 13-Mar-14 12:42pm    
You are right, I cannot do that, so I need to solve this using something else
Sergey Alexandrovich Kryukov 13-Mar-14 14:22pm    
Just please tell us why referencing assemblies directly is not suitable; and I'm almost sure I'll be able to put forward some approach. There can be a very different approach, with pluggable assemblies, but it will take more work. Explain the ultimate purposed, to get some advice.
—SA
memd24 13-Mar-14 14:31pm    
Sure, Is because im trying to use a dll(c++/cli) in a silverlight project, but silverlight only works with is own dlls, so Im trying to call that dll from another project.

But maybe im wrong trying to do that
I created a question something more explained
http://www.codeproject.com/Questions/743807/Can-I-use-Silverlight-dll-cplusplus-and-WCF

Thanks :)
Sergey Alexandrovich Kryukov 13-Mar-14 14:37pm    
Thank you for the note. I'll try to think of something...
—SA
Sergey Alexandrovich Kryukov 13-Mar-14 15:32pm    
Please see my answer to that new question, just on the aspects I was able to understand.
—SA

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