Click here to Skip to main content
15,922,650 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI,
I know that is posible to call methods from a dll using dllImport
But, If I need to use the class name for a get and a set like:

C#
private ClassName myClassName;
        public ClassName  m_myClassName
        {
            get { return myClassName; }
            set { myClassName= value; }
        }



How can I call that class?

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 4-Mar-14 11:18am    
It looks like gibberish, especially with your comment to Solution 1. Can you finally explain it all properly?
In particular, show C++ declarations in question.
—SA

1 solution

You don't need DLLImport to access .NET classes - DLLImport is for external resources that are not .NET, but native.

For .NET resources, just add a reference to the assembly in your project, add the appropriate using statement for the namespace, and access the class directly.
 
Share this answer
 
Comments
memd24 4-Mar-14 11:05am    
Thanks, I know that
The problem is the dll, is from c++ project. Thats why I need to use dllImport y call the class name and methods
OriginalGriff 4-Mar-14 11:24am    
AFAIK, you can't use DLLImport on anything other than functions - you need to use a .NET wrapper to access it and access that via a reference.
See here: http://stackoverflow.com/questions/7130892/how-to-use-c-class-instance-in-c-sharp

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