Click here to Skip to main content
15,895,606 members
Home / Discussions / C#
   

C#

 
AnswerRe: error in insert 'msman88' Pin
Luc Pattyn1-May-10 8:36
sitebuilderLuc Pattyn1-May-10 8:36 
AnswerRe: error in insert 'msman88' Pin
Abhinav S1-May-10 8:36
Abhinav S1-May-10 8:36 
Questionhow to bring Graphic shapes to front of Form Pin
jojoba20111-May-10 4:05
jojoba20111-May-10 4:05 
AnswerRe: how to bring Graphic shapes to front of Form Pin
egenis1-May-10 4:46
egenis1-May-10 4:46 
AnswerRe: how to bring Graphic shapes to front of Form Pin
DaveyM691-May-10 10:26
professionalDaveyM691-May-10 10:26 
QuestionMicrosoft Office dictioanries Pin
LiorY19891-May-10 3:48
LiorY19891-May-10 3:48 
AnswerRe: Microsoft Office dictioanries Pin
Abhinav S1-May-10 6:08
Abhinav S1-May-10 6:08 
QuestionInteroperability Pin
Chiman11-May-10 1:55
Chiman11-May-10 1:55 
I am working on an application where I am using C# .net as well as ATL COM.

I have created below classes

1) Class Add, Which is created using C# .Net. And which implement Addition functionality. This class uses IAdd interface which is having Add method to perform addition. (Please note that IAdd is an com interface and we have used it by creating interop dll)

public class Add : IAdd
    {
        #region IAdd Members

        void IAdd.Add(double P1, double P2)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }


2) Class Calculate (com visible component), which is created using C# .Net. And which internally uses Class ADD to perform addition. . (Please note that ICustom is an com interface and we have used it by creating interop dll)

class Calculate : ICustom
    { 
        #region ICustom Members
        Add add = new Add ();
        #endregion

        #region ICustom Members

        void  ICustom.CustomQueryInterface(Guid id, ref object ptr)
        {
 	        throw new Exception("The method or operation is not    implemented.");
        }

        #endregion
        }


3) Class Client, This class is created using ATL COM, which crates the object of class Calculate as “calculate“ and then tries to retrieve interface IAdd using object calculate.

To get the IAdd interface, what I have done is I have created a Custom Interface which contain a method similar to the Query Interface () method available in the IUnknownInterface.

This interface is then implemented by the class Calculate, Now whenever client requires an IADD interface pointer; it will use ICustomInterface to retrieve it.

Please suggest:

What should be the implementation Of .CustomQueryInterface(Guid id, ref object ptr)?

Also what should be the code at client side (Client is implemented inCOM)


IDL file :


[
	object,
	uuid(E99CD31D-34FE-4AFF-A1E6-C438F73F685F),
	dual,
	nonextensible,
	helpstring("ICOMClient Interface"),
	pointer_default(unique)
]
interface ICOMClient : IDispatch{
	
	[id(1), helpstring("method PerformCalculation")] HRESULT PerformCalculation(void);
};

[
	object,
	uuid(53F4B9FA-B6E7-42aa-939B-97B93010270F),
	dual,
	nonextensible,
	helpstring("IAdd Interface"),
	pointer_default(unique)
]
interface IAdd : IUnknown{
	[id(1), helpstring("method Add")] HRESULT Add([in] DOUBLE P1, [in] DOUBLE P2);
};

[
	object,
	uuid(8C4DE0FA-6D4B-4c52-9E35-72D1908D3457),
	dual,
	nonextensible,
	helpstring("ICustom Interface"),
	pointer_default(unique)
]
interface ICustom : IUnknown{
	[id(1), helpstring("method CustomQueryInterface")] HRESULT CustomQueryInterface(GUID id ,IUnknown** ptr);
};

AnswerRe: Interoperability Pin
ThatsAlok2-May-10 20:20
ThatsAlok2-May-10 20:20 
Questionhow to change a value over a set period of time Pin
kennyhibs30-Apr-10 22:23
kennyhibs30-Apr-10 22:23 
AnswerRe: how to change a value over a set period of time Pin
OriginalGriff30-Apr-10 22:30
mveOriginalGriff30-Apr-10 22:30 
AnswerRe: how to change a value over a set period of time Pin
Luc Pattyn1-May-10 4:04
sitebuilderLuc Pattyn1-May-10 4:04 
QuestionMessage Removed Pin
30-Apr-10 21:59
mrkeivan30-Apr-10 21:59 
AnswerRe: An object reference is required for the non-static field, method, or property !? :( Pin
OriginalGriff30-Apr-10 22:26
mveOriginalGriff30-Apr-10 22:26 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
Abhinav S30-Apr-10 22:50
Abhinav S30-Apr-10 22:50 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
Luc Pattyn1-May-10 3:11
sitebuilderLuc Pattyn1-May-10 3:11 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
OriginalGriff1-May-10 3:46
mveOriginalGriff1-May-10 3:46 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
Luc Pattyn1-May-10 3:55
sitebuilderLuc Pattyn1-May-10 3:55 
GeneralMessage Removed Pin
1-May-10 3:58
harold aptroot1-May-10 3:58 
GeneralMessage Removed Pin
1-May-10 4:03
mveOriginalGriff1-May-10 4:03 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
Luc Pattyn1-May-10 4:16
sitebuilderLuc Pattyn1-May-10 4:16 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
OriginalGriff1-May-10 5:32
mveOriginalGriff1-May-10 5:32 
GeneralMessage Removed Pin
harold aptroot1-May-10 5:33
harold aptroot1-May-10 5:33 
GeneralRe: An object reference is required for the non-static field, method, or property !? :( Pin
Luc Pattyn1-May-10 4:14
sitebuilderLuc Pattyn1-May-10 4:14 
GeneralMessage Removed Pin
1-May-10 4:46
harold aptroot1-May-10 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.