Click here to Skip to main content
15,887,683 members
Home / Discussions / COM
   

COM

 
QuestionAdding Workbook In Excel Pin
SB_CodeForFun6-Dec-11 20:02
SB_CodeForFun6-Dec-11 20:02 
QuestionNeed Com Help - I'm a beginner Pin
jkirkerx6-Nov-11 8:48
professionaljkirkerx6-Nov-11 8:48 
AnswerRe: Need Com Help - I'm a beginner Pin
«_Superman_»6-Nov-11 15:36
professional«_Superman_»6-Nov-11 15:36 
GeneralRe: Need Com Help - I'm a beginner Pin
jkirkerx6-Nov-11 19:34
professionaljkirkerx6-Nov-11 19:34 
GeneralRe: Need Com Help - I'm a beginner Pin
jkirkerx9-Nov-11 7:36
professionaljkirkerx9-Nov-11 7:36 
QuestionHow to use unregistered tlb file Pin
SB_CodeForFun30-Oct-11 23:54
SB_CodeForFun30-Oct-11 23:54 
AnswerRe: How to use unregistered tlb file Pin
DriveByCoder24-Mar-15 7:48
professionalDriveByCoder24-Mar-15 7:48 
QuestionCOM Component Late binding trouble Pin
nilarya25-Aug-11 6:28
nilarya25-Aug-11 6:28 
Hi All,

I have posted this message earlier on the ASP.Net forum, I did not notice there is a separate forum for Co Componenets. However I am moving the post to here, please have a look, any help would be much appreciated.

I am using a third Party Com Component in my ASP.NET application. I dont have much experience with COM Components and I think I have messed up here. Please help.

The Com component has a method which looks like following in the ILDASM:

.method public hidebysig newslot specialname virtual
instance class [stdole]stdole.IPicture
marshal( interface )
get_Preview([in] float64 rWorldMinX,
[in] float64 rWorldMinY,
[in] float64 rWorldMaxX,
[in] float64 rWorldMaxY,
[in] int32 dwPicWidth,
[in] int32 dwPicHeight,
[in] int32 PicType) runtime managed internalcall

In my code behind, I am using


C#
object ComObjLateBound;
Type ComObjType;
ComObjType= Type.GetTypeFromCLSID(new Guid("{89251546-3F1C-430D-BA77-F86572FA4EF6}"));
ComObjLateBound= Activator.CreateInstance(ComObjType);
 
//getting the values from the properties. The properties are in the Com Component 
double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMaxY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMinX", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
double viewMaxX = (double)ComObjType.InvokeMember("ViewMinY", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, new object[] { });
 
//geting the image height and width from a local file
int imagewidth, imageheight, pictype;
imagewidth = 1280; imageheight = 800; pictype = 1;
 
object[] previewDetails = new object[7];
previewDetails[0] = viewMinX;
 
previewDetails[1] = viewMinY;
 
previewDetails[2] = viewMaxX;
 
previewDetails[3] = viewMaxY;
 
previewDetails[4] = imagewidth;
 
previewDetails[5] = imageheight;
 
previewDetails[6] = pictype;
 
 
IPicture picture = (IPicture)ComObjType.InvokeMember("get_Preview", BindingFlags.Default | BindingFlags.InvokeMethod, null, ComObjLateBound, previewDetails);



this fails with a COM Exception like

{"Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"}

with an ErrorCode of -2147352570 if that means something.

Now this is strange, because the exception type and Error Code remains exactly the same if I use any name instead of "get_Preview".

the COM component also has a Preview Property which looks the following in ILDASM:

.property class [stdole]stdole.IPicture Preview(float64,
float64,
float64,
float64,
int32,
int32,
int32)
I have also tried to use this property to get the IPicture value like:

C#
IPicture picture = (IPicture)ComObjType.InvokeMember("Preview", BindingFlags.Default | BindingFlags.GetProperty, null, ComObjLateBound, previewDetails);


But it also falis with a message that Exception has been thrown by the target of an invocation.

Please note, I am not able to use early binding on this component as it gives me an error message -

Unable to cast COM object of type '<>' to interface type '<>'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{}' failed due to the following error: No such interface supported.

I think I am doing something wrong here. Can you please point out what it is?

Thanks in advance.

AnswerRe: COM Component Late binding trouble Pin
tom-englert21-Sep-11 1:20
tom-englert21-Sep-11 1:20 
GeneralRe: COM Component Late binding trouble Pin
nilarya6-Oct-11 23:27
nilarya6-Oct-11 23:27 
GeneralRe: COM Component Late binding trouble Pin
tom-englert7-Oct-11 3:59
tom-englert7-Oct-11 3:59 
GeneralRe: COM Component Late binding trouble Pin
nilarya7-Oct-11 22:46
nilarya7-Oct-11 22:46 
GeneralRe: COM Component Late binding trouble Pin
nilarya7-Oct-11 22:57
nilarya7-Oct-11 22:57 
GeneralRe: COM Component Late binding trouble Pin
nilarya23-Oct-11 23:27
nilarya23-Oct-11 23:27 
GeneralRe: COM Component Late binding trouble Pin
tom-englert7-Nov-11 6:23
tom-englert7-Nov-11 6:23 
AnswerRe: COM Component Late binding trouble Pin
Vi25-Oct-11 0:39
Vi25-Oct-11 0:39 
QuestionUnable to register 64 bit COM Server Pin
sandeepkavade17-Aug-11 2:07
sandeepkavade17-Aug-11 2:07 
AnswerRe: Unable to register 64 bit COM Server Pin
Shameel17-Aug-11 2:32
professionalShameel17-Aug-11 2:32 
AnswerRe: Unable to register 64 bit COM Server Pin
«_Superman_»19-Aug-11 4:18
professional«_Superman_»19-Aug-11 4:18 
QuestionRegarding SheetCalculate event in Excel API Pin
gtag20-Jun-11 10:02
gtag20-Jun-11 10:02 
AnswerRe: Regarding SheetCalculate event in Excel API Pin
«_Superman_»13-Jul-11 7:04
professional«_Superman_»13-Jul-11 7:04 
AnswerI need help...(context menu shell extension) [modified] Pin
T800G5-Jun-11 4:53
T800G5-Jun-11 4:53 
Questionhow do i find all "src" attributes from frame object of html document? Pin
yogish29313-May-11 3:20
yogish29313-May-11 3:20 
AnswerRe: how do i find all "src" attributes from frame object of html document? Pin
«_Superman_»21-Jun-11 19:43
professional«_Superman_»21-Jun-11 19:43 
QuestionHow to create an OLE control in EXCEL sheet? Pin
whiteclouds27-Apr-11 23:46
whiteclouds27-Apr-11 23: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.