Click here to Skip to main content
15,845,681 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I created a sample application in VC++ with two constructors....
class CFirst_ATL
    //Default constructor
    Num1 = 10;
    Num2 = 5;

    //Parameterized constructor
    CFirst_ATL(int val1,int val2)
        Num1 = val1;
        Num2 = val2;
	int Num1,Num2;
	STDMETHOD(AddNumbers)(LONG* ReturnVal);
	STDMETHOD(SubNumbers)(LONG* ReturnVal);
	STDMETHOD(MulNumbers)(LONG* ReturnVal);
	STDMETHOD(DivNumbers)(LONG* ReturnVal);

I referenced the dll to my c# application and works fine for default constructor.
I want to call parameterized constructor from my c# application for that I used this code

IFirst_ATL obj = new First_ATL(2,1);

Even after this, value is assigned with 10 and 5 only not 1 and 2.
Can anyone help me on this?

Thanks in advance.
Updated 17-Apr-13 20:59pm
Sergey Alexandrovich Kryukov 18-Apr-13 1:19am    
The class name: First_ATL or CFirst_ATL? When you show not the real code you would paste but write it right on the page, any kinds of problems can happen. Don't you have both classes, slightly different?

Initializers in constructors have special syntax like ": Num1(val1)", but this is not yes a problem. Will you show the declaration of Num1, Num2?

♥…ЯҠ…♥ 18-Apr-13 1:24am    
Class name is CFirst_ATL. I updated the class with declarations.
TrushnaK 18-Apr-13 2:22am    
i may think here is problem
IFirst_ATL obj = new First_ATL(2,1);
your class name CFirst_Alt
IFirst_ATL obj = new CFirst_ATL(2,1);
try for this
♥…ЯҠ…♥ 18-Apr-13 2:38am    
I tried this too... throws missing assembly reference library.
TrushnaK 18-Apr-13 3:04am    
check your bin folder is that dll file is there. If that file available then check reference. Remove the current reference to that dll and make another reference.

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